Skip to content

feat(spanner): enable built-in metrics and support custom MeterProvider #16742

feat(spanner): enable built-in metrics and support custom MeterProvider

feat(spanner): enable built-in metrics and support custom MeterProvider #16742

Workflow file for this run

# 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 # zizmor: ignore[excessive-permissions]
on:
push:
branches: [main, grpc_rust, 'release-*']
pull_request:
branches: [main, grpc_rust, 'release-*']
release:
types: [published]
env:
GHA_RUST_VERSIONS: '{ "rust:current": "1.98" }'
GHA_GO_VERSIONS: '{ "go:current": "1.26.7" }'
# Define the unstable flags once
UNSTABLE_CFGS: &unstable_cfgs '--cfg google_cloud_unstable_trust_boundaries --cfg google_cloud_unstable_storage_bidi --cfg google_cloud_unstable_grpc_server_streaming --cfg google_cloud_unstable_tracing'
jobs:
build:
if: github.repository == 'googleapis/google-cloud-rust'
strategy:
matrix:
os: ['macos-14', 'windows-2025']
rust-version: ['rust:current']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # rachet:actions/cache@v5 # zizmor: ignore[cache-poisoning] - bypassed during release runs
with:
path: |
~/.cargo
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }}
if: matrix.os != 'macos-14' && github.event_name != 'release'
- name: Setup Rust ${{ matrix.rust-version }}
env:
RUST_VERSION: ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }}
run: |
rustup toolchain install ${RUST_VERSION}
rustup default ${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
# Ensure that the library version and the librarian.yaml version align.
check-versions:
if: github.repository == 'googleapis/google-cloud-rust'
runs-on: ubuntu-24.04
strategy:
matrix:
rust-version: ['rust:current']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Setup Rust ${{ matrix.rust-version }}
env:
RUST_VERSION: ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }}
run: |
rustup toolchain install ${RUST_VERSION}
rustup default ${RUST_VERSION}
- name: Verify library versions
run: cargo run --package check-versions
# A quick check on changes to the major version of some critical crates.
# Can be disabled if it returns a false positive.
semver-checks:
if: github.repository == 'googleapis/google-cloud-rust'
runs-on: ubuntu-24.04
strategy:
matrix:
rust-version: ['rust:current']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # ratchet:actions/cache@v5 # zizmor: ignore[cache-poisoning] - bypassed during release runs
with:
path: |
~/.cargo
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }}
if: github.event_name != 'release'
- name: Check for major breaks in key libraries
# TODO(#3265) - replace with a standard tool or a program in Go or Rust.
env:
BASE_REF: ${{ github.base_ref || github.ref_name }}
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 "${BASE_REF}"
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/"${BASE_REF}"..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:
if: github.repository == 'googleapis/google-cloud-rust'
runs-on: ubuntu-24.04
strategy:
matrix:
rust-version: ['rust:current']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # ratchet:actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # ratchet:actions/cache@v5 # zizmor: ignore[cache-poisoning] - bypassed during release runs
with:
path: |
~/.cargo
key: ${{ github.job }}-${{ runner.os }}-${{ matrix.rust-version }}-cargo-${{ hashFiles('Cargo.lock', '.github/workflows/sdk.yaml') }}
# Disable caching completely during release runs. This gives us peace
# of mind w.r.t. cache poisoning attacks that install nefarious
# versions of `mdbook` or otherwise create evil instances of the
# user guide.
if: github.event_name != 'release'
- name: Setup Rust ${{ matrix.rust-version }}
env:
RUST_VERSION: ${{ fromJson(env.GHA_RUST_VERSIONS)[matrix.rust-version] }}
run: |
set -e
rustup toolchain install ${RUST_VERSION}
rustup default ${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@fc324d3547104276b827a68afc52ff2a11cc49c9 # ratchet:actions/upload-pages-artifact@v5
with:
path: guide/book/
deploy:
if: github.repository == 'googleapis/google-cloud-rust' && 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@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # ratchet:actions/deploy-pages@v5