-
Notifications
You must be signed in to change notification settings - Fork 131
170 lines (165 loc) · 6.12 KB
/
sdk.yaml
File metadata and controls
170 lines (165 loc) · 6.12 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
# 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.95" }'
GHA_GO_VERSIONS: '{ "go:current": "1.25.6" }'
# 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'
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@v5 # 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@v5