-
-
Notifications
You must be signed in to change notification settings - Fork 2
222 lines (186 loc) · 6.19 KB
/
reviewdog.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Reviewdog
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
ELIXIR_VERSION: '1.16.0'
OTP_VERSION: '26.2.1'
permissions:
contents: read
pull-requests: write
jobs:
opts:
name: Reviewdog options
runs-on: ubuntu-latest
outputs:
reporter: ${{ steps.reporter.outputs.value }}
filter-mode: ${{ steps.filter-mode.outputs.value }}
steps:
- uses: haya14busa/action-cond@v1
id: reporter
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "github-pr-review"
if_false: "github-check"
- uses: haya14busa/action-cond@v1
id: filter-mode
with:
cond: ${{ github.event_name == 'pull_request' }}
if_true: "file"
if_false: "nofilter"
actionlint:
name: Lint workflows
runs-on: ubuntu-latest
needs: opts
steps:
- uses: actions/checkout@v4
- name: Run actionlint with reviewdog
uses: reviewdog/action-actionlint@v1
with:
actionlint_flags: -config-file .github/actionlint.yaml
level: warning
reporter: ${{ needs.opts.outputs.reporter }}
filter_mode: ${{ needs.opts.outputs.filter-mode }}
fail_on_error: true
hadolint:
name: Lint Dockerfile
runs-on: ubuntu-latest
needs: opts
steps:
- uses: actions/checkout@v4
- name: Run hadolint with reviewdog
uses: reviewdog/action-hadolint@v1
with:
level: warning
reporter: ${{ needs.opts.outputs.reporter }}
filter_mode: ${{ needs.opts.outputs.filter-mode }}
fail_on_error: true
mix-deps:
name: Install dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-elixir-lint-deps-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-lint-deps-
- run: mix deps.get --only test
- name: Restore build cache
uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-lint-build-${{ hashFiles('**/mix.lock') }}-${{ hashFiles( '**/lib/**/*.{ex,eex}', '**/config/*.exs', '**/mix.exs' ) }}
restore-keys: |
${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-lint-build-${{ hashFiles('**/mix.lock') }}-
${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-lint-build-
- run: mix deps.compile
env:
MIX_ENV: test
mix-format:
name: Formatting
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: opts
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
version-type: strict
- run: mix format
- name: Reviewdog suggester / mix-format
uses: reviewdog/action-suggester@v1
with:
tool_name: mix-format
filter_mode: ${{ needs.opts.outputs.filter-mode }}
fail_on_error: true
credo:
name: Code analysis
runs-on: ubuntu-latest
needs: [mix-deps, opts]
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-elixir-lint-deps-${{ hashFiles('**/mix.lock') }}
- name: Restore build cache
uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-lint-build-${{ hashFiles('**/mix.lock') }}-${{ hashFiles( '**/lib/**/*.{ex,eex}', '**/config/*.exs', '**/mix.exs' ) }}
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run credo with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
reviewdog \
-runners=credo \
-reporter=${{ needs.opts.outputs.reporter }} \
-filter-mode=${{ needs.opts.outputs.filter-mode }} \
-fail-on-error
dialyzer:
name: Type checking
runs-on: ubuntu-latest
needs: [mix-deps, opts]
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
version-type: strict
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-elixir-lint-deps-${{ hashFiles('**/mix.lock') }}
- name: Restore build cache
uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-lint-build-${{ hashFiles('**/mix.lock') }}-${{ hashFiles( '**/lib/**/*.{ex,eex}', '**/config/*.exs', '**/mix.exs' ) }}
- name: Restore PLT cache
uses: actions/cache@v4
id: plt_cache
with:
path: priv/plts
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-dialyzer-plt-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}-erlang-${{ env.OTP_VERSION }}-dialyzer-plt-
- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run dialyzer with reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
reviewdog \
-runners=dialyzer \
-reporter=${{ needs.opts.outputs.reporter }} \
-filter-mode=${{ needs.opts.outputs.filter-mode }} \
-fail-on-error