Skip to content

Commit 31fa06f

Browse files
authored
fix: upgrade the generator to protobuf 31 and bazel 7.7.1, and update templates to fix system test (googleapis#7943)
* chore: upgrade the generator to protobuf 31 and bazel 7.7.1 * run generator tests * fix generator test * run generator tests * chore: fix generator issue * Update generator-tests.yaml * chore: update dependencies * chore: update sinon to non-regressed types * fix original system test issue
1 parent efa3e04 commit 31fa06f

109 files changed

Lines changed: 255 additions & 317 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/generator-tests.yaml

Lines changed: 4 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -41,136 +41,10 @@ jobs:
4141
run: npm install
4242
working-directory: core/generator/gapic-generator-typescript
4343

44-
- name: Run bazel build
45-
working-directory: core/generator/gapic-generator-typescript
46-
run: bazelisk build --noremote_accept_cached '//...'
47-
48-
- name: Run bazel test
49-
working-directory: core/generator/gapic-generator-typescript
50-
run: bazelisk test --test_output=errors --noremote_accept_cached //...
51-
52-
- name: Verify error conformance
44+
- name: Strip local GCC 15 flags for CI
5345
working-directory: core/generator/gapic-generator-typescript
54-
run: |
55-
curl -sSL https://github.com/googleapis/gapic-config-validator/releases/download/v0.6.0/gapic-config-validator-0.6.0-linux-amd64.tar.gz > config-validator.tar.gz
56-
tar xzf config-validator.tar.gz --no-same-owner
57-
chmod +x gapic-error-conformance
58-
chmod +x bazel-bin/protoc_plugin_/protoc_plugin
59-
./gapic-error-conformance -plugin="bazel-bin/protoc_plugin_/protoc_plugin"
46+
run: sed -i '/--gsframe/d' .bazelrc
6047

61-
- name: Prepare baseline artifacts
62-
working-directory: core/generator/gapic-generator-typescript
63-
run: |
64-
mkdir -p ~/artifacts
65-
cp bazel-testlogs/unit_tests/test.outputs/outputs.zip ~/artifacts/
66-
bazelisk run -- @pnpm//:pnpm --dir $PWD install
67-
tar cfz ~/artifacts/node_modules.tar.gz node_modules
68-
69-
- name: Save artifacts
70-
uses: actions/upload-artifact@v5
71-
with:
72-
name: artifacts
73-
path: ~/artifacts
74-
75-
- name: Test generated libraries
76-
working-directory: core/generator/gapic-generator-typescript
77-
run: |
78-
set -ex
79-
unzip ~/artifacts/outputs.zip -d library
80-
for lib in showcase kms translate monitoring dlp texttospeech showcase-legacy compute logging bigquery-v2 redis retail; do
81-
echo "--- Testing library $lib ---"
82-
cd library/.test-out-$lib
83-
npm install
84-
npm test
85-
npm run fix
86-
rm -rf build
87-
npm run compile
88-
npm run system-test
89-
npm run docs
90-
cd ../..
91-
done
92-
93-
- name: Test generated ESM libraries
94-
working-directory: core/generator/gapic-generator-typescript
95-
run: |
96-
set -ex
97-
for lib in showcase kms translate monitoring dlp texttospeech showcase-legacy compute logging bigquery-v2 redis retail; do
98-
echo "--- Testing ESM library $lib ---"
99-
cd library/.test-out-$lib-esm
100-
npm install
101-
npm test
102-
npm run fix
103-
rm -rf build
104-
npm run compile
105-
npm run system-test
106-
cd ../..
107-
done
108-
- name: Test combined library (Speech)
109-
if: steps.generator-changes.outputs.changes == 'true'
110-
env:
111-
TEST_ENV_DESTINATION_PATH: generator/gapic-generator-typescript/test-fixtures/google-cloud-speech
112-
run: generator/gapic-generator-typescript/rules_typescript_gapic/combine_script.sh generator/gapic-generator-typescript/test-fixtures/google-cloud-speech-nodejs v1 "" "" generator/gapic-generator-typescript/node_modules/gapic-tools/build/src/compileProtos.js generator/gapic-generator-typescript/node_modules/gapic-node-processing/build/src/cli.js ""
113-
114-
- name: Run tests for combined library (Speech)
115-
if: steps.generator-changes.outputs.changes == 'true'
116-
run: |
117-
set -ex
118-
cd generator/gapic-generator-typescript/test-fixtures/google-cloud-speech
119-
npm install
120-
npm test
121-
npm run system-test
122-
123-
- name: Test combined library (Tasks)
124-
if: steps.generator-changes.outputs.changes == 'true'
125-
env:
126-
TEST_ENV_DESTINATION_PATH: generator/gapic-generator-typescript/test-fixtures/google-cloud-tasks
127-
run: generator/gapic-generator-typescript/rules_typescript_gapic/combine_script.sh generator/gapic-generator-typescript/test-fixtures/google-cloud-tasks-nodejs v2 "" "" generator/gapic-generator-typescript/node_modules/gapic-tools/build/src/compileProtos.js generator/gapic-generator-typescript/node_modules/gapic-node-processing/build/src/cli.js ""
128-
129-
- name: Run tests for combined library (Tasks)
130-
if: steps.generator-changes.outputs.changes == 'true'
131-
run: |
132-
set -ex
133-
cd generator/gapic-generator-typescript/test-fixtures/google-cloud-tasks
134-
npm install
135-
npm test
136-
npm run system-test
137-
138-
continuous:
139-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
140-
runs-on: ubuntu-latest
141-
container: gcr.io/gapic-images/googleapis:20250404
142-
steps:
143-
- uses: actions/checkout@v5
144-
with:
145-
fetch-depth: 2 # Need at least two commits for HEAD~..
146-
147-
- name: Mark repo as safe for git
148-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
149-
150-
- name: Compute GIT_DIFF_ARG
151-
id: diff-logic
152-
run: |
153-
# For continuous build, we want to know the difference in the last
154-
# commit. This assumes we use squash commit when merging PRs.
155-
git fetch origin main --deepen=1
156-
echo "GIT_DIFF_ARG=HEAD~.." >> $GITHUB_ENV
157-
158-
- name: Cache Bazel files
159-
id: cache-bazel
160-
uses: actions/cache@v5
161-
with:
162-
path: ~/.cache/bazel
163-
key: ${{ runner.os }}-googleapis-20250422-${{ secrets.CACHE_VERSION }}
164-
165-
- name: Setup Node.js
166-
uses: actions/setup-node@v6
167-
with:
168-
node-version: 18.x
169-
170-
- name: Install Node dependencies with npm
171-
run: npm install
172-
working-directory: core/generator/gapic-generator-typescript
173-
17448
- name: Run bazel build
17549
working-directory: core/generator/gapic-generator-typescript
17650
run: bazelisk build --noremote_accept_cached '//...'
@@ -235,7 +109,7 @@ jobs:
235109
npm run system-test
236110
cd ../..
237111
done
238-
- name: Test combined library (Speech)
112+
- name: Test combined library (Speech)
239113
if: steps.generator-changes.outputs.changes == 'true'
240114
env:
241115
TEST_ENV_DESTINATION_PATH: generator/gapic-generator-typescript/test-fixtures/google-cloud-speech
@@ -263,4 +137,4 @@ jobs:
263137
cd generator/gapic-generator-typescript/test-fixtures/google-cloud-tasks
264138
npm install
265139
npm test
266-
npm run system-test
140+
npm run system-test
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# See https://github.com/bazelbuild/bazelisk
2-
USE_BAZEL_VERSION=6.3.0
2+
USE_BAZEL_VERSION=7.7.1
Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
# Copied from https://github.com/googleapis/googleapis/blob/master/.bazelrc
2-
# Need because absl library requires C++14 while the Bazel default is C++0x
1+
common --noenable_bzlmod
32

3+
# --- C++ Toolchain & Compilation ---
4+
# Force C++17 for Protobuf 31 / gRPC 1.74 compatibility
5+
build --cxxopt='-std=c++17'
6+
build --host_cxxopt='-std=c++17'
7+
build --action_env=BAZEL_CXXOPTS="-std=c++17"
8+
build --copt='-Wa,--gsframe=no'
9+
build --host_copt='-Wa,--gsframe=no'
10+
11+
12+
# --- Java Toolchain & Runtime (JDK 21) ---
13+
build --java_language_version=21
14+
build --java_runtime_version=remotejdk_21
15+
build --javacopt="-Xep:ImpossibleNullComparison:OFF"
16+
17+
# --- Protobuf & gRPC ---
18+
build --proto_toolchain_for_java="@com_google_protobuf//:java_toolchain"
19+
build --define=grpc_no_ares=true
420
# To make proto_library rules to include source info in the descriptor
521
build --protocopt=--include_source_info
622
build --protocopt=--experimental_allow_proto3_optional
7-
# New boringssl requires C++14
8-
build --repo_env=BAZEL_CXXOPTS="-std=c++14"
923

24+
# --- Test Environment Fixes ---
25+
test --jvmopt="-Djava.security.manager=allow"
26+
test --jvmopt="--add-opens=java.base/java.lang=ALL-UNNAMED"
1027

11-
# This is to avoid JVM SIGBUS crashes on highly parallel builds,
12-
# see https://github.com/bazelbuild/bazel/issues/3236 for more details
13-
build --enable_platform_specific_config
28+
# --- Linux Specific Config ---
1429
build:linux --sandbox_tmpfs_path=/tmp
30+
common:linux --experimental_convenience_symlinks=ignore
1531

16-
build --cxxopt=-std=c++17
17-
build --host_cxxopt=-std=c++17
18-
19-
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
20-
21-
# Between Bazel 6.0 and 6.3, you need all of this, to avoid discarding the analysis cache:
22-
build --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
23-
fetch --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
24-
query --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
32+
# --- Performance & Analysis ---
33+
# Bazel 6.4+: 'common' applies to all commands that support the flag
34+
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig

core/generator/gapic-generator-typescript/WORKSPACE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ workspace(
22
# How this workspace would be referenced with absolute labels from another workspace
33
name = "gapic_generator_typescript",
44
)
5+
56

67
load("//:repositories.bzl", "gapic_generator_typescript_repositories", "NODE_VERSION")
78
gapic_generator_typescript_repositories()
89

10+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
11+
12+
http_archive(
13+
name = "rules_java",
14+
urls = [
15+
"https://github.com/bazelbuild/rules_java/releases/download/7.11.1/rules_java-7.11.1.tar.gz",
16+
],
17+
sha256 = "6f3ce0e9fba979a844faba2d60467843fbf5191d8ca61fa3d2ea17655b56bb8c",
18+
)
19+
920
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
1021
protobuf_deps()
1122

23+
24+
1225
load("@rules_python//python:repositories.bzl", "py_repositories")
1326
py_repositories()
1427

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": "./node_modules/gts"
2+
"extends": "./node_modules/gts",
3+
"root": true
34
}

core/generator/gapic-generator-typescript/baselines/asset-esm/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"@babel/preset-typescript": "^7.28.5",
8383
"@types/mocha": "^10.0.10",
8484
"@types/node": "^22.18.12",
85-
"@types/sinon": "^17.0.4",
85+
"@types/sinon": "^20.0.0",
8686
"babel-plugin-replace-import-extension": "^1.1.5",
8787
"c8": "^10.1.3",
8888
"gapic-tools": "^1.0.3",
@@ -92,9 +92,9 @@
9292
"jsdoc-fresh": "^5.0.2",
9393
"long": "^5.3.2",
9494
"mocha": "^11.7.4",
95-
"pack-n-play": "^4.2.1",
9695
"typescript": "5.8.3",
97-
"sinon": "^21.0.0",
96+
"pack-n-play": "^4.2.1",
97+
"sinon": "^20.0.0",
9898
"ts-loader": "^8.4.0",
9999
"webpack": "^5.102.1",
100100
"webpack-cli": "^6.0.1"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": "./node_modules/gts"
2+
"extends": "./node_modules/gts",
3+
"root": true
34
}

core/generator/gapic-generator-typescript/baselines/asset/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"devDependencies": {
4141
"@types/mocha": "^10.0.10",
4242
"@types/node": "^22.18.12",
43-
"@types/sinon": "^17.0.4",
43+
"@types/sinon": "^20.0.0",
4444
"c8": "^10.1.3",
4545
"gapic-tools": "^1.0.3",
4646
"gts": "^6.0.2",
@@ -50,7 +50,7 @@
5050
"mocha": "^11.7.4",
5151
"pack-n-play": "^4.2.1",
5252
"typescript": "5.8.3",
53-
"sinon": "^21.0.0"
53+
"sinon": "^20.0.0"
5454
},
5555
"engines": {
5656
"node": ">=v18"

core/generator/gapic-generator-typescript/baselines/asset/system-test/install.ts.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('📦 pack-n-play test', () => {
4040
packageDir: process.cwd(),
4141
sample: {
4242
description: 'JavaScript user can use the library',
43-
ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString()
43+
cjs: readFileSync('./system-test/fixtures/sample/src/index.js').toString()
4444
}
4545
};
4646
await packNTest(options);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": "./node_modules/gts"
2+
"extends": "./node_modules/gts",
3+
"root": true
34
}

0 commit comments

Comments
 (0)