-
Notifications
You must be signed in to change notification settings - Fork 6
92 lines (88 loc) · 3.54 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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 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 }}