-
Notifications
You must be signed in to change notification settings - Fork 1.2k
189 lines (168 loc) · 6.37 KB
/
rust-sdk-tests.yml
File metadata and controls
189 lines (168 loc) · 6.37 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
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"
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
# 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"
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
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