-
Notifications
You must be signed in to change notification settings - Fork 10
103 lines (95 loc) · 3.1 KB
/
linter.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Linting
on:
push:
branches:
- '**'
pull_request:
branches:
- 'main' # Continuous Releases
jobs:
# 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
with:
fetch-depth: 2 # to also fetch parent commit for git diff
- name: Set up Ruby 3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.4
bundler-cache: true
# Deleted files are excluded
# adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721
- name: Get changed ruby files (git diff)
run: |
changedFiles=$(git diff-tree --name-only --diff-filter=d -r HEAD^1 HEAD | grep '\.rb$')
echo "Changed ruby files: $changedFiles"
echo "CHANGED_FILES=$changedFiles" >> $GITHUB_ENV
# Scope Rubocop to changed files:
# https://robertfaldo.medium.com/commands-to-run-rubocop-and-specs-you-changed-in-your-branch-e6d2f2e4110b
# Exclude deleted files
- name: Run RuboCop
run: |
$CHANGED_FILES | 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