Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip back pipeline to Rubocop linting only #562

Merged
merged 21 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 35 additions & 77 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,45 @@
on: [push]
name: Linting

# Trigger each time HEAD branch is updated in a pull request
# see https://github.com/orgs/community/discussions/26366
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

jobs:

# Resources:
# number [1] being most important
# [1] https://github.com/actions/checkout/issues/520#issuecomment-1167205721
# [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
runs-on: ubuntu-latest
name: A job to check rubocop linter errors
steps:
- uses: actions/checkout@v2
- name: 'Checkout PR branch (with test merge-commit)'
uses: actions/checkout@v4
with:
fetch-depth: 2 # to also fetch parent of PR

# Adapted from this great comment [1]. Git diff adapted from [2].
# "|| test $? = 1;" is used to ignore the exit code of grep when no files
# are found matching the pattern. For the "three dots" ... syntax, see [3].
- name: Get changed files
run: |
files=$(git diff --name-only --diff-filter=ACMR -r HEAD^1...HEAD | grep '\.rb$' || test $? = 1;)
printf "🎴 Changed ruby files: \n$files"
echo "CHANGED_FILES=$(echo ${files} | xargs)" >> $GITHUB_ENV

- name: Set up Ruby 3
if: env.CHANGED_FILES != ''
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.4
- name: Install gems # usual step to install the gems.
bundler-cache: true

- name: Run RuboCop
if: env.CHANGED_FILES != ''
run: |
bin/bundle config path vendor/bundle
bin/bundle config set without 'default doc job cable storage ujs test db'
bin/bundle install --jobs 4 --retry 3
- name: Linter count
id: hello
uses: henrixapp/[email protected]
with:
name: Rubocop
command: bin/bundle exec rubocop app config lib spec
total_regexp: \d+ offenses detected
errors_regexp: \d+ offenses detected
warnings_regexp: \d+ offenses detected
compare_branch: mampf-next
mode: changed
include: .rb
eslint:
runs-on: ubuntu-latest
name: A job to check eslint linter errors
steps:
- uses: actions/checkout@v2
- name: Linter count
id: hello
uses: henrixapp/[email protected]
with:
name: EsLint
command: npx eslint
total_regexp: \d+ problems
errors_regexp: \d+ errors
warnings_regexp: \d+ warnings
compare_branch: mampf-next
mode: changed
include: .js
coffee:
runs-on: ubuntu-latest
name: A job to check coffee linter errors
steps:
- uses: actions/checkout@v2
- name: Linter count
id: hello
uses: henrixapp/[email protected]
with:
name: Coffee
command: npx coffeelint
total_regexp: \d+ errors
errors_regexp: \d+ errors
warnings_regexp: \d+ warnings
compare_branch: mampf-next
mode: changed
include: .coffee
# erblint:
# runs-on: ubuntu-latest
# name: A job to check erblint linter errors
# steps:
# - uses: actions/checkout@v2
# - name: Set up Ruby 2.7
# uses: ruby/setup-ruby@v1
# with:
# ruby-version: 2.7
# - name: Install gems # usual step to install the gems.
# run: |
# bin/bundle config path vendor/bundle
# bin/bundle config set without 'default doc job cable storage ujs test db'
# bin/bundle install --jobs 4 --retry 3
# - name: Linter count
# id: hello
# uses: henrixapp/[email protected]
# with:
# name: Erblint
# command: bin/bundle exec erblint .
# total_regexp: \d+ error(s)
# errors_regexp: \d+ error(s)
# warnings_regexp: \d+ error(s)
# compare_branch: mampf-next
echo "🚨 Running RuboCop version: $(bundle info rubocop | head -1)"
bundle exec rubocop --format github --fail-level 'convention' --force-exclusion -- $CHANGED_FILES
84 changes: 0 additions & 84 deletions .github/workflows/tests.yml

This file was deleted.