Skip to content

Commit 71f9f91

Browse files
authored
Merge pull request #1726 from kolyshkin/bump-shellcheck
ci: improve shellcheck job
2 parents 636520b + 739a2bf commit 71f9f91

File tree

4 files changed

+45
-36
lines changed

4 files changed

+45
-36
lines changed

.github/workflows/test.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,20 @@ jobs:
190190
runs-on: ubuntu-latest
191191
steps:
192192
- uses: actions/checkout@v4
193-
- name: vars
194-
run: |
195-
echo 'VERSION=v0.8.0' >> $GITHUB_ENV
196-
echo 'BASEURL=https://github.com/koalaman/shellcheck/releases/download' >> $GITHUB_ENV
197-
echo 'SHA256SUM=f4bce23c11c3919c1b20bcb0f206f6b44c44e26f2bc95f8aa708716095fa0651' >> $GITHUB_ENV
198-
echo ~/bin >> $GITHUB_PATH
199193
- name: install shellcheck
194+
env:
195+
VERSION: v0.10.0
196+
BASEURL: https://github.com/koalaman/shellcheck/releases/download
197+
SHA256: f35ae15a4677945428bdfe61ccc297490d89dd1e544cc06317102637638c6deb
200198
run: |
201199
mkdir ~/bin
202200
curl -sSfL --retry 5 $BASEURL/$VERSION/shellcheck-$VERSION.linux.x86_64.tar.xz |
203201
tar xfJ - -C ~/bin --strip 1 shellcheck-$VERSION/shellcheck
204-
sha256sum ~/bin/shellcheck | grep -q $SHA256SUM
202+
sha256sum --strict --check - <<<"$SHA256 *$HOME/bin/shellcheck"
205203
# make sure to remove the old version
206204
sudo rm -f /usr/bin/shellcheck
205+
# Add ~/bin to $PATH.
206+
echo ~/bin >> $GITHUB_PATH
207207
- name: install dependencies
208208
run: |
209209
sudo apt-get update -q -y

Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,6 @@ clang-format:
320320
git ls-files src tests | grep -E "\\.[hc]" | grep -v "blake3\|chroot_realpath.c\|cloned_binary.c\|signals.c\|mount_flags.c" | xargs clang-format -style=file -i
321321

322322
shellcheck:
323-
shellcheck tests/*/*.sh contrib/*.sh
323+
shellcheck autogen.sh build-aux/release.sh tests/run_all_tests.sh tests/*/*.sh contrib/*.sh
324324

325325
.PHONY: coverity sync generate-rust-bindings generate-signals.c generate-mount_flags.c clang-format shellcheck

build-aux/release.sh

+32-23
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,63 @@ test -e Makefile && make distclean
1313

1414
./configure
1515

16-
make -j $(nproc)
16+
make -j "$(nproc)"
1717

18-
VERSION=$($(dirname $0)/git-version-gen --prefix "" .)
19-
if test x$SKIP_CHECKS = x; then
20-
grep $VERSION NEWS
18+
VERSION="$("$(dirname "$0")/git-version-gen" --prefix "" .)"
19+
if test "$SKIP_CHECKS" = ""; then
20+
grep "$VERSION" NEWS
2121
fi
2222

2323
OUTDIR=${OUTDIR:-release-$VERSION}
24-
if test -e $OUTDIR; then
24+
if test -e "$OUTDIR"; then
2525
echo "the directory $OUTDIR already exists" >&2
2626
exit 1
2727
fi
2828

29-
mkdir -p $OUTDIR
29+
mkdir -p "$OUTDIR"
3030

3131
rm -f crun-*.tar*
3232

3333
make dist-gzip
3434
make ZSTD_OPT="--ultra -c22" dist-zstd
3535

36-
mv crun-*.tar.gz $OUTDIR
37-
mv crun-*.tar.zst $OUTDIR
36+
mv crun-*.tar.gz "$OUTDIR"
37+
mv crun-*.tar.zst "$OUTDIR"
3838

3939
make distclean
4040

41-
RUNTIME=${RUNTIME:-podman}
42-
RUNTIME_EXTRA_ARGS=${RUNTIME_EXTRA_ARGS:-}
41+
read -r -a RUNTIME_EXTRA_ARGS <<< "${RUNTIME_EXTRA_ARGS:-}"
42+
43+
BUILD_CMD=(
44+
"${RUNTIME:-podman}" run --init --rm
45+
"${RUNTIME_EXTRA_ARGS[@]}"
46+
--privileged
47+
-v /nix:/nix -v "${PWD}:${PWD}"
48+
-w "${PWD}"
49+
"${NIX_IMAGE}"
50+
nix
51+
--extra-experimental-features nix-command
52+
--print-build-logs
53+
--option cores "$(nproc)"
54+
--option max-jobs "$(nproc)"
55+
build
56+
--max-jobs auto
57+
)
4358

4459
mkdir -p /nix
4560

46-
NIX_ARGS="--extra-experimental-features nix-command --print-build-logs --option cores $(nproc) --option max-jobs $(nproc)"
47-
4861
for ARCH in amd64 arm64 ppc64le riscv64 s390x; do
49-
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
50-
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix
51-
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}
52-
62+
"${BUILD_CMD[@]}" --file nix/default-${ARCH}.nix
63+
cp ./result/bin/crun "$OUTDIR/crun-$VERSION-linux-${ARCH}"
5364
rm -rf result
5465

55-
$RUNTIME run --init --rm $RUNTIME_EXTRA_ARGS --privileged -v /nix:/nix -v ${PWD}:${PWD} -w ${PWD} ${NIX_IMAGE} \
56-
nix $NIX_ARGS build --max-jobs auto --file nix/default-${ARCH}.nix --arg enableSystemd false
57-
cp ./result/bin/crun $OUTDIR/crun-$VERSION-linux-${ARCH}-disable-systemd
58-
66+
"${BUILD_CMD[@]}" --file nix/default-${ARCH}.nix --arg enableSystemd false
67+
cp ./result/bin/crun "$OUTDIR/crun-$VERSION-linux-${ARCH}-disable-systemd"
5968
rm -rf result
6069
done
6170

62-
if test x$SKIP_GPG = x; then
63-
for i in $OUTDIR/*; do
64-
gpg2 -b --armour $i
71+
if test "$SKIP_GPG" = ""; then
72+
for i in "$OUTDIR"/*; do
73+
gpg2 -b --armour "$i"
6574
done
6675
fi

tests/run_all_tests.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ OCI_RUNTIME=${OCI_RUNTIME:-/usr/bin/crun}
66
export INIT
77
export OCI_RUNTIME
88

9-
rm -f *.trs
9+
rm -f -- *.trs
1010

11-
COLOR=
11+
COLOR="no"
1212
if [ -t 1 ]; then
13-
COLOR="--color-tests yes"
13+
COLOR="yes"
1414
fi
1515

1616
for i in test_*.py
1717
do
18-
./tap-driver.sh --test-name $i --log-file $i.log --trs-file $i.trs ${COLOR} --enable-hard-errors yes --expect-failure no -- /usr/bin/python $i
18+
./tap-driver.sh --test-name "$i" --log-file "$i.log" --trs-file "$i.trs" --color-tests "${COLOR}" --enable-hard-errors yes --expect-failure no -- /usr/bin/python "$i"
1919
done
2020

21-
if grep FAIL *.trs; then
21+
if grep FAIL -- *.trs; then
2222
exit 1
2323
fi

0 commit comments

Comments
 (0)