-
Notifications
You must be signed in to change notification settings - Fork 328
160 lines (131 loc) · 4.75 KB
/
Copy pathci.yml
File metadata and controls
160 lines (131 loc) · 4.75 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: 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@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
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@820762786026740c76f36085b0efc47a31fe5020
with:
node-version: latest
cache: "npm"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
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@bee27e3a4fd1ea2111cf90ab89cd076c870fce14
with:
config: ./typos.toml
- name: Lint
run: |
cargo clippy
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
- 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@166cdcfd11aee3cb47222f9ddb555ce30ddb9659
with:
toolchain: stable
- name: Install cargo-hack
uses: taiki-e/install-action@41049aa56687c35e0afa74eed4f09cec4f9afabf
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 }}