-
Notifications
You must be signed in to change notification settings - Fork 1
361 lines (339 loc) · 11.1 KB
/
ci.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: CI
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
skip_check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true"
commitlint:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install NodeJS
uses: actions/setup-node@v4
with:
cache: "npm"
- name: Install commitlint
run: |
npm install conventional-changelog-conventionalcommits
npm install commitlint@latest
- name: Versions
run: |
git --version
node --version
npm --version
npx commitlint --version
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --from HEAD~1 --to HEAD --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
- name: README IF FAILED
if: failure()
run: echo 'Your commit message(s) does not conform to convention. See https://github.com/smve-rs/smve/blob/master/CONTRIBUTING.md#commits for more information.'
clippy_skip_check:
needs: commitlint
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["**/Cargo.lock", "**/Cargo.toml", "**/*.rs"]'
clippy:
needs: clippy_skip_check
if: needs.clippy_skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-clippy-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-rust-
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo clippy --workspace -- -Dwarnings
- name: README IF FAILED
if: failure()
run: echo "Please fix clippy's suggestions with cargo clippy --workspace --fix"
docs_skip_check:
needs: commitlint
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["**/*.rs"]'
docs:
needs: docs_skip_check
if: needs.docs_skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-docs-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-rust-
- name: Cargo doc
run: cargo doc --no-deps
- name: Upload docs
uses: actions/[email protected]
with:
name: Docs
path: target/doc/**/*
- name: README IF FAILED
if: failure()
run: echo 'Docs failed to build. Please fix the errors.'
test_skip_check:
needs: commitlint
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["**/Cargo.lock", "**/Cargo.toml", "**/*.rs"]'
test:
needs: test_skip_check
if: needs.test_skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-test-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-rust-
- uses: dtolnay/rust-toolchain@nightly
- run: cargo t --workspace
# build:
# needs: clippy
# strategy:
# fail-fast: false
# matrix:
# os: ["windows", "macos", "ubuntu"]
# configuration: ["debug", "release"]
# runs-on: ${{ matrix.os }}-latest
# steps:
# - uses: actions/cache@v4
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry/index/
# ~/.cargo/registry/cache/
# ~/.cargo/git/db/
# target/
# key: ${{ runner.os }}-rust-build-${{ hashFiles('**/Cargo.toml') }}
# restore-keys: ${{ runner.os }}-rust-
# - uses: dtolnay/rust-toolchain@nightly
# - name: Install LLD on Windows
# if: matrix.os == 'windows'
# run: |
# cargo install -f cargo-binutils
# rustup component add llvm-tools-preview
# - name: Install LLD on macOS
# if: matrix.os == 'macos'
# run: brew install llvm
# - name: Install LLD on Ubuntu
# if: matrix.os == 'ubuntu'
# run: sudo apt-get install lld
# - uses: actions/checkout@v4
# - name: Cargo build
# run: cargo build --verbose ${{ matrix.configuration == 'release' && '--release' || '' }}
# - name: Upload binary
# uses: actions/[email protected]
# with:
# name: smve-${{ matrix.os }}-${{ matrix.configuration }}
# path: target/${{ matrix.configuration }}/smve${{ matrix.os == 'windows' && '.exe' || '' }}
# - name: README IF FAILED
# if: failure()
# run: echo 'Build failed for ${{ matrix.os }}-${{ matrix.configuration }}. Please fix the compile errors.'
format_skip_check:
needs: commitlint
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["**/*.rs"]'
format:
needs: format_skip_check
permissions:
contents: write
pull-requests: write
if: needs.format_skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-format-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-rust-
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: echo "${HOME}/.cargo/bin" >> $GITHUB_PATH
- name: Rust format on commit
if: github.event_name == 'push'
uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
style: auto format
Automated commit from Github Actions
- name: Rust format on pull request
if: github.event_name == 'pull_request'
uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
mode: review
toml_skip_check:
needs: commitlint
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths: '["**.toml"]'
toml:
needs: toml_skip_check
if: needs.toml_skip_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install taplo
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz \
| gzip -d - \
| install -m 755 /dev/stdin /usr/local/bin/taplo
- name: Run Taplo
id: taplo
run: taplo fmt --check --diff
- name: Taplo info
if: failure()
run: |
echo 'To fix toml fmt, please run taplo fmt'
echo 'Or if you use VSCode, use the Even Better Toml extension'
update_line_of_code:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Download cloc
run: |
sudo apt-get update -y && sudo apt-get install -y cloc
- name: Count lines of code
run: |
echo "CODE_LINES=$( ./scripts/cloc.sh --loc)" >> $GITHUB_ENV
- name: Create Lines-of-Code-Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.CI_GIST_TOKEN }}
gistID: a488eb0391a5fc6a2918d13184cd0a26
filename: smve_loc.json
label: Lines of Code
message: ${{ env.CODE_LINES }}
logoColor: cdd6f4
labelColor: 313244
color: 94e2d5
namedLogo: googledocs
style: for-the-badge
typos:
needs: commitlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/[email protected]
- name: Typos info
if: failure()
run: |
echo 'To fix typos, please run `typos -w`'
echo 'To check for a diff, run `typos`'
echo 'You can find typos here: https://crates.io/crates/typos'
echo 'if you use VSCode, you can also install `Typos Spell Checker'
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'
# markdown_lint_skip_check:
# needs: commitlint
# runs-on: ubuntu-latest
# outputs:
# should_skip: ${{ steps.skip_check.outputs.should_skip }}
# steps:
# - id: skip_check
# uses: fkirc/skip-duplicate-actions@v5
# with:
# paths: '["**.md"]'
#
# markdown_lint:
# needs: markdown_lint_skip_check
# if: needs.markdown_lint_skip_check.outputs.should_skip != 'true'
# runs-on: ubuntu-latest
#
# permissions:
# contents: read
# packages: read
# # To report GitHub Actions status checks
# statuses: write
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# # super-linter needs the full git history to get the
# # list of files that changed across commits
# fetch-depth: 0
#
# - name: Super-linter
# uses: super-linter/super-linter/[email protected] # x-release-please-version
# env:
# MULTI_STATUS: false
# VALIDATE_MARKDOWN: true
#
# - name: README IF FAILED
# if: failure()
# run: echo 'Please fix the formatting errors in markdown files as suggested.'