feat(generator/rust): use I32 formatter #5117
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Rust SDK | |
permissions: read-all | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
release: | |
types: [published] | |
env: | |
GHA_RUST_VERSIONS: '{ "rust:msrv": "1.85", "rust:current": "1.87" }' | |
GHA_GO_VERSIONS: '{ "go:current": "1.23.8" }' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: ['macos-14', 'ubuntu-24.04', 'windows-2025'] | |
rust-version: ['rust:current'] | |
include: | |
- os: 'ubuntu-24.04' | |
rust-version: 'rust:msrv' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- run: rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Running tests for key crates | |
run: cargo clean && cargo test | |
- name: Build full workspace | |
# See Cargo.toml for the definition and motivation of this profile | |
run: cargo clean && cargo build --profile=ci --workspace | |
- name: Running tests for full workspace | |
# See Cargo.toml for the definition and motivation of this profile | |
run: cargo clean && cargo test --profile=ci --workspace | |
if: github.event_name == 'push' | |
features: | |
strategy: | |
matrix: | |
os: ['ubuntu-24.04'] | |
rust-version: ['rust:current'] | |
runs-on: ${{ matrix.os }} | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add clippy | |
- run: rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Test crates with features disabled | |
run: | | |
set -e | |
cargo clean | |
echo "==== google-cloud-wkt ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-wkt --no-default-features | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features chrono | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features time | |
cargo "${sub}" --package google-cloud-wkt --no-default-features --features _internal-semver | |
cargo "${sub}" --package google-cloud-wkt --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-wkt --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-gax ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-gax --no-default-features | |
cargo "${sub}" --package google-cloud-gax --no-default-features --features unstable-stream | |
cargo "${sub}" --package google-cloud-gax --no-default-features --features _internal-semver | |
cargo "${sub}" --package google-cloud-gax --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-gax --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-gax-internal ====" | |
for sub in test doc; do | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-common | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-http-client | |
cargo "${sub}" --package google-cloud-gax-internal --no-default-features --features _internal-grpc-client | |
cargo "${sub}" --package google-cloud-gax-internal --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-gax-internal --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-lro ====" | |
for sub in test doc; do | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features --features unstable-stream | |
cargo "${sub}" --profile=ci --package google-cloud-lro --no-default-features --features _internal-semver | |
cargo "${sub}" --profile=ci --package google-cloud-lro --all-features | |
done | |
cargo clippy --no-deps --package google-cloud-lro --all-features --all-targets --profile=test -- --deny warnings | |
cargo clean | |
echo "==== google-cloud-aiplatform-v1 ====" | |
cargo build -p google-cloud-aiplatform-v1 --no-default-features | |
mapfile -t features < <(sed -n -e '/^default = \[/,/^\]/ p' src/generated/cloud/aiplatform/v1/Cargo.toml | sed -n -e '/",/ s/ *"\(.*\)",/\1/p') | |
for feature in "${features[@]}"; do | |
echo "==== google-cloud-aiplatform-v1 + ${feature} ====" | |
cargo build --profile=ci -p google-cloud-aiplatform-v1 --no-default-features --features "${feature}" | |
done | |
coverage: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install cargo-tarpaulin --version 0.32.1 --locked | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo tarpaulin --out xml | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
showcase: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
go-version: ['go:current'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ fromJson(env.GHA_GO_VERSIONS)[matrix.go-version] }} | |
cache-dependency-path: | | |
generator/go.sum | |
- run: | | |
cargo test --features run-showcase-tests -p integration-tests | |
docs: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
cargo install mdbook | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo doc --workspace | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
- run: cargo doc --package google-cloud-gax | |
env: | |
RUSTDOCFLAGS: "-D warnings" | |
- run: mdbook build guide | |
- run: mdbook test guide | |
- name: Upload user guide | |
id: deployment | |
uses: actions/upload-pages-artifact@v3 # or specific "vX.X.X" version tag for this action | |
with: | |
path: guide/book/ | |
deploy: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-24.04 | |
permissions: | |
# to deploy to Pages | |
pages: write | |
# to verify the deployment originates from an appropriate source | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: docs | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
lint: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo | |
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add clippy rustfmt | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- run: cargo clippy --workspace --all-targets --profile=test -- --deny warnings | |
- run: cargo fmt | |
- run: git diff --exit-code | |
regenerate: | |
# Verifies the generated code has not been tampered with. Or maybe that the | |
# code requires no tampering. | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
rust-version: ['rust:current'] | |
go-version: ['go:current'] | |
steps: | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/sidekick | |
key: ${{ github.job }}-${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
- uses: actions/checkout@v4 | |
- name: Setup Rust ${{ matrix.rust-version }} | |
run: | | |
set -e | |
rustup toolchain install ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup default ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }} | |
rustup component add rustfmt | |
- name: Display Cargo version | |
run: cargo version | |
- name: Display rustc version | |
run: rustup show active-toolchain -v | |
- name: Setup Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ fromJson(env.GHA_GO_VERSIONS)[matrix.go-version] }} | |
cache-dependency-path: | | |
generator/go.sum | |
- name: Install protoc | |
run: | | |
set -e | |
curl -fSSL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protoc-28.3-linux-x86_64.zip | |
cd /usr/local | |
sudo unzip -x /tmp/protoc.zip | |
protoc --version | |
- name: Regenerate all the code | |
working-directory: generator | |
run: go run ./cmd/sidekick refreshall -project-root .. | |
- run: cargo fmt | |
# If there is any difference between the generated code and the | |
# committed code that is an error. All the inputs should be pinned, | |
# including the generator version and the googleapis SHA. | |
- run: git diff --exit-code |