Skip to content

Commit be7413b

Browse files
committed
Shellcheck fails should fail the command
1 parent ea5acd5 commit be7413b

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

hooks/command

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ fi
3737
echo "+++ Running shellcheck on ${#files[@]} files"
3838
if docker run --rm -v "$PWD:/mnt" koalaman/shellcheck "${files[@]}" ; then
3939
echo "Files are ok ✅"
40+
else
41+
exit 1
4042
fi

tests/run.bats

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ load '/usr/local/lib/bats/load.bash'
3333

3434
unstub docker
3535
}
36+
37+
@test "Shellcheck failure" {
38+
export BUILDKITE_PLUGIN_SHELLCHECK_FILES_0="tests/testdata/subdir/llamas.sh"
39+
40+
stub docker \
41+
"run --rm -v $PWD:/mnt koalaman/shellcheck tests/testdata/test.sh tests/testdata/subdir/llamas.sh tests/testdata/subdir/shell\ with\ space.sh' : echo shellcheck failed; exit 1"
42+
43+
run "$PWD/hooks/command"
44+
45+
assert_failure
46+
assert_output --partial "shellcheck failed"
47+
48+
unstub docker
49+
}

0 commit comments

Comments
 (0)