-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (173 loc) · 7.18 KB
/
Copy pathpr-tests.yml
File metadata and controls
196 lines (173 loc) · 7.18 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
name: PR Tests
# Runs on every PR and on push to dev. Four parallel jobs — wall-clock
# is the slowest one (usually `tests`). A new push to the same ref
# cancels the previous run.
on:
pull_request:
push:
branches: [dev]
concurrency:
group: pr-tests-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
# `CARGO_*_DEBUG=0` strips debuginfo so test binaries stay within runner
# memory — the full debug profile on nightly + tvm-sdk has hit rust-lld
# Bus errors. `CARGO_INCREMENTAL=0` — incremental compile only bloats
# the cache in CI without payoff (every runner is fresh).
env:
CARGO_PROFILE_DEV_DEBUG: "0"
CARGO_PROFILE_TEST_DEBUG: "0"
CARGO_INCREMENTAL: "0"
CARGO_TERM_COLOR: always
jobs:
fmt-clippy:
name: fmt + clippy
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
# nightly is required because `rustfmt.toml` sets
# `unstable_features = true`.
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
# `shared-key` drops the job name from the cache key → all 3 jobs
# in this workflow read/write the same cache. Parallel jobs in the
# same run still build independently (cache save happens at end of
# job, not during). The win is on subsequent runs: after the first
# green PR, all 3 jobs hit cache. Cold ~12-15 min (tvm-sdk),
# warm ~30-60 s per job.
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: pr-tests
cache-on-failure: true
- name: cargo fmt --all --check
run: cargo fmt --all --check
# `--no-deps` skips crates.io deps (we don't control their
# warnings); `--all-targets` covers tests + examples + bins.
#
# `double_must_use` is allowed because it fires on code no one here
# writes: `#[async_trait]` expands each trait method to a `#[must_use]`
# function returning `Pin<Box<dyn Future>>`, which is itself already
# `must_use`, and clippy reports the redundancy against the macro's
# output. Clippy normally suppresses lints originating in an external
# macro; this one slips through, so the only place to silence it is
# here — the offending attribute exists solely in the expansion, and
# there is no source line to annotate. Every `#[async_trait]` trait in
# the workspace trips it, so `-D warnings` fails the whole job.
#
# Drop this flag once the upstream lint stops firing on macro
# expansions: remove it, run the command below, and if it is clean the
# workaround has outlived its cause.
- name: cargo clippy
run: cargo clippy --workspace --all-targets --no-deps -- -D warnings -A clippy::double_must_use
tests:
name: tests (Postgres + nextest)
runs-on: ubuntu-latest
timeout-minutes: 30
env:
# Tests read TEST_DATABASE_URL from env, see README.md#test-postgres.
# Locally the port is 55432 (via docker-compose.test.yml); in CI
# it's 5432 (the conventional default — runner has nothing else
# bound to it).
TEST_DATABASE_URL: postgres://dodex:dodex@localhost:5432/dodex_test
services:
# Matches docker-compose.test.yml on image / creds / settings;
# only the port differs (5432 in CI vs 55432 locally). The schema
# is created in tests via `sqlx::migrate!`, so the container only
# needs to bring up an empty database.
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: dodex
POSTGRES_PASSWORD: dodex
POSTGRES_DB: dodex_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U dodex -d dodex_test"
--health-interval 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: pr-tests
cache-on-failure: true
# Pre-built binary, ~10 s install. The `cargo install
# cargo-nextest` alternative compiles for ~3 min from scratch.
- name: Install nextest
uses: taiki-e/install-action@nextest
# nextest runs integration test binaries in parallel (cargo test
# runs them sequentially). With 25+ integration crates this is a
# noticeable runtime win. `#[ignore]`-marked shellnet e2e_* tests
# are skipped by default (`--run-ignored=all` includes them).
- name: cargo nextest run
run: cargo nextest run --workspace --no-fail-fast
# nextest does not run doctests — separate step.
- name: cargo test --doc
run: cargo test --workspace --doc
openapi-drift:
name: openapi drift guard
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
shared-key: pr-tests
cache-on-failure: true
- name: Regenerate openapi.yaml from Rust source
run: cargo run --quiet -p dodex-api --bin gen-openapi -- --out /tmp/openapi.yaml
- name: Diff against committed docs/openapi.yaml
run: |
if ! diff -u docs/openapi.yaml /tmp/openapi.yaml; then
echo
echo "docs/openapi.yaml is out of sync with services/api."
echo "Run: cargo run -p dodex-api --bin gen-openapi"
echo "and commit the result."
exit 1
fi
sdk-harness-tests:
name: sdk harness unit tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with: { shared-key: sdk-tests, cache-on-failure: true }
- uses: taiki-e/install-action@nextest
# sdk/ is its own workspace and sits outside `cargo nextest run
# --workspace` above, so it gets its own run. No filter: everything in
# there that needs a chain is `#[ignore]`d, so a plain run is exactly the
# hermetic set — and a new hermetic test is picked up by having been
# written, rather than by happening to match one of a list of name
# patterns.
#
# The count guard stays. Without it this step would pass just as happily
# having run nothing at all, which is what an over-eager `#[ignore]` or a
# broken test binary would look like.
- name: nextest (sdk harness units)
run: |
N=$(cargo nextest list --manifest-path sdk/Cargo.toml | grep -c '::')
test "$N" -ge 60
cargo nextest run --manifest-path sdk/Cargo.toml --no-fail-fast
# Gated e2e: only after fmt/clippy, tests and openapi-drift are green.
# Delegates to the reusable e2e-shellnet workflow (real shellnet,
# single-threaded). It self-provisions a fresh seed note per run
# (mint_pn_pool) and drains it in teardown — no secret needed.
e2e:
name: e2e (shellnet)
needs: [fmt-clippy, tests, openapi-drift]
uses: ./.github/workflows/e2e-shellnet.yml
secrets: inherit