Files
chromebrew/.github/workflows/Linters.yml
Satadru Pramanik, DO, MPH, MEng 46f9929fd7 update linter config (#8289)
2023-05-22 11:44:18 -05:00

70 lines
1.8 KiB
YAML

---
name: Linters
on:
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install ruby
uses: ruby/setup-ruby@v1.150.0
with:
ruby-version: 3.2.2
- name: Install linters
run: |
gem install mdl yaml-lint
sudo apt install shellcheck -y
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
- name: Syntax check
run: |
ruby=
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
ext="${file##*.}"
if ! [[ "$ext" =~ ^(md|rb|sh|yml|yaml)$ ]]; then
type="$(file -b "$file" | cut -d' ' -f1)"
case $type in
Bourne-Again)
ext="sh"
;;
HTML)
ext="md"
;;
Ruby)
ext="rb"
;;
esac
fi
case $ext in
md)
mdl -c .mdlrc "$file"
;;
rb)
ruby=true
ruby -wcWlevel=2 "$file"
;;
sh)
shellcheck "$file"
;;
yml|yaml)
yaml-lint "$file"
;;
*)
echo "Unable to check syntax of $file."
;;
esac
done
echo "ruby=$ruby" >> $GITHUB_ENV
- name: Rubocop
if: env.ruby
uses: satmandu/Octocop@v0.0.3
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
rubocop_flags: "-c .rubocop.yml"