Skip to content

Commit

Permalink
bzlmod: Verify that the lockfile is platform-independent (#1617)
Browse files Browse the repository at this point in the history
By committing a single lockfile and running CI with
`--lockfile_mode=error`, we can ensure that the same lockfile works
across OSes and architectures.

Since the lockfile can get pretty large, we exclude it from the release
archive and hence also don't check the lockfile in the BCR presubmit.
  • Loading branch information
fmeum authored Aug 27, 2023
1 parent 553c8fb commit 38d1fa7
Show file tree
Hide file tree
Showing 6 changed files with 1,581 additions and 5 deletions.
13 changes: 11 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ tasks:
- bazel run //:gazelle -- update pkg
- bazel run //:gazelle -- pkg
build_flags:
- "--allow_yanked_versions=all"
# Verify that the committed lockfile is platform-independent.
# In case of expected changes, regenerate the lockfile with
# `bazel mod graph`, which evaluates all module extensions.
# Note: `go_sdk`s *is* platform-dependent since it registers the first
# host-compatible SDK, but the result only differs if there is also a
# matching SDK with manual goos/goarch set, which isn't the case in CI.
# TODO: Make this more realistic after
# https://github.com/bazelbuild/bazel/issues/19154.
- "--lockfile_mode=error"
test_flags:
- "--allow_yanked_versions=all"
# See above.
- "--lockfile_mode=error"
build_targets:
- "//..."
- "//:gazelle"
Expand Down
2 changes: 0 additions & 2 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ bcr_test_module:
run_test_module:
name: Run test module
platform: ${{ platform }}
build_flags:
- --experimental_isolated_extension_usages
shell_commands:
# Regenerate the BUILD file for the test module using Gazelle.
- rm pkg/BUILD.bazel
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitattributes export-ignore
# The lockfile is not used by downstream projects and tends to be large.
tests/bcr/MODULE.bazel.lock export-ignore
1 change: 1 addition & 0 deletions tests/bcr/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
common --enable_bzlmod
common --experimental_isolated_extension_usages
common --lockfile_mode=update
2 changes: 1 addition & 1 deletion tests/bcr/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.1
6.3.2
Loading

0 comments on commit 38d1fa7

Please sign in to comment.