Conversation
…ndows tests) - Add Bazel workspace files: MODULE.bazel, .bazelrc, .bazelversion, .bazelignore - Add BUILD.bazel targets for lib/ (ts_project) and all test suites - Unit/lib tests: one jest_test target per spec file, cached independently - System tests: tagged ["manual","system"], run via bazel query to bypass Bazel's wildcard exclusion of manual targets - Windows tests: tagged ["windows"], own jest config with Bazel runfiles rootDir handling; CI jobs install Bazelisk (Windows) and use bazel test - Fix system/dockerfile-analysis Dockerfile fixtures missing from test data - Fix go regression CI job: npx jest -> bazel test //test:unit_go-binaries - Update package.json scripts and circleci config to use Bazel throughout - Add pnpm-lock.yaml required by rules_js npm_translate_lock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Reviewer Guide 🔍
|
- .bazelrc: remove <YOUR_BUCKET> placeholder; remote_cache URL now injected by setup_gcs_cache via $BAZEL_REMOTE_CACHE_BUCKET env var - .circleci/config.yml: pin Bazelisk to v1.20.0 (not "latest"); secure GCS key with mktemp+chmod 600; add $BAZEL_REMOTE_CACHE_BUCKET to setup_gcs_cache; split bazel query and bazel test into separate steps in test_system; remove install_bazelisk/setup_gcs_cache from install job (not persisted to workspace); add setup_gcs_cache to Windows and Go jobs - MODULE.bazel: sync ts_version from 5.4.5 to 5.4.2 to match package.json - package.json: rm -rf dist before cp in prepare to prevent stale nesting - test/BUILD.bazel: document that Windows snapshots must not be updated on Linux Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Background
This PR implements the plan in
.claude/plans/fluffy-hopping-bentley.md: migrate snyk-docker-plugin from plaintsc+ Jest (via npm scripts) to Bazel, using Bzlmod (MODULE.bazel),aspect_rules_js+aspect_rules_ts+aspect_rules_jest, and a GCS bucket for remote cache shared across dev machines and CI.Goals: hermetic builds, per-spec-file test result caching, and a single
bazel test //test/...that replaces the scattered npm/jest invocations.What changed
New Bazel workspace files
.bazelversionMODULE.bazel+MODULE.bazel.lockaspect_rules_js,aspect_rules_ts,aspect_rules_jest,aspect_bazel_lib.bazelrctry-import .bazelrc.localfor per-machine overrides.bazelignorenode_modules,dist,.aspectfrom Bazelpnpm-lock.yamlnpm_translate_lockinrules_jsBUILD.bazel(root)npm_link_all_packages;copy_to_binfortsconfig.jsonandjest.config.jslib/BUILD.bazelts_projectfor the entire library with all production deps declaredtest/BUILD.bazelTest targets in
test/BUILD.bazelUnit / lib tests (
test/lib/,test/unit/) — onejest_testper spec file, untagged, included inbazel test //test/.... Changing one spec reruns only that target.System tests (
test/system/) — onejest_testper spec file, tagged["manual", "system"]:manualkeeps them out of the defaultbazel test //test/...wildcard (they require Docker)systemallows the npm script to enumerate them viabazel query 'attr(tags, "system", //test/...)'— necessary because--test_tag_filters=manualcannot select targets that//test/...already excludes;--build_manual_testsonly affects the build graph, not test collectionWindows tests (
test/windows/) — onejest_testper spec file, tagged["windows"], using a separatecopy_to_bin'dwindows/jest.config.js. The config was updated to computerootDirfromJS_BINARY__RUNFILES(Bazel) orpath.resolve(__dirname, '../..')(plain jest), making it work in both contexts.Fixes discovered during conversion
test/system/dockerfile-analysis/Dockerfile*files were not included in any Bazel data glob; fixed by adding"system/**"(excluding.tsand.snap) to_SHARED_DATAjest_testtarget's snapshot glob is scoped to its own__snapshots__/file to avoid--cifailing on "obsolete snapshots" from other targetsbuild_and_test_latest_go_binary) was usingnpx jest test/unit/go-binaries.spec.tsdirectly; changed tobazel test //test:unit_go-binariespackage.jsonscript changesbuildtscbazel build //lib:libtestjest --ci ...bazel test //test/... --test_tag_filters=-manual,-windowstest:unitjest --ci ... --testPathPattern='test/(lib|unit)/'bazel test //test/... --test_tag_filters=-manual,-windowstest:systemjest --ci ... --testPathPattern='test/system/'bazel test $(bazel query 'attr(tags, "system", //test/...)')test-jest-windowsjest --ci --config test/windows/jest.config.jsbazel test //test/... --test_tag_filters=windowspreparenpm run buildbazel build //lib:lib && cp -rL bazel-bin/lib distCI (
.circleci/config.yml) changesinstall_bazeliskcommand (Linux) andinstall_bazelisk_windowscommand (Windows, downloads.exeinto~/bin, adds to$BASH_ENV)setup_gcs_cachecommand: writes$GCLOUD_SERVICE_KEYto/tmp/gcs-bazel-key.jsonand appends--google_credentialsto.bazelrc.localinstall,build,releasejobs: addinstall_bazelisk+setup_gcs_cache; replacenpm run buildwithbazel build //lib:libtest_unitjob: addinstall_bazelisk+setup_gcs_cache; replacenpm run test:unitwithbazel test //test/... --test_tag_filters=-manual,-windowstest_systemjob: addinstall_bazelisk+setup_gcs_cache; replacenpm run test:systemwithbazel test $(bazel query ...) --test_output=errorstest_jest_windows_with_docker/test_jest_windows_no_docker: addinstall_bazelisk_windows; replacenpm run test-jest-windowswithbazel test //test/... --test_tag_filters=windowsbuild_and_test_latest_go_binary: addinstall_bazelisk; replacenpx jestwithbazel test //test:unit_go-binariesOther file changes
jest.config.js: addedrootDircomputation fromJS_BINARY__RUNFILESso Jest finds test files from the workspace root when running under Bazeltsconfig.json: commented out"outDir": "./dist"— Bazel'sts_projectcontrols output location;outDirin tsconfig would conflict.gitignore: addedbazel-*,.aspect,.bazelrc.localGCS bucket setup (prerequisite, done outside this PR)
gs://snyk-docker-plugin-bazel-cacheStorage Object Adminon the bucketGCLOUD_SERVICE_KEYgcloud auth application-default login(picked up by--google_default_credentials=true)Test plan
npm run test:unit— 47 unit/lib targets, all passnpm run test:system— 50 system targets run; passes requiring Docker pass in CI (setup_remote_docker), fixture-only tests pass locallynpm run test-jest-windows— 5 windows targets, run on Windows CI executornpm run build—bazel build //lib:libcompiles library🤖 Generated with Claude Code