From 9e8edc52f9c0635a2ace60dd66d6736d37a79fce Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 30 Sep 2020 19:05:51 +0300 Subject: [PATCH 1/6] Shellcheck fix --- test.extensions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.extensions.sh b/test.extensions.sh index 375c303..75bb99e 100755 --- a/test.extensions.sh +++ b/test.extensions.sh @@ -55,5 +55,5 @@ for extension in extensions/*; do done after="$(php -m)$(php -v)" -echo "After: $after\nDiff:" +printf "After: %s\nDiff:" "$after" diff -u <(echo "$before") <(echo "$after") || true From f724081bad61eaa2fdac0f108e7115a29d59bf98 Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 17 Mar 2021 10:34:48 +0200 Subject: [PATCH 2/6] Update for use in Jenkins --- Jenkinsfile | 5 +++++ quality.sh | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 quality.sh diff --git a/Jenkinsfile b/Jenkinsfile index 52fba9c..7fa3005 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,11 @@ pipeline { stage('Build, Test, Publish') { agent { label 'my127ws' } stages { + stage('Quality Checks') { + steps { + sh './quality.sh' + } + } stage('Build') { steps { sh './build.sh' diff --git a/quality.sh b/quality.sh new file mode 100755 index 0000000..e9245fa --- /dev/null +++ b/quality.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e -o pipefail + +docker pull koalaman/shellcheck:latest +run_shellcheck() +{ + local script="$1" + echo -n "Linting '$script': " + docker run --rm -i koalaman/shellcheck:latest --exclude SC1008,SC1091 - < "$script" && echo "OK" +} +export -f run_shellcheck + +find . -type f ! -path "./.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -exec bash -ec 'run_shellcheck "$0"' {} \; From e7ce6f6fd8d9cb5b1f2f12eb1d38ade600b98f57 Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 17 Mar 2021 10:37:13 +0200 Subject: [PATCH 3/6] Only run once per pipeline --- Jenkinsfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7fa3005..7b8202a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,17 @@ pipeline { } triggers { cron(env.BRANCH_NAME ==~ /^main$/ ? 'H H(0-6) 1 * *' : '') } stages { + stage('Quality Checks') { + agent { label 'my127ws' } + steps { + sh './quality.sh' + } + post { + always { + cleanWs() + } + } + } stage('Matrix') { matrix { axes { @@ -18,11 +29,6 @@ pipeline { stage('Build, Test, Publish') { agent { label 'my127ws' } stages { - stage('Quality Checks') { - steps { - sh './quality.sh' - } - } stage('Build') { steps { sh './build.sh' From 733875be9ccfb89dbd5d7f6b0eb92ef44666e85e Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 17 Mar 2021 10:49:32 +0200 Subject: [PATCH 4/6] Speed up quality check --- quality.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/quality.sh b/quality.sh index e9245fa..180082f 100755 --- a/quality.sh +++ b/quality.sh @@ -1,14 +1,9 @@ #!/bin/bash - set -e -o pipefail -docker pull koalaman/shellcheck:latest +docker pull koalaman/shellcheck-alpine:stable run_shellcheck() { - local script="$1" - echo -n "Linting '$script': " - docker run --rm -i koalaman/shellcheck:latest --exclude SC1008,SC1091 - < "$script" && echo "OK" + docker run --rm --volume "$(pwd):/app" koalaman/shellcheck-alpine:stable /bin/sh -c 'find /app -type f ! -path "*/.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -exec shellcheck --exclude SC1008,SC1091 {} +' } -export -f run_shellcheck - -find . -type f ! -path "./.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -exec bash -ec 'run_shellcheck "$0"' {} \; +run_shellcheck From 7171116457a562398179ef20de9a22227f1eb48e Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 17 Mar 2021 10:54:03 +0200 Subject: [PATCH 5/6] List files being looked at --- quality.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quality.sh b/quality.sh index 180082f..03aba3d 100755 --- a/quality.sh +++ b/quality.sh @@ -4,6 +4,6 @@ set -e -o pipefail docker pull koalaman/shellcheck-alpine:stable run_shellcheck() { - docker run --rm --volume "$(pwd):/app" koalaman/shellcheck-alpine:stable /bin/sh -c 'find /app -type f ! -path "*/.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -exec shellcheck --exclude SC1008,SC1091 {} +' + docker run --rm --volume "$(pwd):/app" koalaman/shellcheck-alpine:stable /bin/sh -c 'find /app -type f ! -path "*/.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -print -exec shellcheck --exclude SC1008,SC1091 {} +' } run_shellcheck From 6cb1b13206278fe3f585bb08118635c947f1c874 Mon Sep 17 00:00:00 2001 From: Kieren Evans Date: Wed, 17 Mar 2021 17:41:07 +0200 Subject: [PATCH 6/6] Only pull if missing --- quality.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quality.sh b/quality.sh index 03aba3d..125599e 100755 --- a/quality.sh +++ b/quality.sh @@ -1,7 +1,10 @@ #!/bin/bash set -e -o pipefail -docker pull koalaman/shellcheck-alpine:stable +if ! docker image ls -a --format '{{ print .Repository ":" .Tag }}' | grep -q koalaman/shellcheck-alpine:stable; then + docker pull koalaman/shellcheck-alpine:stable +fi + run_shellcheck() { docker run --rm --volume "$(pwd):/app" koalaman/shellcheck-alpine:stable /bin/sh -c 'find /app -type f ! -path "*/.git/*" ! -name "*.orig" -and \( -name "*.sh" -or -perm -0111 \) -print -exec shellcheck --exclude SC1008,SC1091 {} +'