-
Notifications
You must be signed in to change notification settings - Fork 48
191 lines (152 loc) · 4.8 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
name: CI
on:
push:
branches:
- master
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:
env:
# Disable incremental compilation. CI builds are often closer to from-scratch builds, as changes
# are typically bigger than from a local edit-compile cycle.
# Incremental compilation also significantly increases the amount of IO and the size of ./target
# folder, which makes caching less effective.
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
RUST_BACKTRACE: short
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# Cache should never takes more than a few seconds to get downloaded.
# If it does, let’s just rebuild from scratch instead of hanging "forever".
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
# Disabling debug info so compilation is faster and ./target folder is smaller.
CARGO_PROFILE_DEV_DEBUG: 0
jobs:
formatting:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo xtask check fmt -v
typos:
name: Check typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: typos (prepare)
run: cargo xtask check install -v
- name: typos (check)
run: cargo xtask check typos -v
checks:
name: Checks [${{ matrix.os }}]
runs-on: ${{ matrix.runner }}
needs: formatting
strategy:
fail-fast: false
matrix:
os: [ windows, linux, macos ]
include:
- os: windows
runner: windows-latest
- os: linux
runner: ubuntu-latest
- os: macos
runner: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install devel packages
if: runner.os == 'Linux'
run: |
sudo apt-get -y install libasound2-dev
- name: Install NASM
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install nasm
$Env:PATH += ";$Env:ProgramFiles\NASM"
echo "PATH=$Env:PATH" >> $Env:GITHUB_ENV
- name: Rust cache
uses: Swatinem/[email protected]
- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
# Compilation is separated from execution so we know exactly the time for each step.
- name: Tests (compile)
run: cargo xtask check tests --no-run -v
- name: Tests (run)
run: cargo xtask check tests -v
- name: Lints
run: cargo xtask check lints -v
- name: WASM (prepare)
run: cargo xtask wasm install -v
- name: WASM (check)
run: cargo xtask wasm check -v
- name: Lock files
run: cargo xtask check locks -v
fuzz:
name: Fuzzing
runs-on: ubuntu-latest
needs: formatting
steps:
- uses: actions/checkout@v4
- name: Rust cache
uses: Swatinem/[email protected]
with:
workspaces: fuzz -> target
- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare
run: cargo xtask fuzz install -v
# Simply run all fuzz targets for a few seconds, just checking there is nothing obviously wrong at a quick glance
- name: Fuzz
run: cargo xtask fuzz run -v
- name: Lock files
run: cargo xtask check locks -v
web:
name: Web Client
runs-on: ubuntu-latest
needs: formatting
steps:
- uses: actions/checkout@v4
- name: Rust cache
uses: Swatinem/[email protected]
- name: Binary cache
uses: actions/cache@v4
with:
path: ./.cargo/local_root/bin
key: ${{ runner.os }}-bin-${{ github.job }}-${{ hashFiles('xtask/src/bin_version.rs') }}
- name: Prepare
run: cargo xtask web install -v
- name: Check
run: cargo xtask web check -v
- name: Lock files
run: cargo xtask check locks -v
success:
name: Success
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- formatting
- typos
- checks
- fuzz
- web
steps:
- name: Check success
shell: pwsh
run: |
$results = '${{ toJSON(needs.*.result) }}' | ConvertFrom-Json
$succeeded = $($results | Where { $_ -Ne "success" }).Count -Eq 0
exit $(if ($succeeded) { 0 } else { 1 })