Skip to content

Commit b346aea

Browse files
locking: enforce Bzlmod lockfile consistency (#89)
add reusable lockfile check workflow track MODULE.bazel.lock (remove from .gitignore) enforce --lockfile_mode=error in CI and scripts Addresses eclipse-score/score#2628 Co-authored-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com>
1 parent 682c9f5 commit b346aea

9 files changed

Lines changed: 7450 additions & 18 deletions

File tree

.github/workflows/bzlmod-lock.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
name: Bzlmod Lockfile Check
14+
permissions:
15+
contents: read
16+
on:
17+
pull_request:
18+
types: [opened, reopened, synchronize]
19+
merge_group:
20+
types: [checks_requested]
21+
push:
22+
branches:
23+
- main
24+
jobs:
25+
bzlmod-lock:
26+
uses: eclipse-score/cicd-workflows/.github/workflows/bzlmod-lock-check.yml@main
27+
with:
28+
working-directory: .

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
run: bazel mod tidy
3737

3838
- name: Build all workspace targets
39-
run: bazel build --config=x86_64-linux //...
39+
run: bazel build --lockfile_mode=error --config=x86_64-linux //...
4040

4141
- name: Run all workspace tests
42-
run: bazel test --config=x86_64-linux //...
42+
run: bazel test --lockfile_mode=error --config=x86_64-linux //...
4343

4444
- name: Lint rust code (with clippy)
45-
run: bazel build --config=lint-rust //...
45+
run: bazel build --lockfile_mode=error --config=lint-rust //...

.github/workflows/copyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
copyright-check:
2222
uses: eclipse-score/cicd-workflows/.github/workflows/copyright.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0
2323
with:
24-
bazel-target: "run //:copyright.check"
24+
bazel-target: "run --lockfile_mode=error //:copyright.check"

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ jobs:
3939

4040
with:
4141
# the bazel-target depends on your repo specific docs_targets configuration (e.g. "suffix")
42-
bazel-target: "//:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
42+
bazel-target: "--lockfile_mode=error //:docs -- --github_user=${{ github.repository_owner }} --github_repo=${{ github.event.repository.name }}"
4343
retention-days: 3

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
formatting-check:
2424
uses: eclipse-score/cicd-workflows/.github/workflows/format.yml@c1c90b1a82a1fab0fc202979dde6686b2162d5a8 # v0.0.0
2525
with:
26-
bazel-target: "test //:format.check" # optional, this is the default
26+
bazel-target: "test --lockfile_mode=error //:format.check" # optional, this is the default

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ jobs:
6060
6161
- name: Build via Bazel
6262
run: |
63-
echo "Running: bazel build //..."
64-
bazel build //...
63+
echo "Running: bazel build --lockfile_mode=error //..."
64+
bazel build --lockfile_mode=error //...
6565
6666
- name: Run Unit Tests via Bazel
6767
run: |
68-
echo "Running: bazel test //:unit_tests"
69-
bazel test //:unit_tests
68+
echo "Running: bazel test --lockfile_mode=error //:unit_tests"
69+
bazel test --lockfile_mode=error //:unit_tests
7070
7171
- name: Run Unit Test with Coverage for Rust
7272
run: |
7373
# Run tests
74-
bazel coverage //:unit_tests \
74+
bazel coverage --lockfile_mode=error //:unit_tests \
7575
--collect_code_coverage \
7676
--combined_report=lcov \
7777
--experimental_generate_llvm_lcov \

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
# Bazel
3636
bazel-*
37-
MODULE.bazel.lock
3837
user.bazelrc
3938

4039
# Ruff

MODULE.bazel.lock

Lines changed: 7405 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pre_commit.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
1919

2020
buildifier -r $SCRIPT_DIR
2121
bazelisk mod tidy
22-
bazelisk run //:format.fix
23-
bazelisk run //:format.check_Rust_with_rustfmt
24-
bazelisk run //:copyright.check
25-
bazelisk build --config=lint-rust //...
26-
bazelisk build --config=x86_64-linux //...
27-
bazelisk test --config=x86_64-linux //...
22+
bazelisk run --lockfile_mode=error //:format.fix
23+
bazelisk run --lockfile_mode=error //:format.check_Rust_with_rustfmt
24+
bazelisk run --lockfile_mode=error //:copyright.check
25+
bazelisk build --lockfile_mode=error --config=lint-rust //...
26+
bazelisk build --lockfile_mode=error --config=x86_64-linux //...
27+
bazelisk test --lockfile_mode=error --config=x86_64-linux //...

0 commit comments

Comments
 (0)