Skip to content

Commit

Permalink
[ci skip] Revert "contrib/check.sh: Use docker image directly"
Browse files Browse the repository at this point in the history
This reverts commit e665f90.
  • Loading branch information
ko1nksm committed Jul 4, 2019
1 parent 7711430 commit 04d3064
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 17 additions & 19 deletions contrib/check.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
# shellcheck disable=SC2046

# Check shell script files

Expand All @@ -12,21 +11,6 @@

set -eu

image="koalaman/shellcheck"

shellcheck() {
if ! docker --version >/dev/null 2>&1; then
echo "You need docker to run shellcheck" >&2
exit 1
fi

if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ]; then
pwd() { wslpath -w -a .; }
fi

docker run -i -v "$(pwd):/src" -w /src "$image" "$@"
}

sources() {
echo shellspec
find lib libexec -name '*.sh'
Expand All @@ -43,9 +27,9 @@ samples() {
count() {
printf '%6s: ' "$1"
shift
cat "$@" | wc -lc | {
cat $@ | wc -lc | {
read -r lines bytes
printf '%3s files, %5s lines, %3s KiB\n' $# "$lines" $((bytes / 1024))
printf '%3s files, %5s lines, %3s KiB\n' $# $lines $((bytes / 1024))
}
}

Expand All @@ -59,7 +43,21 @@ count sample $(samples)
count total $(sources; specs; samples)
echo

if ! docker --version >/dev/null 2>&1; then
echo "You need docker to run shellcheck" >&2
exit 1
fi

echo "Checking scripts by shellcheck..."
shellcheck -C $(sources; specs; samples)

tag="shellspec:shellcheck"

trap 'exit 1' INT
trap 'docker rmi "$tag" >/dev/null 2>&1' EXIT

# Volume can not be used on VolFs of WSL.
docker build -t "$tag" . -f dockerfiles/.shellcheck > /dev/null
docker run -i --rm "$tag" --version
docker run -i --rm "$tag" -C $(sources; specs; samples)

echo "ok"
2 changes: 2 additions & 0 deletions dockerfiles/.shellcheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM koalaman/shellcheck
COPY ./ ./

0 comments on commit 04d3064

Please sign in to comment.