Skip to content

PoC Bazel

PoC Bazel #93

Workflow file for this run

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=8cpu-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: Restore Bazel cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/bazel
~/.cache/bazelisk
key: ${{ runner.os }}-bazel2-${{ github.ref }}-${{ hashFiles('**/BUILD.bazel', '**/MODULE.bazel', '**/*.bzl', '.bazelrc') }}
restore-keys: |
${{ runner.os }}-bazel2-${{ github.ref }}-
${{ runner.os }}-bazel2-
- 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: Tidy and generate
run: |
bazel mod tidy
- name: Ensure no diff
run: |
git diff
git diff --stat --exit-code
- name: (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
- name: Save Bazel cache
if: always()
uses: actions/cache/save@v4
with:
path: |
~/.cache/bazel
~/.cache/bazelisk
key: ${{ runner.os }}-bazel2-${{ github.ref }}-${{ hashFiles('**/BUILD.bazel', '**/MODULE.bazel', '**/*.bzl', '.bazelrc') }}