mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
70 lines
1.8 KiB
YAML
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"
|