-
-
Notifications
You must be signed in to change notification settings - Fork 28
246 lines (204 loc) · 8.12 KB
/
ci.yaml
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
name: ci
on:
push:
branches:
- automation/brawl/try/*
- automation/brawl/merge/*
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
RUST_TOOLCHAIN: nightly
# By default, when a action is run against a PR it will use a merge commit from the target branch & the PR branch. We want to use just the PR branch.
# So this changes the SHA to the PR branch SHA or falls back to the current SHA (if its not a PR)
# https://github.com/actions/checkout/issues/426
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
jobs:
clippy:
name: Clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- name: Setup nasm
run: |
sudo apt-get install nasm
- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: clippy
- uses: Swatinem/rust-cache@v2
id: cache-rust
with:
prefix-key: "v0-rust-${{ steps.setup-rust.outputs.cachekey }}"
shared-key: clippy
- name: Make sure code is linted
run: cargo +${{ env.RUST_TOOLCHAIN }} clippy
fmt:
name: Fmt
runs-on: ubuntu-24.04
permissions:
checks: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Make sure code is formatted
run: cargo +${{ env.RUST_TOOLCHAIN }} fmt --check
hakari:
name: Hakari
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-hakari
- name: Make sure Hakari is up-to-date
run: |
set -xeo pipefail
cargo +${{ env.RUST_TOOLCHAIN }} hakari manage-deps --dry-run
cargo +${{ env.RUST_TOOLCHAIN }} hakari generate --diff
cargo +${{ env.RUST_TOOLCHAIN }} hakari verify
test:
name: Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- name: Setup nasm
run: |
sudo apt-get install nasm
- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: llvm-tools-preview
- name: Install ffmpeg
run: |
set -xeo pipefail
curl -L https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-7.1-linux-clang-default.tar.xz/download -o ffmpeg.tar.xz
tar -xvf ffmpeg.tar.xz
sudo mv ffmpeg-7.1-linux-clang-default/include/* /usr/include
sudo mv ffmpeg-7.1-linux-clang-default/lib/amd64/* /usr/local/lib
sudo mv ffmpeg-7.1-linux-clang-default/bin/amd64/* /usr/local/bin
sudo rm -rf ffmpeg-7.1-linux-clang-default
sudo rm -rf ffmpeg.tar.xz
sudo ldconfig
- name: Install ffmpeg dependencies
run: |
sudo apt-get install -y --no-install-recommends libdrm2 libxcb1 libasound2t64 libxv1 libc++1 libvdpau1 libva2
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-${{ steps.setup-rust.outputs.cachekey }}"
shared-key: test
- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov
# Note; we don't run the powerset here because it's very slow on CI
# Perhaps we should consider it at some point.
#
# Coverage for doctests is currently broken in llvm-cov.
# Once it fully works we can add the `--doctests` flag to the test and report command again.
- name: Run tests
run: |
cargo +${{ env.RUST_TOOLCHAIN }} llvm-cov nextest --no-fail-fast --all-features --profile ci --no-report
cargo +${{ env.RUST_TOOLCHAIN }} llvm-cov test --all-features --doc --no-report
cargo +${{ env.RUST_TOOLCHAIN }} llvm-cov report --lcov --output-path ./lcov.info
- name: Codecov Override
if: ${{ startsWith(github.ref, 'refs/heads/automation/brawl/try/') }}
run: |
PR_NUMBER=$(echo ${{ github.ref }} | sed -n 's/^refs\/heads\/automation\/brawl\/try\/\([0-9]*\)$/\1/p')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
RUN_COMMIT_SHA=$(git log -1 --pretty=format:%H)
echo "RUN_COMMIT_SHA=$RUN_COMMIT_SHA" >> $GITHUB_ENV
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
override_pr: ${{ env.PR_NUMBER || github.event.pull_request.number || '' }}
override_commit: ${{ env.RUN_COMMIT_SHA || env.SHA }}
verbose: true
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
files: ./target/nextest/ci/junit.xml
override_pr: ${{ env.PR_NUMBER || github.event.pull_request.number || '' }}
override_commit: ${{ env.RUN_COMMIT_SHA || env.SHA }}
token: ${{ secrets.CODECOV_TOKEN }}
docs:
name: Docs
runs-on: ubuntu-24.04
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SHA }}
- name: Setup nasm
run: |
sudo apt-get install nasm
- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rust-docs
- uses: Swatinem/rust-cache@v2
id: cache-rust
with:
prefix-key: "v0-rust-${{ steps.setup-rust.outputs.cachekey }}"
shared-key: docs
- name: Build docs
run: |
RUSTDOCFLAGS="-D warnings --cfg docsrs --enable-index-page -Zunstable-options" cargo +${{ env.RUST_TOOLCHAIN }} doc --no-deps --all-features
- name: Get PR Number
if: ${{ startsWith(github.ref, 'refs/heads/automation/brawl/try/') }}
run: |
PR_NUMBER=$(echo ${{ github.ref }} | sed -n 's/^refs\/heads\/automation\/brawl\/try\/\([0-9]*\)$/\1/p')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Get short commit SHA
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | cut -c 1-7)
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
- name: Insert custom html for PR
if: ${{ startsWith(github.ref, 'refs/heads/automation/brawl/try/') || github.event.pull_request.head.repo.full_name == github.repository }}
run: .github/patch-docs.sh ${{ github.event.repository.html_url }} ${{ env.SHA }} ${{ env.SHORT_SHA }} ${{ env.PR_NUMBER || github.event.pull_request.number }}
- name: Insert custom html for merge
if: ${{ startsWith(github.ref, 'refs/heads/automation/brawl/merge/') }}
run: .github/patch-docs.sh ${{ github.event.repository.html_url }} ${{ env.SHA }} ${{ env.SHORT_SHA }}
- name: Upload docs
uses: actions/upload-artifact@v4
with:
name: docs
path: target/doc
- name: Deploy
if: ${{ startsWith(github.ref, 'refs/heads/automation/brawl/try/') || github.event.pull_request.head.repo.full_name == github.repository }}
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_DOCS_API_KEY }}
accountId: ${{ secrets.CF_DOCS_ACCOUNT_ID }}
command: pages deploy --project-name=scuffle-docrs --branch=pr/${{ env.PR_NUMBER || github.event.pull_request.number }} --commit-hash=${{ env.SHA }} --commit-dirty=true ./target/doc
brawl-done:
runs-on: ubuntu-24.04
needs: [hakari, test, clippy, fmt, docs]
if: ${{ !cancelled() && github.event_name == 'push' }}
steps:
- name: calculate the correct exit status
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'