-
Notifications
You must be signed in to change notification settings - Fork 1.2k
160 lines (141 loc) · 4.98 KB
/
rust-sdk-tests.yml
File metadata and controls
160 lines (141 loc) · 4.98 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
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"
- 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'
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"
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
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
COPILOT_CLI_PATH: ${{ steps.setup-copilot.outputs.cli-path }}
run: cargo test --features test-support
# Validates the `embedded-cli` build path on all three supported
# platforms. This is the only place `build.rs` actually runs (the
# default `cargo test` job above has `COPILOT_CLI_VERSION` unset, so
# `build.rs` returns immediately). Catches regressions in the
# download / verify / extract / embed pipeline before they ship to
# crates.io and before bundling consumers (e.g. github-app's
# bundled-CLI release pipeline) 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
- name: Read pinned @github/copilot CLI version
id: cli-version
working-directory: ./nodejs
run: |
version=$(node -p "require('./package.json').dependencies['@github/copilot'].replace(/^[\^~]/, '')")
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; on
# cache miss the bundle job exercises the full ureq download +
# SHA-256 + retry path, which is exactly the regression surface
# we want validated.
- 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 --features embedded-cli
env:
COPILOT_CLI_VERSION: ${{ steps.cli-version.outputs.version }}
BUNDLED_CLI_CACHE_DIR: ${{ github.workspace }}/rust/.bundled-cli-cache
run: cargo build --features embedded-cli