-
Notifications
You must be signed in to change notification settings - Fork 25
134 lines (122 loc) · 4.95 KB
/
ci.yaml
File metadata and controls
134 lines (122 loc) · 4.95 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI
# 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:
workflow_call:
secrets:
BUILDBUDDY_API_KEY:
required: true
SSH_PRIVATE_KEY:
required: true
concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
test:
strategy:
fail-fast: false
matrix:
# only test on linux for now, macos is not ready.
os: [ubuntu-latest, ubuntu-24.04-arm]
bazel_version: [8.x, 9.x]
folder:
- "."
- "test"
runs-on: ${{ matrix.os }}
# Configure a human readable name for each job
name: Test ${{ matrix.folder }} with Bazel ${{ matrix.bazel_version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Setup SSH agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Trust GitHub host key
shell: bash
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
# 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
with:
path: |
~/.cache/bazel-repo
key: bazel-cache-${{ matrix.os }}-${{ matrix.bazel_version }}-${{ matrix.folder }}-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'MODULE.bazel') }}
restore-keys: |
bazel-cache-${{ matrix.os }}-${{ matrix.bazel_version }}-${{ matrix.folder }}
- name: bazel test //...
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=yes
working-directory: ${{ matrix.folder }}
shell: bash
run: |
bazel \
--bazelrc=.bazelrc \
test \
--config=remote \
--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY \
//...
test_windows:
strategy:
fail-fast: false
matrix:
os: [windows-latest, windows-11-arm]
bazel_version: [9.x]
folder:
- "test"
runs-on: ${{ matrix.os }}
# Configure a human readable name for each job
name: Test ${{ matrix.folder }} with Bazel ${{ matrix.bazel_version }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Setup SSH agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Trust GitHub host key
shell: bash
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- name: bazel test windows targets
id: bazel_test
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=yes
working-directory: ${{ matrix.folder }}
shell: bash
run: |
git config --global core.longpaths true
bazel \
--output_user_root=C:/bzl \
--bazelrc=.bazelrc \
build \
--config=remote \
--repository_cache= \
--repo_contents_cache= \
--remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY \
--jobs=100 \
//:all_builds_aarch64-pc-windows-gnullvm \
//:all_builds_x86_64-pc-windows-gnullvm