Skip to content

chore(deps): update dependency rules_bazel_integration_test to v0.24.1 #689

chore(deps): update dependency rules_bazel_integration_test to v0.24.1

chore(deps): update dependency rules_bazel_integration_test to v0.24.1 #689

Workflow file for this run

name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize, edited]
# Allows you to call this workflow from another workflow
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# matrix-prep-* steps generate JSON used to create a dynamic actions matrix.
# Insanely complex for how simple this requirement is inspired from
# https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional
matrix-prep-bazelversion:
# Prepares the 'bazelversion' axis of the test matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: versions_from_bazel_versions_bzl
run: echo "bazelversions=$(.github/workflows/bazel_versions.py)" >> $GITHUB_OUTPUT
outputs:
# Will look like ["<version from .bazelversion>","<version from bazel_versions.bzl>"]
bazelversions: ${{ steps.versions_from_bazel_versions_bzl.outputs.bazelversions }}
test:
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
needs:
- matrix-prep-bazelversion
# Run bazel test in each workspace with each version of Bazel supported
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }}
zigversion: [0.12.0]
bzlmodEnabled: [true, false]
folder:
- "."
- "e2e/workspace"
target: ["//..."]
include:
# The integration tests iterate over all supported Bazel versions, so
# we only run them against the latest Bazel version.
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: false
folder: "."
target: "//zig/tests/integration_tests"
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: true
folder: "."
target: "//zig/tests/integration_tests"
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: true
folder: "."
target: "//zig/tests/integration_tests"
# Only test older Zig versions with the latest Bazel version
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: false
folder: "."
target: "//..."
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: true
folder: "."
target: "//..."
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: true
folder: "."
target: "//..."
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: false
folder: "e2e/workspace"
target: "//..."
- os: ubuntu-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: true
folder: "e2e/workspace"
target: "//..."
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.11.0
bzlmodEnabled: true
folder: "e2e/workspace"
target: "//..."
# Only test the latest Bazel version on MacOS (MacOS runners are expensive and slow)
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: false
folder: "."
target: "//..."
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: true
folder: "."
target: "//..."
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: false
folder: "e2e/workspace"
target: "//..."
- os: macos-latest
bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] }}
zigversion: 0.12.0
bzlmodEnabled: true
folder: "e2e/workspace"
target: "//..."
# Configure a human readable name for each job
name: Test ${{ matrix.target }} in ${{ matrix.folder }} with Zig ${{ matrix.zigversion }}, 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
- uses: actions/checkout@v4
# Cache build and external artifacts so that the next ci build is incremental.
# Because github action caches cannot be updated after a build, we need to
# store the contents of each build in a unique cache key, then fall back to loading
# it on the next ci run. We use hashFiles(...) in the key and restore-keys- with
# the prefix to load the most recent cache for the branch on a cache miss. You
# should customize the contents of hashFiles to capture any bazel input sources,
# although this doesn't need to be perfect. If none of the input sources change
# then a cache hit will load an existing cache and bazel won't have to do any work.
# In the case of a cache miss, you want the fallback cache to contain most of the
# previously built artifacts to minimize build time. The more precise you are with
# hashFiles sources the less work bazel will have to do.
- name: Mount bazel caches
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
~/.cache/bazel-repo
key: bazel-cache-${{ matrix.os }}-${{ matrix.zigversion }}-${{ matrix.bazelversion }}-${{ matrix.bzlmodEnabled }}-${{ matrix.folder }}-${{ matrix.target }}-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', '**/*.zig', 'WORKSPACE', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}
restore-keys: |
bazel-cache-${{ matrix.os }}-${{ matrix.bazelversion }}-${{ matrix.bzlmodEnabled }}-${{ matrix.folder }}-${{ matrix.target }}
- name: Configure remote cache and execution
working-directory: ${{ matrix.folder }}
run: |
cat <<EOF >>.bazelrc.user
build --config=remote-bes --config=remote-cache
# Remote execution on non-Linux is only available for BuildBuddy Enterprise.
build:linux --config=remote
EOF
cat <<EOF >>.bazelrc.ic.user
build --config=remote-bes --config=remote-cache
# Remote execution on non-Linux is only available for BuildBuddy Enterprise.
build:linux --config=remote
EOF
- name: Configure Bazel version
working-directory: ${{ matrix.folder }}
run: echo "USE_BAZEL_VERSION=${{ matrix.bazelversion }}" > .bazeliskrc
- name: Configure Zig version
working-directory: ${{ matrix.folder }}
run: echo "build --@zig_toolchains//:version=${{ matrix.zigversion }}" >> .bazelrc.user
- name: Configure documentation generation
if: matrix.folder == '.' && matrix.target == '//...'
run: |
# Disable documentation generation for all but the first Bazel
# version, by setting --no@rules_zig//docs:build_docs in
# .bazelrc.user. The generated documentation can vary between Bazel
# versions. For example, Bazel version 7 changed the documentation of
# the implicit `repo_mapping` parameter to repository rules compared
# to Bazel version 6.
PREFIX=${{ matrix.bazelversion == fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions)[0] && '' || 'no' }}
echo "common --$PREFIX@rules_zig//docs:build_docs" >> .bazelrc.user
- name: Set bzlmod flag
working-directory: ${{ matrix.folder }}
# Set --enable_bzlmod if bzlmodEnabled is true, else --noenable_bzlmod.
id: set_bzlmod_flag
run: |
echo "common ${{ matrix.bzlmodEnabled && '--enable_bzlmod' || '--noenable_bzlmod' }}" >> .bazelrc.user
echo "bzlmod_flag=${{ matrix.bzlmodEnabled && '--enable_bzlmod' || '--noenable_bzlmod' }}" >> $GITHUB_OUTPUT
- name: Test generated files
if: matrix.folder == '.' && matrix.target == '//...'
run: |
# Bazelisk will download bazel to here, ensure it is cached between runs.
export XDG_CACHE_HOME="$HOME/.cache/bazel-repo"
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc run //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
# Checks for the existence of test.sh in the folder. Downstream steps can use
# steps.has_test_sh.outputs.files_exists as a conditional.
id: has_test_sh
uses: andstor/file-existence-action@v3
with:
files: "${{ matrix.folder }}/test.sh"
- name: bazel test ${{ matrix.target }}
working-directory: ${{ matrix.folder }}
run: |
# Bazelisk will download bazel to here, ensure it is cached between runs.
export XDG_CACHE_HOME="$HOME/.cache/bazel-repo"
bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ${{ matrix.target }}
- name: ./test.sh
# Run if there is a test.sh file in the folder
if: steps.has_test_sh.outputs.files_exists == 'true'
working-directory: ${{ matrix.folder }}
shell: bash
# Run the script potentially setting BZLMOD_FLAG=--enable_bzlmod. All test.sh
# scripts that run bazel directly should make use of this variable.
run: BZLMOD_FLAG=${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} ./test.sh
all_tests:
runs-on: ubuntu-latest
needs:
- matrix-prep-bazelversion
- test
if: ${{ always() }}
steps:
- uses: cgrindel/[email protected]
# Skip on release flows when invoked through the release workflow.
# Otherwise gha_join_jobs discovers its own job in the job list and
# fails since it is not yet succeeded, but still in progress.
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}