chore(gapic-generator-typescript): remove bazel dependency from build#7965
Open
GautamSharda wants to merge 18 commits intomainfrom
Open
chore(gapic-generator-typescript): remove bazel dependency from build#7965GautamSharda wants to merge 18 commits intomainfrom
GautamSharda wants to merge 18 commits intomainfrom
Conversation
This change completely removes the Bazel dependency from the gapic-generator-typescript project. All Bazel configuration files have been deleted and package.json scripts have been updated to use the standard TypeScript compiler (tsc) directly. Bazel was originally introduced to export build rules for the googleapis monorepo. However, following the consolidation of the generator into google-cloud-node/core, Bazel is no longer necessary and adds significant overhead (e.g., 4+ minute installations via npm run compile). Since tsc provides all the compilation functionality needed natively, stripping Bazel simplifies the toolchain and significantly speeds up CI pipelines without losing capabilities. To verify this change does not break functionality, the project was locally compiled successfully using `npx tsc -p .` in under 7 seconds. The test scripts were also run, and the overall Librarian CI workflow has been verified to pass with these changes, confirming that the generator builds and executes correctly without Bazel. For googleapis/librarian#4593
This change completely removes the Bazel dependency from the gapic-generator-typescript project. All Bazel configuration files have been deleted and package.json scripts have been updated to use the standard TypeScript compiler (tsc) directly. Bazel was originally introduced to export build rules for the googleapis monorepo. However, following the consolidation of the generator into google-cloud-node/core, Bazel is no longer necessary and adds significant overhead (e.g., 4+ minute installations via npm run compile). Since tsc provides all the compilation functionality needed natively, stripping Bazel simplifies the toolchain and significantly speeds up CI pipelines without losing capabilities. To verify this change does not break functionality, the project was locally compiled successfully using `npx tsc -p .` in under 7 seconds. The test scripts were also run, and the overall Librarian CI workflow has been verified to pass with these changes, confirming that the generator builds and executes correctly without Bazel. For googleapis/librarian#4593
Since Bazel was completely stripped out of the repository, the generator-tests.yaml workflow was failing because it attempted to strip GCC flags from .bazelrc and run bazelisk commands. This commit updates the CI workflow to: - Use standard 'npm run compile' and 'npm test' instead of bazelisk. - Reference the built protoc-plugin.js path directly instead of bazel-bin. - Manually zip the generated .test-out directories instead of relying on Bazel's testlogs.
When running tests locally or in CI without Bazel, the generated TypeScript entry point (gapic-generator-typescript.js) was losing its executable permissions, causing baseline tests to fail with 'Permission denied'. This commit explicitly invokes the generator with 'node' in the test utility to ensure cross-platform execution without relying on file permissions.
When Bazel was removed, the build step stopped copying the 'templates/' directory to the 'build/' output folder. This caused the generator to fail with ENOENT errors when it tried to locate the Nunjucks templates during code generation. This commit updates the 'npm run compile' script to explicitly copy the templates directory into 'build/' after tsc finishes.
With Bazel removed, the gapic-generator-typescript no longer has
a local, managed version of the `protoc` binary injected via the
environment variable.
When it attempts to find `protoc` in the local file system using
`fs.existsSync('protoc')`, it fails and throws an error. This commit
updates the check to skip `fs.existsSync` if the resolved path is
just the string 'protoc', allowing the generator to correctly defer
to the system PATH where protoc is already installed in CI.
With Bazel removed, the gapic-generator-typescript no longer has a local, managed version of the `protoc` binary. The generator-tests.yaml workflow was failing because it attempted to spawn `protoc` without it being installed in the container environment. This commit updates the CI workflow to download and install protoc v25.3 globally before running the tests.
The gapic-generator-typescript expects the 'PROTOC_PATH' environment variable to point to the protoc binary, or it falls back to looking for 'protoc' in the system PATH. This commit updates generator-tests.yaml to explicitly provide the PROTOC_PATH environment variable to 'npm test' pointing to the newly installed /usr/local/bin/protoc binary, ensuring the tests don't fail with ENOENT when trying to spawn protoc.
When Bazel was removed, the protoc-plugin.js file generated by tsc no longer had executable permissions. When protoc attempted to invoke it via the --plugin flag, it failed with 'program not found or is not executable'. This commit updates the fallback logic in gapic-generator-typescript.ts to prepend 'node ' to the protoc plugin path, ensuring protoc executes it correctly using the Node.js runtime without relying on file permissions.
The gapic-error-conformance binary invoked the protoc-plugin.js
directly, which failed because the generated script no longer has
executable permissions after the removal of Bazel.
This updates the CI workflow to execute the plugin via the Node.js
runtime ('node ...') instead of relying on chmod and the file's
shebang.
When protoc invokes a plugin via the --plugin=name=path flag, it expects 'path' to be an actual executable binary/script. Prepending 'node' to the path caused protoc to fail to find the executable. This commit updates gapic-generator-typescript to explicitly run fs.chmodSync(pluginPath, 0o755) before passing the path to protoc, ensuring the generated script is executable and can use its node shebang.
When protoc compiles proto files that use the experimental Editions feature (like google/showcase/v1beta1/testing.proto), it throws a fatal error unless the --experimental_editions flag is explicitly passed. This commit updates the generator to always pass this flag to protoc, ensuring it doesn't crash when encountering these newer proto files now that we are relying on the system protoc (v25+).
The gapic-error-conformance tool expects an executable binary or script for the -plugin flag and fails with 'no such file or directory' when passed a string like 'node file.js'. This commit reverts the workflow to use chmod +x on the generated plugin script so it can be passed directly to the conformance tool, since we previously updated the typescript code to ensure the script itself is generated with execution permissions.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change removes the Bazel dependency from the gapic-generator-typescript project. All Bazel configuration files have been deleted and package.json scripts have been updated to use the standard TypeScript compiler (tsc) directly.
Bazel was originally introduced to export build rules for the googleapis monorepo. However, following the consolidation of the generator into google-cloud-node/core, Bazel is no longer necessary and adds significant overhead (e.g., 4+ minute installations via npm run compile). Since tsc provides all the compilation functionality needed natively, removing Bazel simplifies the toolchain and speeds up CI pipelines without losing capabilities.
For googleapis/librarian#4593
Fixes b/492949752