CI: shellcheck: adjust for 'pmbootstrap ci' (MR 3608)
Split out the grep for CHANGEME into a separate .ci/grep.sh script, as it's not related to shellcheck and also there's another grep check that I'll move there in a follow-up patch.
This commit is contained in:
parent
613aa1c68a
commit
c88cfa516f
3 changed files with 30 additions and 14 deletions
16
.ci/grep.sh
Executable file
16
.ci/grep.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Description: check various bad patterns with grep
|
||||||
|
# https://postmarktos.org/pmb-ci
|
||||||
|
|
||||||
|
if [ "$(id -u)" = 0 ]; then
|
||||||
|
set -x
|
||||||
|
apk -q add grep
|
||||||
|
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find CHANGEMEs in APKBUILDs
|
||||||
|
if grep -qr '(CHANGEME!)' *; then
|
||||||
|
echo "ERROR: Please replace '(CHANGEME!)' in the following files:"
|
||||||
|
grep --color=always -r '(CHANGEME!)' *
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -1,16 +1,15 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
# Copyright 2021 Oliver Smith
|
# Copyright 2022 Oliver Smith
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
# Description: lint all shell scripts
|
||||||
|
# https://postmarktos.org/pmb-ci
|
||||||
|
|
||||||
set -e
|
DIR="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||||
DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
||||||
cd "$DIR/.."
|
|
||||||
|
|
||||||
# Find CHANGEMEs in APKBUILDs
|
if [ "$(id -u)" = 0 ]; then
|
||||||
if grep -qr '(CHANGEME!)' *; then
|
set -x
|
||||||
echo "ERROR: Please replace '(CHANGEME!)' in the following files:"
|
apk -q add shellcheck
|
||||||
grep --color=always -r '(CHANGEME!)' *
|
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Shell: shellcheck
|
# Shell: shellcheck
|
||||||
|
@ -42,8 +41,9 @@ sh_files="
|
||||||
|
|
||||||
$(find . -path '.ci/*.sh')
|
$(find . -path '.ci/*.sh')
|
||||||
"
|
"
|
||||||
|
|
||||||
for file in $sh_files; do
|
for file in $sh_files; do
|
||||||
echo "Test with shellcheck: $file"
|
echo "Test with shellcheck: $file"
|
||||||
cd "$DIR/../$(dirname "$file")"
|
cd "$DIR/$(dirname "$file")"
|
||||||
shellcheck -e SC1008 -x "$(basename "$file")"
|
shellcheck -e SC1008 -x "$(basename "$file")"
|
||||||
done
|
done
|
||||||
|
|
|
@ -51,15 +51,15 @@ flake8:
|
||||||
- .ci/lib/gitlab_prepare_ci.sh
|
- .ci/lib/gitlab_prepare_ci.sh
|
||||||
- .ci/flake8.sh
|
- .ci/flake8.sh
|
||||||
|
|
||||||
# shellcheck
|
# shellcheck and various grep checks
|
||||||
shellcheck:
|
shellcheck-grep:
|
||||||
stage: lint
|
stage: lint
|
||||||
<<: *only-default
|
<<: *only-default
|
||||||
image: alpine:edge
|
image: alpine:edge
|
||||||
before_script:
|
|
||||||
- apk -q add shellcheck
|
|
||||||
script:
|
script:
|
||||||
|
- .ci/lib/gitlab_prepare_ci.sh
|
||||||
- .ci/shellcheck.sh
|
- .ci/shellcheck.sh
|
||||||
|
- .ci/grep.sh
|
||||||
|
|
||||||
editor-config:
|
editor-config:
|
||||||
stage: lint
|
stage: lint
|
||||||
|
|
Loading…
Reference in a new issue