From 15dceafef9d8538c8925f5c9b5a3e289156e9cdd Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 30 Jan 2024 21:41:55 +0100 Subject: [PATCH] Prepare CI for bzlmod --- .bazelrc | 11 +++-------- .github/workflows/main.yml | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.bazelrc b/.bazelrc index 9e1354c3..b749130a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 @@ -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++ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02a91895..657bdd26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,6 +53,7 @@ jobs: # Run bazel test with gcc and clang in each workspace strategy: + fail-fast: false matrix: folder: - "." @@ -60,11 +61,18 @@ jobs: 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 @@ -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 }}