Add test matrix to CI + format build files #763
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }}, Detekt ${{ matrix.detekt-strategy }}) | ||
| runs-on: ubuntu-latest | ||
| <<<<<<< HEAD | ||
| ======= | ||
| <<<<<<< HEAD | ||
| 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: Mount bazel caches | ||
| uses: actions/cache@v6 | ||
| with: | ||
| path: | | ||
| ~/.cache/bazel-disk-cache | ||
| key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'MODULE.bazel', 'MODULE.bazel.lock') }} | ||
| restore-keys: bazel-cache- | ||
| - name: "Setup Bazelisk" | ||
| uses: bazelbuild/setup-bazelisk@v3 | ||
| - name: "Configure Bazel" | ||
| run: cp .github/workflows/ci.bazelrc . | ||
| - name: "Unit tests" | ||
| run: bazel test -- //... -//tests/integration/... | ||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
| ======= | ||
| env: | ||
| USE_BAZEL_VERSION: ${{ matrix.bazel }} | ||
| >>>>>>> 58a6e97 (Add test matrix to CI + format build files) | ||
| >>>>>>> 4d34234 (Add test matrix to CI + format build files) | ||
| 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: | ||
| <<<<<<< HEAD | ||
| path: | | ||
| ~/.cache/bazel-disk-cache | ||
| key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'MODULE.bazel', 'MODULE.bazel.lock') }} | ||
| restore-keys: bazel-cache- | ||
| - name: "Setup Bazelisk" | ||
| uses: bazelbuild/setup-bazelisk@v3 | ||
| - name: "Configure Bazel" | ||
| run: cp .github/workflows/ci.bazelrc . | ||
| <<<<<<< HEAD | ||
| - name: "Unit tests" | ||
| run: bazel test //... --strategy=Detekt=${{ matrix.detekt-strategy }} | ||
| ======= | ||
| - name: "Integration tests (${{ matrix.detekt-strategy }})" | ||
| run: bazel test --strategy=Detekt=${{ matrix.detekt-strategy }} --disk_cache= --cache_test_results=no //tests/integration/... | ||
| ======= | ||
| 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 --strategy=Detekt=${{ matrix.detekt-strategy }} //... | ||
| - name: Verify MODULE.bazel.lock is unchanged | ||
| if: ${{ always() && matrix.bazel == '9.x' && matrix.detekt-strategy == 'local' }} | ||
| 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 | ||
| >>>>>>> 58a6e97 (Add test matrix to CI + format build files) | ||
| >>>>>>> 4d34234 (Add test matrix to CI + format build files) | ||