Skip to content

Commit

Permalink
Prepare CI for bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
lalten committed Feb 1, 2024
1 parent 4b7016b commit abf3461
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
11 changes: 3 additions & 8 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
# Mandatory at the moment for Bazel 7.0.0.
build --noincompatible_sandbox_hermetic_tmp

# This is mandatory if your build env doesn't have a proper Python 3 exe
# -- like the CI build image for this repo.
# The build image is using a fake python exe, see
# https://github.com/mvukov/bazel_builder/blob/main/Dockerfile.
# If blzmod is enabled, but not used as in this repo at the moment),
# then bazel for some reason tries to auto-detect a Python exe.
build --noenable_bzlmod

# Fix the wrong default to generate __init__.py to delimit a Python package.
# This is a mandatory flag.
build --incompatible_default_to_explicit_init_py
Expand All @@ -37,6 +29,9 @@ build --noexperimental_check_output_files
# Don't bother building targets which aren't dependencies of the tests.
test --build_tests_only

# Show all the problems in CI
test --keep_going

# To use a clang compiler, invoke Bazel with `--config=clang`.
build:clang --repo_env=CC=clang
build:clang --repo_env=CXX=clang++
Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,26 @@ jobs:

# Run bazel test with gcc and clang in each workspace
strategy:
fail-fast: false
matrix:
folder:
- "."
- "examples"
toolchain:
- "gcc"
- "clang"
external_dependency_system:
# - bzlmod # TODO: https://github.com/mvukov/rules_ros2/pull/238
- workspace
include:
- toolchain: "gcc"
config_option: ""
- toolchain: "clang"
config_option: "--config=clang"
# - external_dependency_system: bzlmod
# bzlmod_flags: --enable_bzlmod
- external_dependency_system: workspace
bzlmod_flags: --noenable_bzlmod

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand All @@ -89,13 +97,21 @@ jobs:
path: |
~/.cache/bazel
~/.cache/bazel-repo
key: v3-bazel-repo-cache-${{ matrix.toolchain }}-${{ hashFiles('.bazelversion', 'examples/WORKSPACE', 'repositories/**', 'requirements_lock.txt', 'WORKSPACE') }}
restore-keys: v3-bazel-repo-cache-${{ matrix.toolchain }}-
- name: bazel test ${{ matrix.config_option }} //...
key: >-
v3-bazel-repo-cache
-${{ matrix.external_dependency_system }}-${{ matrix.toolchain }}
-${{ hashFiles('.bazelversion', '**/WORKSPACE', '**/MODULE.bazel', 'repositories/**/*.bzl', 'requirements_lock.txt') }}
restore-keys: >-
v3-bazel-repo-cache
-${{ matrix.external_dependency_system }}-${{ matrix.toolchain }}
- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
BUILDBUDDY_ORG_API_KEY: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
USER: ${{ needs.configure.outputs.user_name }}
working-directory: ${{ matrix.folder }}
run: ${GITHUB_WORKSPACE}/.github/workflows/test.sh ${{ matrix.config_option }}
run: >
${GITHUB_WORKSPACE}/.github/workflows/test.sh
${{ matrix.config_option }}
${{ matrix.bzlmod_flags }}

0 comments on commit abf3461

Please sign in to comment.