-
Notifications
You must be signed in to change notification settings - Fork 248
366 lines (332 loc) · 12.5 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
362
363
364
365
366
# Main CI workflow to validate PRs and branches are correctly formatted
# and pass tests.
#
# CI workflow was based on a lot of work from other people:
# - https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
# - https://www.reillywood.com/blog/rust-faster-ci/
# - https://matklad.github.io/2021/09/04/fast-rust-builds.html
#
# Supported platforms run the following tasks:
# - cargo fmt
# - cargo test (built/test in separate steps)
# - cargo clippy (apparently faster to do it after the build/test)
#
# Unsupported platforms run the following tasks:
# - cargo build
#
# Note that not all platforms are tested using this CI action! There are some
# tested by Cirrus CI due to (free) platform limitations on GitHub. Currently,
# this is just macOS M1 and FreeBSD.
name: ci
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'ClementTsang/bottom' }}
jobs:
# Check if things should be skipped.
pre-job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- name: Check if this action should be skipped
id: skip_check
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
with:
skip_after_successful_duplicate: "true"
paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml", "Cross.toml"]'
do_not_skip: '["workflow_dispatch", "push"]'
# Runs rustfmt + tests + clippy on the main supported platforms.
#
# TODO: In the future, when ARM runners are available on github, switch ARM targets off of cross.
supported:
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
runs-on: ${{ matrix.info.os }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
- {
os: "ubuntu-latest",
target: "x86_64-unknown-linux-gnu",
cross: false,
}
- {
os: "ubuntu-latest",
target: "aarch64-unknown-linux-gnu",
cross: true,
}
- { os: "macos-12", target: "x86_64-apple-darwin", cross: false }
- { os: "macos-14", target: "aarch64-apple-darwin", cross: false }
- {
os: "windows-2019",
target: "x86_64-pc-windows-msvc",
cross: false,
}
features: ["--all-features", "--no-default-features"]
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
with:
toolchain: stable
components: rustfmt, clippy
target: ${{ matrix.info.target }}
- name: Enable Rust cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # 2.7.3
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with:
key: ${{ matrix.info.target }}
cache-all-crates: true
- name: Check cargo fmt
run: cargo fmt --all -- --check
- name: Build tests
uses: ClementTsang/[email protected]
with:
command: test
args: --no-run --locked ${{ matrix.features }} --target=${{ matrix.info.target }}
use-cross: ${{ matrix.info.cross }}
cross-version: 0.2.5
env:
RUST_BACKTRACE: full
- name: Run tests
uses: ClementTsang/[email protected]
with:
command: test
args: --no-fail-fast ${{ matrix.features }} --target=${{ matrix.info.target }} -- --nocapture --quiet
use-cross: ${{ matrix.info.cross }}
cross-version: 0.2.5
env:
RUST_BACKTRACE: full
- name: Run clippy
uses: ClementTsang/[email protected]
with:
command: clippy
args: ${{ matrix.features }} --all-targets --workspace --target=${{ matrix.info.target }} -- -D warnings
use-cross: ${{ matrix.info.cross }}
cross-version: 0.2.5
env:
RUST_BACKTRACE: full
# Try running cargo build on all other platforms.
# TODO: Maybe some of these should be allowed to fail? If so, I guess we can add back the "unofficial" MSRV,
# I would also put android there.
other-check:
needs: pre-job
runs-on: ${{ matrix.info.os }}
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
# x86 or x86-64
- {
os: "ubuntu-latest",
target: "i686-unknown-linux-gnu",
cross: true,
}
- {
os: "ubuntu-latest",
target: "x86_64-unknown-linux-musl",
cross: false,
}
- {
os: "ubuntu-latest",
target: "i686-unknown-linux-musl",
cross: true,
}
- { os: "windows-2019", target: "i686-pc-windows-msvc", cross: false }
- {
os: "windows-2019",
target: "x86_64-pc-windows-gnu",
cross: false,
}
# Beta
- {
os: "ubuntu-latest",
target: "x86_64-unknown-linux-gnu",
cross: false,
rust: "beta",
}
- {
os: "macos-12",
target: "x86_64-apple-darwin",
cross: false,
rust: "beta",
}
- {
os: "windows-2019",
target: "x86_64-pc-windows-msvc",
cross: false,
rust: "beta",
}
# armv7
- {
os: "ubuntu-latest",
target: "armv7-unknown-linux-gnueabihf",
cross: true,
}
# armv6
- {
os: "ubuntu-latest",
target: "arm-unknown-linux-gnueabihf",
cross: true,
}
# PowerPC 64 LE
- {
os: "ubuntu-latest",
target: "powerpc64le-unknown-linux-gnu",
cross: true,
}
# Risc-V 64gc
# Note: seems like this breaks with tests?
- {
os: "ubuntu-latest",
target: "riscv64gc-unknown-linux-gnu",
cross: true,
}
# Android ARM64
- {
os: "ubuntu-latest",
target: "aarch64-linux-android",
cross: true,
cross-version: "git:cabfc3b02d1edec03869fabdabf6a7f8b0519160",
no-default-features: true,
no-clippy: true,
}
# Seems like cross' FreeBSD image is a bit broken? I
# get build errors, may be related to this issue:
# https://github.com/cross-rs/cross/issues/1291
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
with:
toolchain: ${{ matrix.info.rust || 'stable' }}
target: ${{ matrix.info.target }}
components: "clippy"
- name: Enable Rust cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # 2.7.3
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with:
key: ${{ matrix.info.target }}
cache-all-crates: true
# - name: Test (default features)
# uses: ClementTsang/[email protected]
# if: ${{ matrix.info.no-default-features != true }}
# with:
# command: test
# args: --all-targets --workspace --target=${{ matrix.info.target }} --locked
# use-cross: ${{ matrix.info.cross }}
# cross-version: ${{ matrix.info.cross-version || '0.2.5' }}
# - name: Test (no features enabled)
# uses: ClementTsang/[email protected]
# if: ${{ matrix.info.no-default-features == true }}
# with:
# command: test
# args: --all-targets --workspace --target=${{ matrix.info.target }} --locked --no-default-features
# use-cross: ${{ matrix.info.cross }}
# cross-version: ${{ matrix.info.cross-version || '0.2.5' }}
- name: Check (default features)
uses: ClementTsang/[email protected]
if: ${{ matrix.info.no-default-features != true }}
with:
command: clippy
args: --all-targets --workspace --target=${{ matrix.info.target }} --locked
use-cross: ${{ matrix.info.cross }}
cross-version: ${{ matrix.info.cross-version || '0.2.5' }}
- name: Check (no features enabled)
uses: ClementTsang/[email protected]
if: ${{ matrix.info.no-default-features == true }}
with:
command: clippy
args: --all-targets --workspace --target=${{ matrix.info.target }} --locked --no-default-features
use-cross: ${{ matrix.info.cross }}
cross-version: ${{ matrix.info.cross-version || '0.2.5' }}
vm-check:
name: "Test using VMs"
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
runs-on: "ubuntu-latest"
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
info:
- {
type: "freebsd",
os_release: "14.1",
target: "x86_64-unknown-freebsd",
}
- {
type: "freebsd",
os_release: "13.3",
target: "x86_64-unknown-freebsd",
}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
with:
toolchain: ${{ matrix.info.rust || 'stable' }}
target: ${{ matrix.info.target }}
- name: Enable Rust cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # 2.7.3
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
with:
key: ${{ matrix.info.target }}-${{ matrix.info.os_release }}
cache-all-crates: true
- name: Test FreeBSD
if: ${{ matrix.info.type == 'freebsd' }}
uses: vmactions/[email protected]
with:
release: "${{ matrix.info.os_release }}"
envs: "CARGO_INCREMENTAL CARGO_PROFILE_DEV_DEBUG CARGO_HUSKY_DONT_INSTALL_HOOKS"
usesh: true
prepare: |
pkg install -y curl bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs --output rustup.sh
sh rustup.sh --default-toolchain stable -y
run: |
. "$HOME/.cargo/env"
cargo clippy --all-targets --workspace -- -D warnings
completion:
name: "CI Pass Check"
needs: [supported, other-check, vm-check]
if: ${{ needs.supported.result != 'skipped' && needs.other-check.result != 'skipped' && needs.vm-check.result != 'skipped' }}
runs-on: "ubuntu-latest"
steps:
- name: CI Passed
if: ${{ needs.supported.result == 'success' && needs.other-check.result == 'success' && needs.vm-check.result == 'success' }}
run: |
echo "CI workflow completed successfully.";
- name: CI Failed
if: ${{ needs.supported.result == 'failure' && needs.other-check.result == 'failure' && needs.vm-check.result == 'failure' }}
run: |
echo "CI workflow failed.";
exit 1;
- name: CI Cancelled
if: ${{ needs.supported.result == 'cancelled' && needs.other-check.result == 'cancelled' && needs.vm-check.result == 'cancelled' }}
run: |
echo "CI workflow was cancelled.";
exit 1;