Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shellcheck target and CI workflow #95

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
shell=bash

enable=quote-safe-variables

disable=1091,2030,2031,2034
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SHELL := bash
SHELL_FILES := $(shell file --mime-type bin/* | grep text/x-shellscript | cut -d: -f1)

export ROOT := $(shell pwd)

Expand Down Expand Up @@ -48,6 +49,9 @@ test:
make gh-pages
perlpunk marked this conversation as resolved.
Show resolved Hide resolved
make clean

style-check:
shellcheck $(SHELL_FILES)

add-new:
for f in new/*; do cp "$$f" "src/$${f#*-}"; done

Expand Down
3 changes: 3 additions & 0 deletions bin/new-test-file
Original file line number Diff line number Diff line change
@@ -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() (
Expand Down Expand Up @@ -37,6 +39,7 @@ main() (
)

template() (
# shellcheck disable=1039
cat <<...
---
- name: <test title>
Expand Down
3 changes: 1 addition & 2 deletions bin/new-test-id
Original file line number Diff line number Diff line change
Expand Up @@ -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]' |
Expand Down
3 changes: 3 additions & 0 deletions bin/run-all-parsers
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
# 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

main() (
id=$ID
tmp=/tmp/test/$id

# shellcheck disable=2086
set -- $RUNNERS

run-all-parsers "$@"
Expand Down
2 changes: 2 additions & 0 deletions bin/suite-to-data
Original file line number Diff line number Diff line change
Expand Up @@ -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() (
Expand Down
5 changes: 3 additions & 2 deletions bin/tsv-to-new
Original file line number Diff line number Diff line change
Expand Up @@ -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++))
Expand Down