Skip to content

Add test matrix to CI + format build files #764

Add test matrix to CI + format build files

Add test matrix to CI + format build files #764

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: [master]
pull_request:
branches: [master]
# 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:
pre_commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.1
build:
name: Build (Bazel ${{ matrix.bazel }})
runs-on: ubuntu-latest
env:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
strategy:
fail-fast: false
matrix:
bazel: ["8.x", "9.x", "rolling"]
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7
- name: "Install JDK 11"
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
- name: "Setup Bazel"
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: true
repository-cache: true
- name: "Build"
run: bazel build --curses=no --verbose_failures --worker_verbose --announce_rc //detekt/wrapper:bin
test:
name: Test (Bazel ${{ matrix.bazel }})
runs-on: ubuntu-latest
env:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
strategy:
fail-fast: false
matrix:
bazel: ["8.x", "9.x", "rolling"]
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7
- name: "Install JDK 11"
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
- name: "Setup Bazel"
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: true
repository-cache: true
- name: "Unit tests"
run: bazel test --curses=no --verbose_failures --worker_verbose --announce_rc --test_output=errors --test_env=XDG_CACHE_HOME -- //... -//tests/integration/...
- name: Verify MODULE.bazel.lock is unchanged
if: ${{ always() && matrix.bazel == '9.x' }}
shell: bash
run: |
if [[ -n "$(git status --porcelain -- MODULE.bazel.lock)" ]]; then
git diff -- MODULE.bazel.lock
git diff --cached -- MODULE.bazel.lock
echo "::error file=MODULE.bazel.lock::MODULE.bazel.lock changed during CI. Run Bazel locally and commit the updated lockfile."
exit 1
fi
integration-test:
name: Integration test (Bazel ${{ matrix.bazel }}, Detekt ${{ matrix.detekt-strategy }})
runs-on: ubuntu-latest
env:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
strategy:
fail-fast: false
matrix:
bazel: ["8.x", "9.x", "rolling"]
detekt-strategy: [local, worker]
steps:
- name: "Checkout the sources"
uses: actions/checkout@v7
- name: "Install JDK 11"
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
- name: "Setup Bazel"
uses: bazel-contrib/setup-bazel@0.19.0
with:
bazelisk-cache: true
disk-cache: true
repository-cache: true
- name: "Integration tests (${{ matrix.detekt-strategy }})"
run: bazel test --curses=no --verbose_failures --worker_verbose --announce_rc --test_output=errors --test_env=XDG_CACHE_HOME --strategy=Detekt=${{ matrix.detekt-strategy }} --disk_cache= --cache_test_results=no //tests/integration/...