Add linters to GitHub Actions workflow (#7535)

This commit is contained in:
Ed Reel
2022-10-23 20:10:51 -05:00
committed by GitHub
parent c29197445a
commit 1cfbd37b89

View File

@@ -1,6 +1,6 @@
---
name: Rubocop
on: # yamllint disable-line rule:truthy
name: Linters
on:
pull_request:
branches: [master]
jobs:
@@ -14,9 +14,10 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- name: Install yamllint
- name: Install linters
run: |
sudo apt install yamllint -y
gem install mdl yaml-lint
sudo apt install codespell shellcheck -y
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v33
@@ -26,16 +27,28 @@ jobs:
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
ext="${file##*.}"
type="$(file -b $file | cut -d' ' -f1)"
[[ "$type" == "Ruby" ]] && ext="rb"
case $type in
Bourne-Again)
ext="sh";;
HTML)
ext="md";;
Ruby)
ext="rb";;
esac
case $ext in
yml|yaml)
yamllint $file;;
md)
mdl $file;;
rb)
ruby=true
ruby -wcWlevel=2 $file;;
sh)
shellcheck $file;;
yml|yaml)
yaml-lint $file;;
*)
echo "Unable to check syntax of $file.";;
esac
codespell $file
done
echo "ruby=$ruby" >> $GITHUB_ENV
- name: Rubocop