Repository navigation
176 lines (145 loc) · 5.67 KB
/
Copy pathci.yml
File metadata and controls
176 lines (145 loc) · 5.67 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "ci-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
msrv:
name: Minimum supported Rust version
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Read MSRV from Cargo.toml
id: msrv
run: |
msrv="$(sed -n 's/^rust-version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' agent-client-protocol-schema/Cargo.toml)"
test -n "$msrv"
echo "version=$msrv" >> "$GITHUB_OUTPUT"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f
with:
toolchain: ${{ steps.msrv.outputs.version }}
- name: Check with MSRV
run: cargo check --all-targets --all-features --locked
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Use Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: latest
cache: "npm"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f
with:
toolchain: nightly,stable
components: rustfmt,clippy
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format:check
- name: Check for typos
uses: crate-ci/typos@7f9d0819ca1c008ade73f4b41fa9d258d48f605b
with:
config: ./typos.toml
- name: Lint
run: |
cargo clippy
cargo clippy -p agent-client-protocol-schema --all-targets --no-default-features --features unstable,unstable_protocol_v2,tracing
cargo clippy --all-targets --all-features
- name: Build
run: cargo build --all-targets --all-features
- name: Check docs.rs build
env:
RUSTDOCFLAGS: --cfg docsrs
run: cargo +nightly doc -p agent-client-protocol-schema --all-features --no-deps
- name: Run tests
run: cargo test --all-features
# The generator builds one schema per feature set, and `--all-features`
# only selects the unstable v2 one, so test the other published schemas too.
- name: Run schema generator tests for each published schema
run: |
cargo test -p schema-generator
cargo test -p schema-generator --features unstable
cargo test -p schema-generator --features unstable_protocol_v2
# Some schema tests check behavior that only applies when an unstable
# feature such as `unstable_end_turn_token_usage` is off.
- name: Run schema tests without every unstable feature
run: |
cargo test -p agent-client-protocol-schema --features unstable_protocol_v2
cargo test -p agent-client-protocol-schema --features unstable_subagents
- name: Check generated files are up to date
run: |
npm run generate
git diff --exit-code || (echo "Generated files are out of date. Run 'npm run generate' and commit the changes." && exit 1)
rust-changes:
name: Detect Rust changes
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.rust-changes.outputs.changed }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false
- name: Check for Rust file changes
id: rust-changes
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
HEAD_SHA: ${{ github.sha }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -Eq '(^|/)(Cargo\.toml|Cargo\.lock)$|\.rs$'; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
feature-powerset:
name: Feature powerset (${{ matrix.partition }})
needs: rust-changes
if: needs.rust-changes.outputs.changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
partition: ["1/4", "2/4", "3/4", "4/4"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f
with:
toolchain: stable
- name: Install cargo-hack
uses: taiki-e/install-action@ab6895351a88b908e96a4697860d4ffea5e57dbe
with:
tool: cargo-hack
- name: Check feature powerset
# `unstable` is an aggregate alias for the individual unstable_* features,
# so excluding it avoids duplicate combinations. Limit the powerset to
# feature pairs to keep CI practical; the regular CI all-features build
# still covers the all-on case.
run: cargo hack --locked check --feature-powerset --exclude-features unstable --no-dev-deps --depth 2 --partition ${{ matrix.partition }}