-
Notifications
You must be signed in to change notification settings - Fork 3
217 lines (185 loc) · 8.48 KB
/
Copy pathci.yml
File metadata and controls
217 lines (185 loc) · 8.48 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
name: CI
# Secure CI suite: format, lint (deny warnings), build, test on Linux + Windows,
# plus supply-chain checks (cargo-deny advisories/licenses/sources/bans and
# cargo-audit RUSTSEC). Runs on every PR and on pushes to main.
on:
pull_request:
push:
branches: [main]
# Least privilege: CI only needs to read the repo. No token can write.
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0" # reproducible, smaller caches in CI
RUST_BACKTRACE: "1"
# The workspace compiles wasmtime/cranelift (dig-node), whose debug symbols
# dominate target/ and overran the runner disk ("No space left on device").
# Strip debuginfo in CI — behaviour is identical; backtraces keep symbol names
# (just not line numbers). This is the biggest single reduction in target/ size.
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
jobs:
test:
name: build & test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install pinned Rust toolchain
shell: bash
run: |
rustup show # installs the toolchain pinned in rust-toolchain.toml (channel + components + targets)
rustc --version && cargo --version
# The workspace now pulls in wasmtime/cranelift (dig-node) on top of the full
# crate graph, and build+test of all targets overran the stock ubuntu runner's
# ~14 GB free disk ("No space left on device"). Reclaim the large preinstalled
# SDKs we never use (~25 GB: .NET, Android, GHC, CodeQL) before the build.
# Linux only — Windows runners have ample disk and no apt/docker here.
- name: Free disk space (ubuntu)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
df -h /
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/.ghcup \
/usr/local/lib/android /opt/hostedtoolcache \
/usr/local/share/boost /usr/share/swift /usr/local/share/powershell \
/usr/local/lib/node_modules /usr/local/share/chromium \
/usr/local/graalvm "${AGENT_TOOLSDIRECTORY:-}" || true
sudo docker image prune --all --force || true
df -h /
- name: Cache cargo + target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
# The CLI's build.rs embeds the real guest wasm (BINDING contract D6), so
# the wasm32 guest must be built before anything that compiles digstore-cli.
- name: Build guest wasm (required by digstore-cli build.rs)
run: cargo build -p digstore-guest --target wasm32-unknown-unknown --release --locked
- name: Format check
if: matrix.os == 'ubuntu-latest'
run: cargo fmt --all --check
# Deny warnings (correctness, suspicious, security-relevant lints fail CI).
# Two purely cosmetic style lints are allowed so the gate stays focused on
# substance rather than churn over test-code idioms.
- name: Clippy (deny warnings)
run: >
cargo clippy --workspace --all-targets --locked --
-D warnings
-A clippy::default_constructed_unit_structs
-A clippy::field_reassign_with_default
- name: Build
run: cargo build --workspace --locked
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
# cargo-nextest natively detects+reports flaky tests (retried-but-passed
# surfaces as "FLAKY" in the run summary, not silently green) instead of
# papering over intermittent failures with a bare re-run (#489).
#
# Intentionally a bare `cargo nextest run`, NOT `cargo llvm-cov nextest`:
# main has no coverage measurement/gate today, so this PR (flaky-test
# management only) must not introduce one. Coverage instrumentation also
# measurably slows the instrumented `digstore` binary that CLI
# integration tests spawn as a child process (e.g. `cli_dev`'s dev-server
# startup poll), which blew existing CI-tuned timeouts under nextest's
# parallelism and made an otherwise-passing test fail consistently. A
# future PR can add `cargo llvm-cov` + an explicit `--fail-under-lines`
# gate as its own, reviewable change.
- name: Test (nextest, flaky-aware)
run: cargo nextest run --workspace --locked --retries 2
# nextest does not execute doctests (https://github.com/nextest-rs/nextest/issues/16) —
# run them separately so they still gate CI.
- name: Doctests
run: cargo test --doc --workspace --locked
# The read-crypto wasm crate (crates/dig-client-wasm) is EXCLUDED from the
# workspace (it must resolve without chia-bls/blst, which don't build for
# wasm32) so the `--workspace` job above never sees it. Gate it on its own:
# fmt + clippy + the native parity tests, then build the publishable
# @dignetwork/dig-client package (web + node) and verify it end-to-end. This
# keeps the published package buildable and the publish workflow honest.
dig-client-wasm:
name: dig-client-wasm (read-crypto npm package)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install pinned Rust toolchain
run: rustup show
- name: Install wasm-pack (official installer)
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Format check
working-directory: crates/dig-client-wasm
run: cargo fmt --check
- name: Clippy (deny warnings)
working-directory: crates/dig-client-wasm
run: cargo clippy --all-targets -- -D warnings
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
# This crate is excluded from the `--workspace` job above (it must
# resolve without chia-bls/blst for wasm32); its thin wasm-bindgen glue
# in src/lib.rs is exercised end-to-end by the "Verify assembled
# package" step below, not by these native parity tests. Flaky-aware
# nextest only (no coverage gate anywhere in this workflow — see the
# note on the workspace job's Test step).
- name: Parity tests (native, vs digstore-crypto; flaky-aware)
working-directory: crates/dig-client-wasm
run: cargo nextest run --locked --retries 2
# nextest does not execute doctests — run separately so they still gate CI.
- name: Parity doctests
working-directory: crates/dig-client-wasm
run: cargo test --doc --locked
- name: Build + assemble package (web + node -> pkg/)
working-directory: crates/dig-client-wasm
run: npm run build:pkg
- name: Generate real-crypto smoke fixture
working-directory: crates/dig-client-wasm
run: cargo run --example gen_smoke_fixture > smoke_fixture.json
- name: Verify assembled package (exports + .d.ts + integrity + runtime)
working-directory: crates/dig-client-wasm
run: node scripts/verify-pkg.mjs
supply-chain:
name: supply-chain audit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install pinned Rust toolchain
run: rustup show
- name: Cache cargo tools
uses: actions/cache@v4
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
key: ${{ runner.os }}-cargo-tools-deny
- name: Install cargo-deny
run: cargo install cargo-deny --locked || true
# Security-relevant supply-chain checks: RUSTSEC advisories (known/accepted
# ones ignored in deny.toml), yanked crates, dependency bans, and the source
# registry allow-list. cargo-deny is a superset of cargo-audit, so a separate
# audit step would be redundant. License compliance is deferred (see deny.toml).
- name: cargo deny check
run: cargo deny check advisories bans sources