-
Notifications
You must be signed in to change notification settings - Fork 1.3k
266 lines (236 loc) · 9.57 KB
/
Copy pathrust-sdk-tests.yml
File metadata and controls
266 lines (236 loc) · 9.57 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: "Rust SDK Tests"
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'rust/**'
- 'test/**'
- 'nodejs/package.json'
- '.github/workflows/rust-sdk-tests.yml'
- '.github/actions/setup-copilot/**'
- '!**/*.md'
- '!**/LICENSE*'
- '!**/.gitignore'
- '!**/.editorconfig'
- '!**/*.png'
- '!**/*.jpg'
- '!**/*.jpeg'
- '!**/*.gif'
- '!**/*.svg'
workflow_dispatch:
merge_group:
permissions:
contents: read
jobs:
test:
name: "Rust SDK Tests (${{ matrix.os }}, default)"
if: github.event.repository.fork == false
env:
POWERSHELL_UPDATECHECK: Off
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ./rust
steps:
- uses: actions/checkout@v6.0.2
- uses: ./.github/actions/setup-copilot
id: setup-copilot
# rust-toolchain.toml in rust/ pins the stable channel + components.
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94.0"
components: rustfmt, clippy
# Nightly rustfmt for unstable format options (group_imports,
# imports_granularity, reorder_impl_items) — pinned in
# `.rustfmt.nightly.toml`.
- name: Install nightly rustfmt
if: runner.os == 'Linux'
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-04-14
components: rustfmt
- uses: Swatinem/rust-cache@v2
with:
workspaces: "rust"
prefix-key: v1-rust-no-bin
cache-bin: false
- name: Read pinned @github/copilot CLI version
id: cli-version
working-directory: ./nodejs
run: |
version=$(node -p "require('./package-lock.json').packages['node_modules/@github/copilot'].version")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Pinned CLI version: $version"
# Share the bundled-CLI archive cache with the `bundle` job: build.rs
# now downloads in both modes (embed for `bundle`, extract-to-cache
# for this `test` job's `--no-default-features` build).
- name: Cache bundled CLI tarball
uses: actions/cache@v4
with:
path: ./rust/.bundled-cli-cache
key: bundled-cli-${{ matrix.os }}-${{ steps.cli-version.outputs.version }}
- name: cargo fmt --check (nightly)
if: runner.os == 'Linux'
run: cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml --check
- name: cargo clippy
if: runner.os == 'Linux'
env:
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
run: cargo clippy --all-targets --features test-support -- --no-deps -D warnings -D clippy::unwrap_used -D clippy::disallowed_macros -D clippy::await_holding_invalid_type
- name: cargo doc
if: runner.os == 'Linux'
env:
RUSTDOCFLAGS: "-D warnings"
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
run: cargo doc --no-deps --all-features
- name: Install test harness dependencies
working-directory: ./test/harness
run: npm ci --ignore-scripts
- name: Warm up PowerShell
if: runner.os == 'Windows'
run: pwsh.exe -Command "Write-Host 'PowerShell ready'"
- name: cargo test
timeout-minutes: 90
env:
RUST_E2E_CONCURRENCY: 4
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.cli-path }}
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
# `--no-default-features` selects dev mode: build.rs still downloads
# + verifies + extracts the CLI to the per-user cache, but doesn't
# embed it. Tests exec against the setup-copilot CLI via
# COPILOT_CLI_PATH (the env override wins over the dev cache).
# The dedicated `bundle` job below exercises the embed pipeline.
run: cargo test --no-default-features --features test-support -- --test-threads=4 --nocapture
# Exercises the in-process FFI transport (`Transport::InProcess`, the Rust
# analogue of the .NET `RuntimeConnection.ForInProcess()`), mirroring the
# `inprocess` transport cell in dotnet-sdk-tests.yml. Sets
# COPILOT_SDK_DEFAULT_CONNECTION=inprocess so the client hosts the runtime
# cdylib in-process instead of spawning a stdio child, then runs the whole
# E2E suite over the in-process transport. The suite runs serially in-process
# (the harness forces concurrency to 1) because it mirrors each test's
# environment onto the shared process environment the in-process worker inherits.
# Windows is excluded (matching dotnet-sdk-tests.yml) pending in-process SQLite
# file-locking on shutdown.
test-inprocess:
name: "Rust SDK Tests (${{ matrix.os }}, inprocess)"
if: github.event.repository.fork == false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ./rust
steps:
- uses: actions/checkout@v6.0.2
- uses: ./.github/actions/setup-copilot
id: setup-copilot
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94.0"
- uses: Swatinem/rust-cache@v2
with:
workspaces: "rust"
prefix-key: v1-rust-no-bin
cache-bin: false
- name: Read pinned @github/copilot CLI version
id: cli-version
working-directory: ./nodejs
run: |
version=$(node -p "require('./package-lock.json').packages['node_modules/@github/copilot'].version")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Pinned CLI version: $version"
- name: Cache bundled CLI tarball
uses: actions/cache@v4
with:
path: ./rust/.bundled-cli-cache
key: bundled-cli-${{ matrix.os }}-${{ steps.cli-version.outputs.version }}
- name: Install test harness dependencies
working-directory: ./test/harness
run: npm ci --ignore-scripts
- name: Select in-process transport
run: echo "COPILOT_SDK_DEFAULT_CONNECTION=inprocess" >> "$GITHUB_ENV"
- name: cargo test (in-process transport, full E2E suite)
timeout-minutes: 60
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.cli-path }}
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
# The harness forces serial execution in-process (both the async semaphore and
# libtest via --test-threads=1) because it mirrors each test's environment onto
# the shared process environment, so RUST_E2E_CONCURRENCY is not set here.
run: cargo test --no-default-features --features test-support --test e2e -- --test-threads=1 --nocapture
# Validates the bundled-CLI build path on all three supported
# platforms. While the regular `cargo test` job above also exercises
# build.rs (bundling is on by default now), this matrix job is the
# dedicated cross-platform smoke test for the download / verify /
# extract / embed pipeline. Catches regressions before they ship to
# crates.io and before bundling consumers hit them downstream.
bundle:
name: "Rust SDK Bundled CLI Build (${{ matrix.os }})"
if: github.event.repository.fork == false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ./rust
steps:
- uses: actions/checkout@v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.94.0"
- uses: Swatinem/rust-cache@v2
# Cache is only an optimization; the Windows bundled smoke test should
# not fail when rust-cache's post-job save flakes after a successful build.
continue-on-error: ${{ runner.os == 'Windows' }}
with:
workspaces: "rust"
key: bundled-cli
prefix-key: v1-rust-no-bin
cache-bin: false
- name: Read pinned @github/copilot CLI version
id: cli-version
working-directory: ./nodejs
run: |
version=$(node -p "require('./package-lock.json').packages['node_modules/@github/copilot'].version")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Pinned CLI version: $version"
# Cache the downloaded archive across runs so we don't refetch
# ~130 MB on every CI invocation. Keyed by OS + CLI version so old
# archives drop out when the pinned version bumps, keeping the
# cache bounded.
- name: Cache bundled CLI tarball
uses: actions/cache@v4
with:
path: ./rust/.bundled-cli-cache
key: bundled-cli-${{ matrix.os }}-${{ steps.cli-version.outputs.version }}
- name: cargo build (bundled-cli is the default feature)
env:
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
run: cargo build