Skip to content

Commit

Permalink
pw_presubmit: Enable strict Bazel lockfile checks
Browse files Browse the repository at this point in the history
Enables `--lockfile_mode=error` for Bazel actions in Pigweed's presubmit
actions to ensure that dirty lockfiles are not checked in.

Change-Id: Ia692c4c027530137e3aa34cd056e62f1fec044ec
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/234056
Presubmit-Verified: CQ Bot Account <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Ted Pudlik <[email protected]>
Pigweed-Auto-Submit: Armando Montanez <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
armandomontanez authored and CQ Bot Account committed Sep 5, 2024
1 parent 4816267 commit 02e9f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pw_presubmit/py/pw_presubmit/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def bazel(
ctx: PresubmitContext,
cmd: str,
*args: str,
strict_module_lockfile: bool = False,
use_remote_cache: bool = False,
stdout: TextIO | None = None,
**kwargs,
Expand All @@ -93,6 +94,10 @@ def bazel(
if ctx.continue_after_build_error:
keep_going.append('--keep_going')

strict_lockfile: list[str] = []
if strict_module_lockfile:
strict_lockfile.append('--lockfile_mode=error')

remote_cache: list[str] = []
if use_remote_cache and ctx.luci:
remote_cache.append('--config=remote_cache')
Expand Down Expand Up @@ -128,6 +133,7 @@ def bazel(
f'--symlink_prefix={ctx.output_dir / "bazel-"}',
*num_jobs,
*keep_going,
*strict_lockfile,
*remote_cache,
*args,
cwd=ctx.root,
Expand Down
4 changes: 3 additions & 1 deletion pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def add_default_gn_args(self, args):


def build_bazel(*args, **kwargs) -> None:
build.bazel(*args, use_remote_cache=True, **kwargs)
build.bazel(
*args, use_remote_cache=True, strict_module_lockfile=True, **kwargs
)


#
Expand Down

0 comments on commit 02e9f98

Please sign in to comment.