#!/usr/bin/env bash set -uo pipefail cd "$(dirname "$0")" export PATH="$PWD/../bin:$PATH" rm -rf recorded work; mkdir recorded actionlint -version | head -1 > recorded/00-version.txt shellcheck --version | sed -n 2p >> recorded/00-version.txt (cd bad && actionlint -no-color .github/workflows/ci.yml > ../recorded/01-bad.txt; echo "exit code: $?" >> ../recorded/01-bad.txt) (cd good && actionlint -no-color .github/workflows/ci.yml > ../recorded/02-good.txt; echo "exit code: $?" >> ../recorded/02-good.txt) (cd custom && actionlint -no-color .github/workflows/ci.yml > ../recorded/03-custom-label-unconfigured.txt 2>&1; echo "exit code: $?" >> ../recorded/03-custom-label-unconfigured.txt) # NOTE: actionlint auto-discovers .github/actionlint.yaml only inside a git repo mkdir work && cp -r custom work/ && (cd work/custom && git init -q . && actionlint -no-color > ../../recorded/04-custom-label-configured.txt 2>&1; echo "exit code: $?" >> ../../recorded/04-custom-label-configured.txt) # pre-commit hook test rm -rf work/repo && mkdir -p work/repo && cd work/repo && git init -q . && git config user.email t@example.com && git config user.name t mkdir -p .github/workflows && cp ../../bad/.github/workflows/ci.yml .github/workflows/ci.yml cp ../../hook-pre-commit.sh .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit git add . && git commit -m "add ci" > ../../recorded/05-commit-blocked.txt 2>&1; echo "git commit exit code: $?" >> ../../recorded/05-commit-blocked.txt cp ../../good/.github/workflows/ci.yml .github/workflows/ci.yml && git add . && git commit -m "add ci" > ../../recorded/06-commit-ok.txt 2>&1; echo "git commit exit code: $?" >> ../../recorded/06-commit-ok.txt