-
Notifications
You must be signed in to change notification settings - Fork 48
97 lines (91 loc) · 3.63 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
93
94
95
96
97
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:
# 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@v4
with:
python-version: 3.8
- name: Run pre-commit checks
uses: pre-commit/[email protected]
# https://github.com/actions/runner/issues/691
configure:
runs-on: ubuntu-latest
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"
test:
name: Run tests
needs: configure
runs-on: ubuntu-22.04
container:
image: mvukov/bazel-builder:commit-5e4745c94c121400da07ceafafecf679b62958f5
options: --user ${{ needs.configure.outputs.uid_gid }}
# Run bazel test with gcc and clang in each workspace
strategy:
matrix:
folder:
- "."
- "examples"
toolchain:
- "gcc"
- "clang"
include:
- toolchain: "gcc"
config_option: ""
- toolchain: "clang"
config_option: "--config=clang"
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/[email protected]
with:
path: |
~/.cache/bazel-repo
key: v3-bazel-repo-cache-${{ hashFiles('.bazelversion', 'examples/WORKSPACE', 'repositories/**', 'requirements_lock.txt', 'WORKSPACE') }}
restore-keys: v3-bazel-repo-cache-
- name: bazel test ${{ matrix.config_option }} //...
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
BAZEL_ARGS: ${{ matrix.config_option }}
BUILDBUDDY_ORG_API_KEY: ${{ secrets.BUILDBUDDY_ORG_API_KEY }}
working-directory: ${{ matrix.folder }}
run: .github/workflows/test.sh