-
Notifications
You must be signed in to change notification settings - Fork 106
223 lines (212 loc) · 8.55 KB
/
ci.yml
File metadata and controls
223 lines (212 loc) · 8.55 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
name: CI
on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 4 * * 0,3" # 4 a.m. UTC every Sun and Wed, keep actions-cache available
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# All jobs use `actions-rust-lang/setup-rust-toolchain@v1`, which handles both
# toolchain installation and Rust-specific caching (via Swatinem/rust-cache)
# internally. No separate `actions/cache` step is needed. Caches are
# automatically separated per job (the key includes the job name, OS, and a
# hash of Cargo.lock).
#
# Jobs with caching remove the pre-installed stable toolchain first so it
# doesn't pollute the rust-cache environment hash. macOS (and sometimes Linux)
# runner images ship with varying stable versions, making the hash
# non-deterministic and causing constant cache misses.
jobs:
msrv:
name: cargo build with MSRV
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-15]
fail-fast: false
steps:
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
toolchain: 1.88.0 # MSRV, should sync with `rust-version` in `Cargo.toml`
target: wasm32-unknown-unknown
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Run builds
run: |
cargo build --workspace --exclude ic-cdk-e2e-tests --target wasm32-unknown-unknown
cargo build --workspace --exclude ic-cdk-e2e-tests --target wasm32-unknown-unknown --release
cargo build --example=work
test:
name: cargo test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-15]
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
# No explicit `toolchain` — uses the channel from rust-toolchain.toml.
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
- name: Download pocket-ic server
run: bash scripts/download_pocket_ic_server.sh
- name: Install protoc (macOS)
if: runner.os == 'macOS'
run: brew install protobuf
- name: Install protoc (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Run tests
run:
| # https://github.com/rust-lang/cargo/issues/6669 we have to run ALL tests with two commands
cargo test --all-targets --no-fail-fast
cargo test --doc
wasm64:
name: wasm64 e2e
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-15]
fail-fast: false
steps:
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
# Pinned to a known-good nightly. wasm64 is a tier-3 target built via
# `-Zbuild-std`, so it's sensitive to nightly regressions. Only bump when
# there's a specific reason (new feature needed, dep requires newer compiler).
toolchain: nightly-2025-05-09 # 1.88.0
# Do NOT add `target: wasm64-unknown-unknown` here. wasm64 is a tier-3
# target with no pre-built `rust-std`, so `rustup target add` would fail.
# Instead, `rust-src` is needed so that `-Zbuild-std` can compile `std`
# from source for the wasm64 target.
components: rust-src
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download pocket-ic server
run: bash scripts/download_pocket_ic_server.sh
- name: Install protoc (macOS)
if: runner.os == 'macOS'
run: brew install protobuf
- name: Install protoc (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Run tests
run: WASM64=1 cargo test --package ic-cdk-e2e-tests --no-fail-fast
fmt:
name: cargo fmt
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# No explicit `toolchain` — uses the channel from rust-toolchain.toml.
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
cache: false # Disable caching for fmt, since it doesn't build anything.
- name: Check formatting
run: |
cargo fmt --all -- --check
clippy:
name: cargo clippy
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
# No explicit `toolchain` — uses the channel from rust-toolchain.toml.
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
- name: Install cargo-hack
uses: taiki-e/install-action@80e6af7a2ec7f280fffe2d0a9d3a12a9d11d86e9 # v2.75.1
with:
tool: cargo-hack@0.6
- name: Install protoc (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Run clippy
run: |
cargo hack clippy --feature-powerset --no-dev-deps --keep-going -- -D warnings
cargo clippy --tests --benches --keep-going -- -D warnings
doc:
name: cargo doc
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
# No explicit `toolchain` — uses the channel from rust-toolchain.toml.
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
- name: Install protoc (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Run doc
run: |
RUSTDOCFLAGS="-D warnings" cargo doc
docsrs:
name: docsrs
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Remove pre-installed Rust stable toolchain
run: rustup toolchain remove stable 2>/dev/null || true
- name: Install nightly Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1.15.4
with:
toolchain: nightly
target: wasm32-unknown-unknown
- name: Build docs (docs.rs simulation)
run: |
RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo +nightly doc --no-deps --all-features --target wasm32-unknown-unknown \
-p ic-cdk \
-p ic-cdk-bitcoin-canister \
-p ic-cdk-executor \
-p ic-cdk-management-canister \
-p ic-cdk-timers
aggregate:
name: ci:required
if: ${{ always() }}
needs: [msrv, test, wasm64, fmt, clippy, doc, docsrs]
runs-on: ubuntu-24.04
steps:
- name: check msrv result
if: ${{ needs.msrv.result != 'success' }}
run: exit 1
- name: check test result
if: ${{ needs.test.result != 'success' }}
run: exit 1
- name: check wasm64 result
if: ${{ needs.wasm64.result != 'success' }}
run: exit 1
- name: check fmt result
if: ${{ needs.fmt.result != 'success' }}
run: exit 1
- name: check clippy result
if: ${{ needs.clippy.result != 'success' }}
run: exit 1
- name: check docsrs result
if: ${{ needs.docsrs.result != 'success' }}
run: exit 1