wip #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: lint | |
# yamllint disable rule:truthy | |
on: | |
pull_request: | |
branches: ['*'] | |
push: | |
branches: ['*'] | |
tags: ['*'] | |
# yamllint enable rule:truthy | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- uses: asdf-vm/actions/install@v1 | |
with: | |
tool_versions: | | |
nim latest:1.6 | |
- name: Install shfmt | |
uses: mfinelli/setup-shfmt@v2 | |
- name: Install lintball | |
run: | | |
asdf local nim latest:1.6 | |
npm install -g lintball@1.6.0 | |
lintball install-tools --yes | |
- name: Check for linter issues | |
shell: bash | |
run: | | |
set -uexo pipefail | |
default_branch=devel | |
if [ "$GITHUB_REF" = "refs/heads/$default_branch" ]; then | |
# A push to the default branch. | |
# Check files which were changed in the most recent commit. | |
commitish="HEAD~1" | |
elif [ -n "$GITHUB_BASE_REF" ]; then | |
# A pull request. | |
# Check files which have changed between the merge base and the | |
# current commit. | |
commitish="$(git merge-base -a refs/remotes/origin/$GITHUB_BASE_REF $GITHUB_SHA)" | |
else | |
# A push to a non-default, non-PR branch. | |
# Check files which have changed between default branch and the current | |
# commit. | |
commitish="$(git merge-base -a refs/remotes/origin/${default_branch} $GITHUB_SHA)" | |
fi | |
# Get the list of changed files | |
files="$(git diff --name-only "$commitish")" | |
# Check if any lintball configuration was changed. If so, check all files. | |
status=0 | |
case "$files" in | |
*lintballrc.json* | *.yamllint.yml* | *lint.yml*) lintball check || status=$? ;; | |
*) lintball check --since "$commitish" || status=$? ;; | |
esac | |
if [ "$status" -gt 0 ]; then | |
echo | |
echo "The above issues were found by lintball." | |
echo "To detect and auto-fix issues before pushing, install lintball's git hooks." | |
echo "See https://github.com/elijahr/lintball" | |
echo | |
exit $status | |
fi |