Skip to content

[examples] Save test output for eyeball inspection (#97) #251

[examples] Save test output for eyeball inspection (#97)

[examples] Save test output for eyeball inspection (#97) #251

Workflow file for this run

# SPDX-License-Identifier: BSD-2-Clause
name: Continuous Integration
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
# Always use the Xvfb service's display.
DISPLAY: ":99"
jobs:
bazel_test:
runs-on: ubuntu-latest
env:
# This is where bazelisk caches its downloads of Bazel.
BAZELISK_HOME: /home/runner/.cache/bazel_ci/bazelisk
steps:
- uses: actions/checkout@v4
- name: Install Ubuntu dependencies
run: .github/ci_setup.bash
# Restore the most appropriate caches.
#
# In the below: `github.ref` will be either "refs/pull/<pr_number>/merge"
# or "refs/heads/main"; `github.run_number` is a monotonically increasing
# serial number; and `github.run_attempt` is a typically 1.
#
# The `key` declared here will never match (since it encodes the current
# run_number) but illustrates the name we'll use to save the caches when
# we're done.
#
# However, one of the `restore-keys` patterns *should* always match. The
# effects we should see from the `restore-keys` patterns are:
#
# * When building the `main` branch, we'll always pull the most recently
# updated main caches. Both restore keys say "pip-refs/heads/main-" and
# the prior archives are named, e.g., "pip-refs/heads/main-####-#".
# GitHub will use the *most recently saved* archive name that matches
# the restore key prefix (no matter the lexicographic ordering of
# the ####-# part).
#
# * Ditto for the first build of a PR; the first restore key will not
# match anything, so it falls back to the main caches.
#
# * For subsequent builds of a PR, the first restore key, e.g.,
# "pip-refs/pull/###/merge-" should match the most recently saved PR key
# "pip-refs/pull/###/merge-####-#".
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pip
# N.B. The "-mumble" suffix below will never match; it's a placeholder
# for the nonce appended to the cache key. Instead, the restore-keys
# will always be used for restoring.
key: pip-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
pip-${{ github.ref }}-
pip-refs/heads/main-
- uses: actions/cache/restore@v4
with:
path: ~/.cache/bazel_ci
key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }}
restore-keys: |
bazel_ci-${{ github.ref }}-
bazel_ci-refs/heads/main-
- name: Report cache sizes
run: |
du -ms ~/.cache/pip || true
du -ms ~/.cache/bazel_ci/* || true
# Actual testing.
- name: Bazel Test
run: |
ln -s .github/ci.bazelrc user.bazelrc
./bazel test //...
# Save the test outputs to allow for eyeball verification when relevant.
- name: Archive test outputs
uses: actions/upload-artifact@v4
with:
name: test_outputs
path: |
.bazel/testlogs/examples/ball_bin_test/test.outputs/outputs.zip
# Save the updated cache snapshots, so we never do the same work twice.
# By default, actions/cache only saves after a successful workflow, but
# our caches are bags of files where we only ever add new files (not change
# an existing files), so it's always safe to snapshot.
- uses: actions/cache/save@v4
if: always()
with:
path: ~/.cache/pip
key: pip-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }}
- uses: actions/cache/save@v4
if: always()
with:
path: ~/.cache/bazel_ci
key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }}