diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 537d9f56..11b6fad3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,3 +13,10 @@ jobs: - uses: actions/checkout@v2 - run: make test # - uses: mxschmitt/action-tmate@v3 + + style: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - run: make style-check diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 00000000..14d56a9d --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,5 @@ +shell=bash + +enable=quote-safe-variables + +disable=1091,2030,2031,2034 diff --git a/Makefile b/Makefile index fbec8c38..43c5ff97 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ SHELL := bash +SHELL_FILES := $(shell file --mime-type bin/* | grep text/x-shellscript | cut -d: -f1) export ROOT := $(shell pwd) @@ -48,6 +49,9 @@ test: make gh-pages make clean +style-check: + shellcheck $(SHELL_FILES) + add-new: for f in new/*; do cp "$$f" "src/$${f#*-}"; done diff --git a/bin/new-test-file b/bin/new-test-file index e77313cc..97e9fca4 100755 --- a/bin/new-test-file +++ b/bin/new-test-file @@ -1,7 +1,9 @@ #!/usr/bin/env bash +# shellcheck disable=2034 version=0.0.1 +# shellcheck disable=1090 source "${ROOT:-$PWD}/.bpan/run-or-docker.bash" check() ( @@ -37,6 +39,7 @@ main() ( ) template() ( + # shellcheck disable=1039 cat <<... --- - name: diff --git a/bin/new-test-id b/bin/new-test-id index 419371ac..3b6ad39c 100755 --- a/bin/new-test-id +++ b/bin/new-test-id @@ -3,8 +3,7 @@ ( while true; do id=$( - cat /dev/urandom | - LC_ALL=C tr -cd A-HJ-NP-Z2-9 | + LC_ALL=C tr -cd A-HJ-NP-Z2-9 < /dev/urandom | fold -w4 | grep '[A-Z]' | grep '[0-9]' | diff --git a/bin/run-all-parsers b/bin/run-all-parsers index f67bc881..96e12c4e 100755 --- a/bin/run-all-parsers +++ b/bin/run-all-parsers @@ -8,6 +8,8 @@ # It is used to run every test in the suite against each YAML parser. # #------------------------------------------------------------------------------ +# shellcheck disable=2030 +# shellcheck disable=2031 set -e -u -o pipefail @@ -15,6 +17,7 @@ main() ( id=$ID tmp=/tmp/test/$id + # shellcheck disable=2086 set -- $RUNNERS run-all-parsers "$@" diff --git a/bin/suite-to-data b/bin/suite-to-data index 376373d8..837964a6 100755 --- a/bin/suite-to-data +++ b/bin/suite-to-data @@ -7,10 +7,12 @@ # #------------------------------------------------------------------------------ +# shellcheck disable=2034 version=0.0.8 RUN_OR_DOCKER_PULL=true +# shellcheck disable=1090 source "${ROOT:-$PWD}/.bpan/run-or-docker.bash" check() ( diff --git a/bin/tsv-to-new b/bin/tsv-to-new index bd87e611..0248b50c 100755 --- a/bin/tsv-to-new +++ b/bin/tsv-to-new @@ -54,12 +54,13 @@ for line in "${each[@]}"; do shift done - if [[ $group && $group == $_group ]]; then + if [[ $group && $group == "$_group" ]]; then more=1 else more='' id=$("$bin/new-test-id") - while [[ -f $dir/$id*.yaml ]]; do + # TODO + while [[ -f $dir/$id.yaml ]]; do id=$("$bin/new-test-id") done : $((i++))