8000 fix(bzlmod): use --lockfile_mode=update and add a separate job for lo… · keith/rules_python@cd4b9c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd4b9c4

Browse files
authored
fix(bzlmod): use --lockfile_mode=update and add a separate job for lockfile testing (bazel-contrib#2154)
We add two jobs for the bzlmod example to test that lockfile is platform independent. Then we also add a .bazelversion file to the example so that the lockfile is stable. Finally we add a pre-commit hook which may help in keeping the lockfile up-to-date. Fixes bazel-contrib#2148
1 parent a507673 commit cd4b9c4

File tree

5 files changed

+36
-10
lines changed

5 files changed

+36
-10
lines changed

.bazelci/presubmit.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ buildifier:
6565
.reusable_build_test_all: &reusable_build_test_all
6666
build_targets: ["..."]
6767
test_targets: ["..."]
68+
.lockfile_mode_error: &lockfile_mode_error
69+
# For testing lockfile support
70+
skip_in_bazel_downstream_pipeline: "Lockfile depends on the bazel version"
71+
build_flags:
72+
- "--lockfile_mode=error"
73+
test_flags:
74+
- "--lockfile_mode=error"
75+
coverage_flags:
76+
- "--lockfile_mode=error"
6877
.coverage_targets_example_bzlmod: &coverage_targets_example_bzlmod
6978
coverage_targets: ["..."]
7079
.coverage_targets_example_bzlmod_build_file_generation: &coverage_targets_example_bzlmod_build_file_generation
@@ -230,12 +239,6 @@ tasks:
230239
name: "examples/bzlmod: Ubuntu, minimum Bazel"
231240
working_directory: examples/bzlmod
232241
platform: ubuntu2004
233-
build_flags:
234-
- "--lockfile_mode=update"
235-
test_flags:
236-
- "--lockfile_mode=update"
237-
coverage_flags:
238-
- "--lockfile_mode=update"
239242
integration_test_bzlmod_ubuntu:
240243
<<: *reusable_build_test_all
241244
<<: *coverage_targets_example_bzlmod
@@ -260,6 +263,20 @@ tasks:
260263
name: "examples/bzlmod: Windows"
261264
working_directory: examples/bzlmod
262265
platform: windows
266+
integration_test_bzlmod_ubuntu_lockfile:
267+
<<: *reusable_build_test_all
268+
<<: *coverage_targets_example_bzlmod
269+
<<: *lockfile_mode_error
270+
name: "examples/bzlmod: Ubuntu with lockfile"
271+
working_directory: examples/bzlmod
272+
platform: ubuntu2004
273+
integration_test_bzlmod_macos_lockfile:
274+
<<: *reusable_build_test_all
275+
<<: *coverage_targets_example_bzlmod
276+
<<: *lockfile_mode_error
277+
name: "examples/bzlmod: macOS with lockfile"
278+
working_directory: examples/bzlmod
279+
platform: macos
263280

264281
integration_test_bzlmod_generate_build_file_generation_ubuntu_min:
265282
<<: *minimum_supported_version

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ repos:
4545
entry: bazel run @rules_bazel_integration_test//tools:update_deleted_packages
4646
files: ^((examples|tests)/.*/(MODULE.bazel|WORKSPACE|WORKSPACE.bzlmod|BUILD.bazel)|.bazelrc)$
4747
pass_filenames: false
48+
- id: update-bzlmod-lockfiles
49+
name: Update bzlmod lockfiles
50+
language: script
51+
entry: ./tools/private/update_bzlmod_lockfiles.sh
52+
files: ^python/
53+
pass_filenames: false

examples/bzlmod/.bazelrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
common --enable_bzlmod
2-
3-
# Update the lockfile by running:
4-
# bazel mod deps --lockfile_mode=update
5-
common --lockfile_mode=error
2+
common --lockfile_mode=update
63

74
coverage --java_runtime_version=remotejdk_11
85

examples/bzlmod/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.3.1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
cd "$(dirname "$0")"/../../examples/bzlmod
5+
bazel mod deps

0 commit comments

Comments
 (0)
0