diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..52fb5cf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: Tests + +# Controls when the action will run. + +on: [push, pull_request, workflow_dispatch] + +jobs: + changelog: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Check that PR is mentioned in Changelog + run: | + if ! ./.github/workflows/check_pr_label.sh "${{github.event.pull_request.number}}" "no changelog"; then + grep "#${{github.event.pull_request.number}}" docs/CHANGELOG.md + fi + if: ${{github.event.pull_request}} + shellcheck: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Run shellcheck + run: | + sudo apt-get update -y + sudo apt-get install shellcheck + ./shellcheck.sh + + linux: + strategy: + matrix: + os: ['ubuntu-20.04', 'ubuntu-22.04'] + env_vars: + - '' + # allow for some parallelity without GNU parallel, since it is not installed by default + - 'BATS_NO_PARALLELIZE_ACROSS_FILES=1 BATS_NUMBER_OF_PARALLEL_JOBS=2' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Run test on OS ${{ matrix.os }} + shell: 'script -q -e -c "bash {0}"' # work around tty issues + env: + TERM: linux # fix tput for tty issue work around + run: | + bash --version + bash -c "time ${{ matrix.env_vars }} bin/bats --print-output-on-failure --formatter tap test" + + bash-version: + strategy: + matrix: + version: ['3.2', '4.0', '4.1', '4.2', '4.3', '4.4', '4', '5.0', '5.1', '5', 'latest'] + env_vars: + - '' + # also test running (recursively!) in parallel + - '-e BATS_NUMBER_OF_PARALLEL_JOBS=2' diff --git a/shellcheck.sh b/shellcheck.sh new file mode 100644 index 0000000..9cb7083 --- /dev/null +++ b/shellcheck.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +targets=() +while IFS= read -r -d $'\0'; do + targets+=("$REPLY") +done < <( + find . -type f \( -name \*.bash -o -name \*.sh \) -print0; \ + find . -type f -name '*.bats' -not -name '*_no_shellcheck*' -print0; \ + find libfoundryup -type f -print0; + find bin -type f -print0) + +if [[ $1 == --list ]]; then + printf "%s\n" "${targets[@]}" + exit 0 +fi + +LC_ALL=C.UTF-8 shellcheck "${targets[@]}" + +exit $?