-
Notifications
You must be signed in to change notification settings - Fork 12
248 lines (233 loc) · 8.74 KB
/
Copy pathtests.yml
File metadata and controls
248 lines (233 loc) · 8.74 KB
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
name: CI Checks
on:
push:
branches:
- main
pull_request:
env:
DFX_VERSION: 0.16.0
jobs:
# First stage is to build everything.
cargo-build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: ["1.90.0"]
os: [ubuntu-22.04, macos-15]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup target add wasm32-unknown-unknown
rustup component add clippy
- name: Build
shell: bash
run: |
cargo build --package xrc --release --all-targets --features ipv4-support
cargo build --package xrc --release --all-targets
env:
RUST_BACKTRACE: 1
# Occurs after building, runs `cargo test` to ensure unit tests are passing.
cargo-tests:
needs: cargo-build
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: ["1.90.0"]
os: [ubuntu-22.04, macos-15]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup target add wasm32-unknown-unknown
rustup component add clippy
- uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # v1.0.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings
- name: Run Tests
shell: bash
run: |
cargo test --package xrc --release --all-targets
cargo test --package xrc --release --all-targets --features ipv4-support
env:
RUST_BACKTRACE: 1
# Runs clippy to lint the rust code.
cargo-clippy:
needs: cargo-build
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: ["1.90.0"]
os: [ubuntu-22.04, macos-15]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup component add clippy
- uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # v1.0.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings
# Runs the e2e tests after the cargo-build stage.
e2e-tests:
runs-on: ubuntu-22.04
needs: cargo-build
strategy:
matrix:
rust: ["1.90.0"]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup target add wasm32-unknown-unknown
- name: Install DFX
env:
DFXVM_INIT_YES: true
run: |
wget --output-document install-dfx.sh "https://sdk.dfinity.org/install.sh"
bash install-dfx.sh
rm install-dfx.sh
source "$HOME/.local/share/dfx/env"
dfx cache install
echo "$HOME/bin" >> $GITHUB_PATH
- name: Run e2e tests
run: |
source "$HOME/.local/share/dfx/env"
./scripts/e2e-tests
# Runs the listing-parser instruction benchmarks with canbench. The committed
# baseline (src/xrc/canbench_results.yml) must stay up to date: any regression,
# improvement, or new benchmark fails the job until it is refreshed with
# `(cd src/xrc && canbench --persist --csv)` and committed. The parse runs
# inside the HTTP-outcall transform — a single, non-DTS execution — so its
# instruction cost is the constraint worth tracking. A PR comment with the
# delta versus the base branch is posted by the canbench-post-comment workflow.
benchmark:
runs-on: ubuntu-22.04
strategy:
matrix:
rust: ["1.90.0"]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Checkout base branch
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
ref: ${{ github.event.pull_request.base.ref || github.ref_name }}
path: _canbench_baseline_branch
- uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-1
- name: Cache canbench binary
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: ~/.cargo/bin/canbench
key: canbench-bin-0.4.1
- name: Cache canbench runtime
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0
with:
path: src/xrc/.canbench
key: canbench-runtime-0.4.1
- name: Install Rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup target add wasm32-unknown-unknown
- name: Benchmark
shell: bash
run: bash ./scripts/ci_run_benchmark.sh src/xrc ${{ github.job }}
env:
RUST_BACKTRACE: 1
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: canbench_result_${{ github.job }}
path: /tmp/canbench_result_${{ github.job }}.md
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: canbench_results_${{ github.job }}_csv
path: /tmp/canbench_results_${{ github.job }}.csv
- name: Pass or fail
shell: bash
run: bash ./scripts/ci_post_run_benchmark.sh
# Saves the PR number so the canbench-post-comment workflow (which runs in a
# separate, trusted context) knows which PR to comment on. PR-only and
# intentionally excluded from checks-pass — it is an artifact helper, not a
# quality gate.
upload-pr-number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-22.04
steps:
- name: Save PR number
run: |
mkdir -p ./pr_number
echo "${{ github.event.pull_request.number }}" > ./pr_number/pr_number
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pr_number
path: pr_number/
# Lints all of the shell scripts.
shell-checks:
name: ShellCheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master
env:
SHELLCHECK_OPTS: -e SC1090 -e SC2119 -e SC1091
# Final stage that will fail if any of the entries in `needs` fails or is skipped.
# NOTE: `if: always()` is required so this job runs even when a dependency
# fails/cancels/skips. Without it, this job would itself be skipped, and
# GitHub branch protection treats a skipped required check as passing,
# allowing PRs to merge despite failing CI.
checks-pass:
if: always()
needs: ["cargo-clippy", "e2e-tests", "cargo-tests", "shell-checks", "benchmark"]
runs-on: ubuntu-22.04
steps:
- name: Fail if any dependency did not succeed
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
run: |
echo "One or more required jobs did not succeed: ${{ toJSON(needs) }}"
exit 1
- name: Checks workflow passes
run: echo OK