Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bzlmod CI #260

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading