-
Notifications
You must be signed in to change notification settings - Fork 1.2k
303 lines (286 loc) · 10.7 KB
/
CI.yml
File metadata and controls
303 lines (286 loc) · 10.7 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
name: CI
on:
push:
pull_request: {}
merge_group:
branches: [ "master" ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# By default, skip building the plugin and rely on caching to put it in the
# system's PATH.
PROTOC_GEN_RUST_GRPC_NO_BUILD: 1
jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
with:
components: rustfmt
- run: cargo fmt --all --check
build-protoc-plugin:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
env:
# By default we skip building this plugin; this is the only rule that
# needs to actually build it.
PROTOC_GEN_RUST_GRPC_NO_BUILD: ""
steps:
- uses: actions/checkout@v6
- uses: actions/cache@v4
id: protoc-binaries-cache
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- uses: hecrj/setup-rust-action@v2
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
- uses: Swatinem/rust-cache@v2
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
- name: Build protoc-gen-rust-grpc
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
run: cargo build -p protoc-gen-rust-grpc
- name: Populate cache directory if needed
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p protoc-cache
# Find where cmake built the binaries and any companion DLLs.
find target/ -name "protoc" -o -name "protoc.exe" -o -name "protoc-gen-rust-grpc" -o -name "protoc-gen-rust-grpc.exe" -o -name "*.dll" | while read -r file; do
# Verify it's in the build output directory to avoid copying source or unrelated files.
if [[ "$file" == *"/out/bin/"* ]] || [[ "$file" == *"/out/build/bin/"* ]]; then
cp "$file" protoc-cache/
fi
done
echo "Cached files:"
ls -la protoc-cache/
clippy:
runs-on: ubuntu-latest
needs: build-protoc-plugin
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
with:
components: clippy
- uses: taiki-e/install-action@protoc
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-features --all-targets
codegen:
runs-on: ubuntu-latest
needs: build-protoc-plugin
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo run --package codegen
- run: git diff --exit-code
udeps:
runs-on: ubuntu-latest
needs: build-protoc-plugin
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-02-22
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-udeps
- uses: taiki-e/install-action@protoc
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo hack udeps --workspace --exclude-features=_tls-any,tls,tls-aws-lc,tls-ring,tls-connect-info --each-feature
- run: cargo udeps --package tonic --features tls-ring,transport
- run: cargo udeps --package tonic --features tls-ring,server
- run: cargo udeps --package tonic --features tls-ring,channel
- run: cargo udeps --package tonic --features tls-aws-lc,transport
- run: cargo udeps --package tonic --features tls-aws-lc,server
- run: cargo udeps --package tonic --features tls-aws-lc,channel
- run: cargo udeps --package tonic --features tls-connect-info
check:
runs-on: ${{ matrix.os }}
needs: build-protoc-plugin
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
env:
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@protoc
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- name: Check features
run: cargo hack check --workspace --no-private --each-feature --no-dev-deps
- name: Check tonic feature powerset
run: cargo hack check --package tonic --feature-powerset --depth 2
- name: Check all targets
run: cargo check --workspace --all-targets --all-features
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- name: Resolve MSRV aware dependencies
run: cargo update
env:
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
- name: Get MSRV from manifest file
id: msrv
run: echo "version=$(yq '.workspace.package.rust-version' Cargo.toml)" >> "$GITHUB_OUTPUT"
- uses: hecrj/setup-rust-action@v2
with:
rust-version: ${{ steps.msrv.outputs.version }}
- uses: taiki-e/install-action@cargo-no-dev-deps
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo no-dev-deps --no-private check --all-features --workspace
doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/install@cargo-docs-rs
- uses: taiki-e/install-action@cargo-hack
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly hack --no-private docs-rs
env:
RUSTDOCFLAGS: "-D warnings"
test:
runs-on: ${{ matrix.os }}
needs: build-protoc-plugin
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-nextest
- uses: taiki-e/install-action@protoc
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo nextest run --workspace --all-features
env:
QUICKCHECK_TESTS: 1000 # run a lot of quickcheck iterations
doc-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@cargo-hack
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo hack --no-private test --doc --all-features
interop:
name: Interop Tests
needs: build-protoc-plugin
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
- uses: taiki-e/install-action@protoc
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo build -p interop
- name: Run interop tests
run: ./interop/test.sh
shell: bash
- name: Run interop tests with Rustls
run: ./interop/test.sh --use_tls tls_rustls
shell: bash
semver:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: all-features
external-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2025-10-18
- name: Install cargo-check-external-types
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-check-external-types@0.4.0
- uses: taiki-e/install-action@cargo-hack
- uses: actions/cache@v4
with:
path: protoc-cache
key: protoc-binaries-${{ runner.os }}-${{ hashFiles('protoc-gen-rust-grpc/src/cpp_source/**', 'protoc-gen-rust-grpc/build.rs') }}
- name: Add cached binaries to PATH
shell: bash
run: echo "${{ github.workspace }}/protoc-cache" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
- run: cargo hack --no-private check-external-types --all-features
env:
RUSTFLAGS: "-D warnings"