Skip to content

Commit f1b3a2c

Browse files
committed
add super linter
1 parent a7957a2 commit f1b3a2c

File tree

4 files changed

+123
-61
lines changed

4 files changed

+123
-61
lines changed

.github/workflows/linter.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ********************************************************************************
2+
# Copyright (c) 2020 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made
8+
# available under the terms of the Apache Software License 2.0
9+
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# ********************************************************************************
13+
14+
---
15+
###########################
16+
###########################
17+
## Linter GitHub Actions ##
18+
###########################
19+
###########################
20+
name: Linter
21+
22+
#
23+
# Documentation:
24+
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
25+
#
26+
27+
#############################
28+
# Start the job on all push #
29+
#############################
30+
on:
31+
pull_request:
32+
branches: [ main ]
33+
34+
###############
35+
# Set the Job #
36+
###############
37+
permissions:
38+
contents: read
39+
40+
jobs:
41+
linter:
42+
permissions:
43+
contents: read # for actions/checkout to fetch code
44+
statuses: write # for github/super-linter to mark status of each linter run
45+
# Name the Job
46+
name: Lint Code Base
47+
# Set the agent to run on
48+
runs-on: ubuntu-latest
49+
50+
##################
51+
# Load all steps #
52+
##################
53+
steps:
54+
##########################
55+
# Checkout the code base #
56+
##########################
57+
- name: Checkout Code
58+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
59+
with:
60+
# Full git history is needed to get a proper list of changed files within `super-linter`
61+
fetch-depth: 0
62+
63+
################################
64+
# Run Linter against code base #
65+
################################
66+
- name: Lint Code Base
67+
uses: github/super-linter@45fc0d88288beee4701c62761281edfee85655d7 # v5.0.0
68+
env:
69+
VALIDATE_ALL_CODEBASE: true
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
# Markdown lint complains about the issue templates
72+
FILTER_REGEX_EXCLUDE: .github/ISSUE_TEMPLATE/*

.test/config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22

3+
# shellcheck disable=SC2154
34
imageTests[openjdk]+='
45
java-ca-certificates-update
56
'

.test/tests/java-ca-certificates-update/run.sh

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
set -o pipefail
44

5+
# shellcheck disable=SC2128
56
testDir="$(readlink -f "$(dirname "$BASH_SOURCE")")"
7+
# shellcheck disable=SC2128
68
runDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
79

810
# CMD1 in each run is just a `date` to make sure nothing is broken with or without the entrypoint
9-
CMD1=date
11+
CMD1="date"
1012

1113
# CMD2 in each run is to check for the `dockerbuilder` certificate in the Java keystore. Entrypoint export $CACERT to
1214
# point to the Java keystore.
@@ -36,86 +38,86 @@ EOF
3638
#
3739

3840
# Test run 1: No added certificates and environment variable is not set. We expect CMD1 to succeed and CMD2 to fail.
39-
docker run --rm "$1" $CMD1 >&/dev/null
41+
docker run --rm "$1" "$CMD1" >&/dev/null
4042
echo -n $?
4143
docker run --rm "$1" "${CMD2[@]}" >&/dev/null
4244
echo -n $?
4345

4446
# Test run 2: No added certificates, but the environment variable is set. Since there are no certificates, we still
4547
# expect CMD1 to succeed and CMD2 to fail.
46-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 "$1" $CMD1 >&/dev/null
48+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "$CMD1" >&/dev/null
4749
echo -n $?
4850
docker run --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "${CMD2[@]}" >&/dev/null
4951
echo -n $?
5052

5153
# Test run 3: Certificates are mounted, but the environment variable is not set, i.e. certificate importing should not
5254
# be activated. We expect CMD1 to succeed and CMD2 to fail.
53-
docker run --rm --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null
55+
docker run --rm --volume="$testDir/certs:/certificates" "$1" "$CMD1" >&/dev/null
5456
echo -n $?
55-
docker run --rm --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null
57+
docker run --rm --volume="$testDir/certs:/certificates" "$1" "${CMD2[@]}" >&/dev/null
5658
echo -n $?
5759

5860
# Test run 4: Certificates are mounted and the environment variable is set. We expect both CMD1 and CMD2 to succeed.
59-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null
61+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$1" "$CMD1" >&/dev/null
6062
echo -n $?
61-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null
63+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$1" "${CMD2[@]}" >&/dev/null
6264
echo -n $?
6365

6466
# Test run 5: Certificates are mounted and are symlinks (e.g. in Kubernetes as `Secret`s or `ConfigMap`s) and the
6567
# environment variable is set. We expect both CMD1 and CMD2 to succeed.
66-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" $CMD1 >&/dev/null
68+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs_symlink:/certificates" "$1" "$CMD1" >&/dev/null
6769
echo -n $?
68-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" "${CMD2[@]}" >&/dev/null
70+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs_symlink:/certificates" "$1" "${CMD2[@]}" >&/dev/null
6971
echo -n $?
7072

7173
# Test run 6: Certificates are mounted and the environment variable is set, but the entrypoint is overridden. We expect
7274
# CMD1 to succeed and CMD2 to fail.
73-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" $CMD1 >&/dev/null
75+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$TESTIMAGE" "$CMD1" >&/dev/null
7476
echo -n $?
75-
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" "${CMD2[@]}" >&/dev/null
77+
docker run --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$TESTIMAGE" "${CMD2[@]}" >&/dev/null
7678
echo -n $?
7779

7880
#
7981
# PHASE 2: Non-root containers
8082
#
8183

8284
# Test run 1: No added certificates and environment variable is not set. We expect CMD1 to succeed and CMD2 to fail.
83-
docker run --read-only --user 1000:1000 --rm "$1" $CMD1 >&/dev/null
85+
docker run --read-only --user 1000:1000 --rm "$1" "$CMD1" >&/dev/null
8486
echo -n $?
8587
docker run --read-only --user 1000:1000 --rm "$1" "${CMD2[@]}" >&/dev/null
8688
echo -n $?
8789

8890
# Test run 2: No added certificates, but the environment variable is set. Since there are no certificates, we still
8991
# expect CMD1 to succeed and CMD2 to fail.
90-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 "$1" $CMD1 >&/dev/null
92+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "$CMD1" >&/dev/null
9193
echo -n $?
9294
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 "$1" "${CMD2[@]}" >&/dev/null
9395
echo -n $?
9496

9597
# Test run 3: Certificates are mounted, but the environment variable is not set, i.e. certificate importing should not
9698
# be activated. We expect CMD1 to succeed and CMD2 to fail.
97-
docker run --read-only --user 1000:1000 --rm --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null
99+
docker run --read-only --user 1000:1000 --rm --volume="$testDir/certs:/certificates" "$1" "$CMD1" >&/dev/null
98100
echo -n $?
99-
docker run --read-only --user 1000:1000 --rm --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null
101+
docker run --read-only --user 1000:1000 --rm --volume="$testDir/certs:/certificates" "$1" "${CMD2[@]}" >&/dev/null
100102
echo -n $?
101103

102104
# Test run 4: Certificates are mounted and the environment variable is set. We expect both CMD1 and CMD2 to succeed.
103-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" $CMD1 >&/dev/null
105+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$1" "$CMD1" >&/dev/null
104106
echo -n $?
105-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$1" "${CMD2[@]}" >&/dev/null
107+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$1" "${CMD2[@]}" >&/dev/null
106108
echo -n $?
107109

108110
# Test run 5: Certificates are mounted and are symlinks (e.g. in Kubernetes as `Secret`s or `ConfigMap`s) and the
109111
# environment variable is set. We expect both CMD1 and CMD2 to succeed.
110-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" $CMD1 >&/dev/null
112+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs_symlink:/certificates" "$1" "$CMD1" >&/dev/null
111113
echo -n $?
112-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs_symlink:/certificates "$1" "${CMD2[@]}" >&/dev/null
114+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs_symlink:/certificates" "$1" "${CMD2[@]}" >&/dev/null
113115
echo -n $?
114116

115117
# Test run 6: Certificates are mounted and the environment variable is set, but the entrypoint is overridden. We expect
116118
# CMD1 to succeed and CMD2 to fail.
117119
#
118-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" $CMD1 >&/dev/null
120+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$TESTIMAGE" "$CMD1" >&/dev/null
119121
echo -n $?
120-
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume=$testDir/certs:/certificates "$TESTIMAGE" "${CMD2[@]}" >&/dev/null
122+
docker run --read-only --user 1000:1000 -v /tmp --rm -e USE_SYSTEM_CA_CERTS=1 --volume="$testDir/certs:/certificates" "$TESTIMAGE" "${CMD2[@]}" >&/dev/null
121123
echo -n $?

dockerhub_doc_config_update.sh

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ oses="alpine ubuntu ubi windowsservercore-ltsc2022 nanoserver-ltsc2022 windowsse
4141
# The image which is used by default when pulling shared tags on linux e.g 8-jdk
4242
default_linux_image="noble"
4343

44-
git_repo="https://github.com/adoptium/containers/blob/master"
45-
4644
# Get the latest git commit of the current repo.
4745
# This is assumed to have all the latest dockerfiles already.
4846
gitcommit=$(git log | head -1 | awk '{ print $2 }')
4947

5048
print_official_text() {
51-
echo "$*" >> ${official_docker_image_file}
49+
echo "$*" >> "${official_docker_image_file}"
5250
}
5351

5452
print_official_header() {
@@ -71,9 +69,9 @@ function generate_official_image_tags() {
7169
ojdk_version=${ojdk_version//+/_}
7270

7371
case $os in
74-
"ubuntu") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;;
75-
"ubi") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;;
76-
"windows") distro=$(echo $dfdir | awk -F '/' '{ print $4 }' ) ;;
72+
"ubuntu") distro=$(echo "$dfdir" | awk -F '/' '{ print $4 }' ) ;;
73+
"ubi") distro=$(echo "$dfdir" | awk -F '/' '{ print $4 }' ) ;;
74+
"windows") distro=$(echo "$dfdir" | awk -F '/' '{ print $4 }' ) ;;
7775
*) distro=$os;;
7876
esac
7977

@@ -82,10 +80,8 @@ function generate_official_image_tags() {
8280
# 8u212-jdk
8381
full_ver_tag="${ojdk_version}-${pkg}"
8482

85-
unset extra_shared_tags extra_ver_tags
83+
unset extra_shared_tags
8684
full_ver_tag="${full_ver_tag}-${distro}"
87-
# Commented out as this added the -hotspot tag which we don't need for temurin
88-
# extra_ver_tags=", ${ver}-${pkg}"
8985

9086
ver_tag="${ver}-${pkg}-${distro}"
9187
all_tags="${full_ver_tag}, ${ver_tag}"
@@ -94,7 +90,6 @@ function generate_official_image_tags() {
9490
jdk_tag="${ver}-${distro}"
9591
all_tags="${all_tags}, ${jdk_tag}"
9692
# make "eclipse-temurin:latest" point to newest supported JDK
97-
# shellcheck disable=SC2154
9893
if [ "${ver}" == "${latest_version}" ]; then
9994
if [ "${vm}" == "hotspot" ]; then
10095
extra_shared_tags=", latest"
@@ -103,44 +98,46 @@ function generate_official_image_tags() {
10398
fi
10499

105100
unset windows_shared_tags
106-
shared_tags=$(echo ${all_tags} | sed "s/-$distro//g")
107-
if [ $os == "windows" ]; then
108-
windows_version=$(echo $distro | awk -F '-' '{ print $1 }' )
109-
windows_version_number=$(echo $distro | awk -F '-' '{ print $2 }' )
110-
windows_shared_tags=$(echo ${all_tags} | sed "s/$distro/$windows_version/g")
101+
shared_tags="${all_tags//-$distro/}"
102+
103+
if [ "$os" == "windows" ]; then
104+
windows_version=$(echo "$distro" | awk -F '-' '{ print $1 }' )
105+
windows_version_number=$(echo "$distro" | awk -F '-' '{ print $2 }' )
106+
windows_shared_tags="${all_tags//$distro/$windows_version}"
111107
case $distro in
112108
nanoserver*)
113109
constraints="${distro}, windowsservercore-${windows_version_number}"
114110
all_shared_tags="${windows_shared_tags}"
115111
;;
116112
*)
117113
constraints="${distro}"
118-
all_shared_tags="${windows_shared_tags}, ${shared_tags}${extra_ver_tags}${extra_shared_tags}"
114+
all_shared_tags="${windows_shared_tags}, ${shared_tags}${extra_shared_tags}"
119115
;;
120116
esac
121117
else
122-
all_shared_tags="${shared_tags}${extra_ver_tags}${extra_shared_tags}"
118+
all_shared_tags="${shared_tags}${extra_shared_tags}"
123119
fi
124120
}
125121

126122
function generate_official_image_arches() {
127123
# Generate the supported arches for the above tags.
128-
# Official images supports amd64, arm64vX, s390x, ppc64le amd windows-amd64
129-
if [ $os == "windows" ]; then
124+
# Official images support amd64, arm64vX, s390x, ppc64le, and windows-amd64
125+
if [ "$os" == "windows" ]; then
130126
arches="windows-amd64"
131127
else
132128
# shellcheck disable=SC2046,SC2005,SC1003,SC2086,SC2063
133129
arches=$(echo $(grep ') \\' ${file} | grep -v "*" | sed 's/) \\//g; s/|//g'))
134-
arches=$(echo ${arches} | sed 's/x86_64/amd64/g') # replace x86_64 with amd64
135-
arches=$(echo ${arches} | sed 's/ppc64el/ppc64le/g') # replace ppc64el with ppc64le
136-
arches=$(echo ${arches} | sed 's/arm64/arm64v8/g') # replace arm64 with arm64v8
137-
arches=$(echo ${arches} | sed 's/aarch64/arm64v8/g') # replace aarch64 with arm64v8
138-
arches=$(echo ${arches} | sed 's/armhf/arm32v7/g') # replace armhf with arm32v7
130+
arches="${arches//x86_64/amd64}" # replace x86_64 with amd64
131+
arches="${arches//ppc64el/ppc64le}" # replace ppc64el with ppc64le
132+
arches="${arches//arm64/arm64v8}" # replace arm64 with arm64v8
133+
arches="${arches//aarch64/arm64v8}" # replace aarch64 with arm64v8
134+
arches="${arches//armhf/arm32v7}" # replace armhf with arm32v7
139135
# sort arches alphabetically
140-
arches=$(echo ${arches} | tr ' ' '\n' | sort | tr '\n' ' ' | sed 's/ /, /g' | sed 's/, $//')
136+
arches=$(echo "${arches}" | tr ' ' '\n' | sort | tr '\n' ' ' | sed 's/ /, /g' | sed 's/, $//')
141137
fi
142138
}
143139

140+
144141
function print_official_image_file() {
145142
# Retrieve the latest manifest block
146143
official_manifest=$(sed -n "/${all_tags}/,/^$/p" official-eclipse-temurin)
@@ -178,15 +175,15 @@ function print_official_image_file() {
178175
echo "Architectures: ${arches}"
179176
echo "GitCommit: ${commit}"
180177
echo "Directory: ${dfdir}"
181-
if [ $os == "windows" ]; then
178+
if [ "$os" == "windows" ]; then
182179
echo "Builder: classic"
183180
echo "Constraints: ${constraints}"
184181
fi
185182
echo ""
186-
} >> ${official_docker_image_file}
183+
} >> "${official_docker_image_file}"
187184
}
188185

189-
rm -f ${official_docker_image_file}
186+
rm -f "${official_docker_image_file}"
190187
print_official_header
191188

192189
official_os_ignore_array=(clefos debian debianslim leap tumbleweed)
@@ -201,7 +198,7 @@ function generate_official_image_info() {
201198
fi
202199
done
203200
if [ "${os}" == "windows" ]; then
204-
distro=$(echo $dfdir | awk -F '/' '{ print $4 }' )
201+
distro=$(echo "$dfdir" | awk -F '/' '{ print $4 }' )
205202
# 20h2 and 1909 is not supported upstream
206203
if [[ "${distro}" == "windowsservercore-20h2" ]] || [[ "${distro}" == "windowsservercore-1909" ]] || [[ "${distro}" == "windowsservercore-ltsc2019" ]] ; then
207204
return;
@@ -210,10 +207,6 @@ function generate_official_image_info() {
210207
return;
211208
fi
212209
fi
213-
# We do not push our nightly and slim images either.
214-
if [ "${build}" == "nightly" ] || [ "${btype}" == "slim" ]; then
215-
return;
216-
fi
217210

218211
generate_official_image_tags
219212
generate_official_image_arches
@@ -239,14 +232,8 @@ do
239232
# dockerfile name
240233
dfname=$(basename "${file}")
241234
# dockerfile dir
242-
dfdir=$(dirname $file | cut -c 3-)
235+
dfdir=$(dirname "${file}" | cut -c 3-)
243236
os=$(echo "${file}" | awk -F '/' '{ print $4 }')
244-
# build = release or nightly
245-
# build=$(echo "${dfname}" | awk -F "." '{ print $3 }')
246-
build="release"
247-
# btype = full or slim
248-
# btype=$(echo "${dfname}" | awk -F "." '{ print $4 }')
249-
build="full"
250237
generate_official_image_info
251238
done
252239
done

0 commit comments

Comments
 (0)