PoC Bazel #100
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: bazel | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| merge_group: | |
| workflow_dispatch: | |
| env: | |
| GOPRIVATE: github.com/smartcontractkit/capabilities | |
| jobs: | |
| test: | |
| runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-arm64/spot=false/extras=s3-cache | |
| steps: | |
| - name: Enable S3 Cache for Self-Hosted Runners | |
| # these env vars are set (and exposed) when it is a self-hosted runner with extras=s3-cache | |
| if: ${{ env.RUNS_ON_INSTANCE_ID != '' && env.ACTIONS_CACHE_URL != '' }} | |
| uses: runs-on/action@66d4449b717b5462159659523d1241051ff470b9 # v1 | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install Bazel | |
| # install for self-hosted runners only, as github-hosted already have bazel installed | |
| if: ${{ env.RUNS_ON_INSTANCE_ID != '' }} | |
| run: | | |
| npm install -g @bazel/bazelisk | |
| bazel version | |
| - name: Bazel mod tidy | |
| run: | | |
| bazel mod tidy | |
| - name: Ensure no diff | |
| run: | | |
| git diff | |
| git diff --stat --exit-code | |
| # Restore Bazel cache after Bazel mod tidy to fail faster on errors | |
| - name: Restore Bazel cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/bazel | |
| ~/.cache/bazelisk | |
| key: ${{ runner.os }}-bazel_cache-${{ github.ref }}-${{ hashFiles('**/BUILD.bazel', '**/MODULE.bazel', '**/*.bzl', '.bazelrc') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bazel_cache-${{ github.ref }}- | |
| ${{ runner.os }}-bazel_cache- | |
| - name: Bazel (re)generate | |
| run: | | |
| bazel run //:gazelle --config=ci | |
| - name: Ensure no diff | |
| run: | | |
| git diff | |
| git diff --stat --exit-code | |
| - name: Build, lint, and test | |
| run: bazel test //... --config=ci |