Skip to content

Commit

Permalink
Add ESLint to CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 6, 2023
1 parent 547d0ac commit aa656fa
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
# [2] https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
# [3] https://community.atlassian.com/t5/Bitbucket-questions/Git-diff-show-different-files-than-PR-Pull-Request/qaq-p/2331786
rubocop:
name: RuboCop
name: RuboCop (Ruby)
runs-on: ubuntu-latest
steps:
- name: 'Checkout PR branch (with test merge-commit)'
Expand Down Expand Up @@ -43,3 +43,31 @@ jobs:
run: |
echo "🚨 Running RuboCop version: $(bundle info rubocop | head -1)"
bundle exec rubocop --format github --fail-level 'convention' --force-exclusion -- $CHANGED_FILES
eslint:
name: ESLint (JS)
runs-on: ubuntu-latest
steps:
- name: 'Checkout PR branch'
uses: actions/checkout@v4

# see notes above (in rubocop job)
- name: Get changed files
run: |
files=$(git diff --name-only --diff-filter=ACMR -r HEAD^1...HEAD | grep -e '\.js$' -e '\.js.erb$'|| test $? = 1;)
printf "🎴 Changed js files: \n$files"
echo "CHANGED_FILES=$(echo ${files} | xargs)" >> $GITHUB_ENV
- name: 'Setup Node.js'
if: env.CHANGED_FILES != ''
uses: actions/setup-node@v4
with:
node-version: '20' # End of Life (EOL): April 2026

- name: 'Install dependencies'
if: env.CHANGED_FILES != ''
run: yarn install

- name: 'Run ESLint'
if: env.CHANGED_FILES != ''
run: yarn run eslint --ignore-path .gitignore --max-warnings 0 -- $CHANGED_FILES

0 comments on commit aa656fa

Please sign in to comment.