Skip to content

Further improve linting setup #2306

Further improve linting setup

Further improve linting setup #2306

Workflow file for this run

name: Linting
on:
push:
branches:
- '**'
pull_request:
branches:
- 'main' # Continuous Releases
jobs:
# RuboCop Linting
# Workflow adapted from Rails
# https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml
rubocop:
name: RuboCop
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
# If this action is not triggered from a PR, we use 'mampf-next' as default
# target branch to compare against. This might not cover all use cases.
# But in the end, one has to open a PR anyways and then the correct target
# branch is identified.
# TODO: rename to 'dev' when 'mampf-next' branch is renamed.
- name: Find target branch
run: |
echo "TARGET_BRANCH=${{ github.base_ref || 'mampf-next' }}" >> $GITHUB_ENV
- name: Fetch target branch (for later git diff)
run: |
echo "Fetching target branch: $TARGET_BRANCH" &&
git fetch origin $TARGET_BRANCH --depth 1
- name: Set up Ruby 3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.4
bundler-cache: true
# Scope Rubocop to changed files:
# https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
- name: Run RuboCop
run: |
git diff --diff-filter=d --name-only $TARGET_BRANCH... | grep '\.rb$' | xargs bundle exec rubocop --parallel
# 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