test(pubsub): speed up testing on macOS #12049
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, 'release-*'] | |
| pull_request: | |
| branches: [main, 'release-*'] | |
| release: | |
| types: [published] | |
| env: | |
| GHA_RUST_VERSIONS: '{ "rust:current": "1.94" }' | |
| GHA_GO_VERSIONS: '{ "go:current": "1.25.6" }' | |
| # Define the unstable flags once | |
| UNSTABLE_CFGS: &unstable_cfgs '--cfg google_cloud_unstable_tracing --cfg google_cloud_unstable_trust_boundaries --cfg google_cloud_unstable_storage_bidi --cfg google_cloud_unstable_grpc_server_streaming' | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: ['macos-14', 'windows-2025'] | |
| rust-version: ['rust:current'] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo | |
| key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
| # TODO(#3887) - restore the cache | |
| if: matrix.os != 'macos-14' | |
| - 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: Testing crates with OS variations | |
| # Only these crates have code that depends on the OS. | |
| # The rest of the code is tested in Google Cloud build | |
| run: cargo test --profile=ci --package google-cloud-auth --package user-guide-samples | |
| # A quick check on changes to the major version of some critical crates. | |
| # Can be disabled if it returns a false positive. | |
| semver-checks: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| matrix: | |
| rust-version: ['rust:current'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo | |
| key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }} | |
| - name: Check for major breaks in key libraries | |
| # TODO(#3265) - replace with a standard tool or a program in Go or Rust. | |
| run: | | |
| set -e | |
| if [[ '${{ contains(github.event.pull_request.labels.*.name, 'rust: no-semver-checks') }}' == 'true' ]]; then | |
| exit 0 | |
| fi | |
| dirs=( | |
| src/wkt | |
| src/gax | |
| src/lro | |
| src/auth | |
| src/generated/cloud/location | |
| src/generated/iam/v1 | |
| src/generated/longrunning | |
| ) | |
| git fetch origin main | |
| cat >major-break.awk <<'_EOF_' | |
| function v(s) { | |
| s = substr(s, 2, length(s)-2); | |
| return s | |
| } | |
| /^\+version/ { new = v($2) } | |
| /^\-version/ { old = v($2) } | |
| END { | |
| if (new == "" || old == "") { | |
| exit 1 | |
| } | |
| split(old, a, ".") | |
| split(new, b, ".") | |
| if (a[1] != b[1]) { | |
| printf("major version mismatch: new=%s old=%s\n", new, old) | |
| exit 0 | |
| } | |
| if (a[1] == "0" && b[1] == "0" && a[2] != b[2]) { | |
| printf("minor version mismatch on 0.x series: new=%s old=%s\n", new, old) | |
| exit 0 | |
| } | |
| printf("major versions match: old=%s, new=%s\n", old, new) | |
| exit 1 | |
| } | |
| _EOF_ | |
| set +e | |
| for name in "${dirs[@]}"; do | |
| if git diff origin/main..HEAD -- "${name}/Cargo.toml" | awk -F' = ' -f major-break.awk; then | |
| cat <<_EOF_ | |
| The major version (or minor for a 0.x series) of a critical package | |
| (located in ${name}) is changing. The types from this package are part | |
| of the public API for many other packages. You need to bump the | |
| version of all downstream packages and then disable this check using | |
| the 'rust: no-semver-checks' github label. | |
| _EOF_ | |
| exit 1 | |
| fi | |
| done | |
| guide: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| matrix: | |
| rust-version: ['rust:current'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/cache@v5 | |
| 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 --version ^0.5 --locked | |
| - run: mdbook build guide | |
| - run: mdbook test guide | |
| - name: Upload user guide | |
| if: matrix.rust-version == 'rust:current' | |
| id: deployment | |
| uses: actions/upload-pages-artifact@v4 # 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: guide | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |