Skip to content

Fix/gh release (#99) #297

Fix/gh release (#99)

Fix/gh release (#99) #297

Workflow file for this run

name: Testing
# 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]
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:
# Can be triggered from the release.yaml workflow.
workflow_call:
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pre-commit checks
uses: pre-commit/action@v3.0.1
# https://github.com/actions/runner/issues/691
configure:
runs-on: ubuntu-22.04
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
user_name: ${{ steps.get-user-name.outputs.user_name }}
steps:
- id: get-user
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT
- id: get-user-name
run: echo "user_name=$(whoami)" >> $GITHUB_OUTPUT
test:
name: Run tests
needs: configure
runs-on: ubuntu-22.04
container:
image: mvukov/bazel-builder:commit-9ba1ea1dd5079d691f234bf8c31709428b72be96
options: --user ${{ needs.configure.outputs.uid_gid }}
# Run bazel test with gcc and clang in each workspace
strategy:
matrix:
folder:
- "."
- "examples"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
# 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.1.2
with:
path: |
~/.cache/bazel
~/.cache/bazel-repo
key: v4-bazel-repo-cache-${{ hashFiles('.bazelversion', 'examples/MODULE.bazel', 'repositories/**', 'requirements_lock.txt', 'MODULE.bazel') }}
restore-keys: v4-bazel-repo-cache
- name: bazel test //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: /github/home/.cache/bazel-repo
BUILDBUDDY_ORG_API_KEY: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
USER: ${{ needs.configure.outputs.user_name }}
working-directory: ${{ matrix.folder }}
run: ${GITHUB_WORKSPACE}/.github/workflows/test.sh