Skip to content

Commit

Permalink
Merge pull request #136 from aherrmann/bzlmod-test
Browse files Browse the repository at this point in the history
chore: enable bzlmod by default
  • Loading branch information
aherrmann authored Nov 26, 2023
2 parents 25cabe3 + c43ed37 commit 6a0a19a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import %workspace%/.bazelrc.flags
# Remote cache configuration.
import %workspace%/.bazelrc.remote

# docs: https://bazel.build/reference/command-line-reference#flag--enable_bzlmod
common --enable_bzlmod

# docs: https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob
common --incompatible_disallow_empty_glob

Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ jobs:
folder: "."
target: "//zig/tests/integration_tests"
exclude:
# Don't test bzlmod with Bazel 5 (not supported)
# rules_bazel_integration_tests requires at least Bazel 6.3.0 with bzlmod enabled.
- bazelversion: 6.0.0
bzlmodEnabled: true
# Only test the latest Bazel version on MacOS (MacOS runners are expensive and slow)
- bazelversion: 6.0.0
os: macos-latest

# Configure a human readable name for each job
name: Test ${{ matrix.target }} in ${{ matrix.folder }} with Bazel ${{ matrix.bazelversion }} and bzlmod ${{ matrix.bzlmodEnabled }} on ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down Expand Up @@ -107,13 +110,18 @@ jobs:
working-directory: ${{ matrix.folder }}
run: echo "USE_BAZEL_VERSION=${{ matrix.bazelversion }}" > .bazeliskrc

- name: Set bzlmod flag
# Set --enable_bzlmod if bzlmodEnabled is true, else --noenable_bzlmod.
id: set_bzlmod_flag
run: echo "bzlmod_flag=${{ matrix.bzlmodEnabled && '--enable_bzlmod' || '--noenable_bzlmod' }}" >> $GITHUB_OUTPUT

- name: Test generated files
if: matrix.folder == '.' && matrix.target == '//...'
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: |
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc run //util:update
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc run ${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} //util:update
test -z $(git status --porcelain) || { echo "Update generated files using `bazel run //util:update`" >&2; git diff >&2; exit 1; }
- name: Check for test.sh
Expand All @@ -124,13 +132,6 @@ jobs:
with:
files: "${{ matrix.folder }}/test.sh"

- name: Set bzlmod flag
# Store the --enable_bzlmod flag that we add to the test command below
# only when we're running bzlmod in our test matrix.
id: set_bzlmod_flag
if: matrix.bzlmodEnabled
run: echo "bzlmod_flag=--enable_bzlmod" >> $GITHUB_OUTPUT

- name: bazel test ${{ matrix.target }}
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
Expand Down
4 changes: 4 additions & 0 deletions util/update_filegroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def query_packages(bazel, enable_bzlmod):
command = [bazel, "query", pattern, "--output=package"]
if enable_bzlmod:
command += ["--enable_bzlmod"]
else:
command += ["--noenable_bzlmod"]
return subprocess.check_output(command).decode().split("\n")


Expand All @@ -81,6 +83,8 @@ def query_package_sources(bazel, package, enable_bzlmod):
command = [bazel, "query", pattern]
if enable_bzlmod:
command += ["--enable_bzlmod"]
else:
command += ["--noenable_bzlmod"]
sources = subprocess.check_output(command).decode().split("\n")
sources.extend(EXTRA_SRCS.get(package, []))
return sources
Expand Down

0 comments on commit 6a0a19a

Please sign in to comment.