Skip to content

grpc/xds: add test utility crate #6065

grpc/xds: add test utility crate

grpc/xds: add test utility crate #6065

Workflow file for this run

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'
with:
cache-targets: "false"
- name: Build protoc-gen-rust-grpc
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
run: cargo build -p protoc-gen-rust-grpc --release
- name: Populate cache directory if needed
if: steps.protoc-binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: |
cp -r target/release/build/protoc-gen-rust-grpc-*/out/install protoc-cache/
echo "Cached files:"
find protoc-cache/ -type f -exec ls -lh {} +
clippy:
runs-on: ubuntu-latest
needs: build-protoc-plugin
steps:
- uses: actions/checkout@v6
- uses: hecrj/setup-rust-action@v2
with:
components: clippy
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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: 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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: 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
# Windows is the long pole of a build. Caching it avoids adding ~5 minutes of build time
cache-targets: ${{ matrix.os == 'windows-latest' }}
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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: 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
# Windows is the long pole of a build. Caching it avoids adding ~4 minutes of build time
cache-targets: ${{ matrix.os == 'windows-latest' }}
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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: 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- 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/bin" >> $GITHUB_PATH
- uses: Swatinem/rust-cache@v2
with:
cache-targets: "false"
- run: cargo hack --no-private check-external-types --all-features
env:
RUSTFLAGS: "-D warnings"