1
1
---
2
2
name : " Bazel Build & Test"
3
3
on : # yamllint disable-line rule:truthy
4
+ workflow_dispatch :
4
5
pull_request :
5
6
types :
6
7
- opened
@@ -16,10 +17,8 @@ on: # yamllint disable-line rule:truthy
16
17
- cron : ' 0 0,6,12,18 * * *'
17
18
env :
18
19
BAZEL_BASE_IMAGE : " ghcr.io/magma/magma/bazel-base:latestv2"
19
- BAZEL_CACHE : bazel-cache
20
- BAZEL_CACHE_REPO : bazel-cache-repo
21
- CACHE_SUB_KEY_BUILD_ALL : build-all
22
- CACHE_SUB_KEY_TEST_ALL : test-all
20
+ CACHE_KEY : bazel-base-image
21
+
23
22
24
23
concurrency :
25
24
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
73
72
- name : Check Out Repo
74
73
# This is necessary for overlays into the Docker container below.
75
74
uses : actions/checkout@v2
76
- - name : Bazel Cache
77
- uses : actions/cache@v2
78
- with :
79
- path : ${{ github.workspace }}/.${{ env.BAZEL_CACHE }}
80
- key : ${{ runner.os }}-${{ env.BAZEL_CACHE }}-${{ env.CACHE_SUB_KEY_BUILD_ALL }}-${{ github.sha }}
81
- restore-keys : |
82
- ${{ runner.os }}-${{ env.BAZEL_CACHE }}-${{ env.CACHE_SUB_KEY_BUILD_ALL }}-
83
-
84
- - name : Bazel Cache Repo
85
- uses : actions/cache@v2
86
- with :
87
- path : ${{ github.workspace }}/.${{ env.BAZEL_CACHE_REPO }}
88
- key : ${{ runner.os }}-${{ env.BAZEL_CACHE_REPO }}-${{ github.sha }}
89
- restore-keys : |
90
- ${{ runner.os }}-${{ env.BAZEL_CACHE_REPO }}-
91
-
92
- # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a
93
- # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit)
94
- # thereby only ever using the last successful cache version. This solution will result in a
95
- # few slower CI actions around the time cache is detected to be too large, but it should
96
- # incrementally improve thereafter.
97
- - name : Ensure cache size BAZEL_CACHE
98
- # Only run on master to avoid slow build on PRs
99
- if : github.event_name == 'schedule' || github.event_name == 'push'
100
- env :
101
- BAZEL_CACHE_DIR : .${{ env.BAZEL_CACHE }}
102
- # Use a 6.5GB threshold since actions/cache compresses the results, and Bazel caches seem
103
- # to only increase by a few hundred megabytes across changes for unrelated branches.
104
- # Uncompressed cache on master is looking to be around 6GB (from observing jobs on master)
105
- BAZEL_CACHE_CUTOFF_MB : 6500
106
- run : |
107
- ./.github/workflows/check-bazel-cache-dir-size.sh "$BAZEL_CACHE_DIR" "$BAZEL_CACHE_CUTOFF_MB"
108
- - name : Ensure cache size BAZEL_CACHE_REPO
109
- # Only run on master to avoid slow build on PRs
110
- if : github.event_name == 'schedule' || github.event_name == 'push'
111
- env :
112
- BAZEL_CACHE_REPO_DIR : .${{ env.BAZEL_CACHE_REPO }}
113
- # Use a 600 threshold since actions/cache compresses the results, and the repository cache should not increase unless we add more dependencies
114
- # Uncompressed cache on master is looking to be around 400MB (from observing jobs on master)
115
- BAZEL_CACHE_REPO_CUTOFF_MB : 600
116
- run : |
117
- ./.github/workflows/check-bazel-cache-dir-size.sh "$BAZEL_CACHE_REPO_DIR" "$BAZEL_CACHE_REPO_CUTOFF_MB"
118
75
- name : Setup Bazel Base Image
119
76
uses : addnab/docker-run-action@v3
120
77
with :
131
88
options : -v ${{ github.workspace }}:/workspaces/magma/
132
89
run : |
133
90
cd /workspaces/magma
91
+ bazel/scripts/remote_cache_bazelrc_setup.sh "${{ env.CACHE_KEY }}" "${{ secrets.BAZEL_REMOTE_PASSWORD }}"
134
92
bazel build //...
135
93
- name : Build space left after run
136
94
shell : bash
@@ -162,39 +120,6 @@ jobs:
162
120
- name : Check Out Repo
163
121
# This is necessary for overlays into the Docker container below.
164
122
uses : actions/checkout@v2
165
- - name : Bazel Cache
166
- uses : actions/cache@v2
167
- with :
168
- path : ${{ github.workspace }}/.${{ env.BAZEL_CACHE }}
169
- key : ${{ runner.os }}-${{ env.BAZEL_CACHE }}-${{ env.CACHE_SUB_KEY_TEST_ALL }}-${{ github.sha }}
170
- restore-keys : |
171
- ${{ runner.os }}-${{ env.BAZEL_CACHE }}-${{ env.CACHE_SUB_KEY_TEST_ALL }}-
172
-
173
- - name : Bazel Cache Repo
174
- uses : actions/cache@v2
175
- with :
176
- path : ${{ github.workspace }}/.${{ env.BAZEL_CACHE_REPO }}
177
- key : ${{ runner.os }}-${{ env.BAZEL_CACHE_REPO }}-${{ github.sha }}
178
- restore-keys : |
179
- ${{ runner.os }}-${{ env.BAZEL_CACHE_REPO }}-
180
-
181
- # This check is needed to ensure that Bazel's unbounded cache growth doesn't result in a
182
- # situation where the cache never updates (e.g. due to exceeding GitHub's cache size limit)
183
- # thereby only ever using the last successful cache version. This solution will result in a
184
- # few slower CI actions around the time cache is detected to be too large, but it should
185
- # incrementally improve thereafter.
186
- - name : Ensure cache size BAZEL_CACHE
187
- # Only run on master to avoid slow build on PRs
188
- if : github.event_name == 'schedule' || github.event_name == 'push'
189
- env :
190
- BAZEL_CACHE_DIR : .${{ env.BAZEL_CACHE }}
191
- # Use a 6.5GB threshold since actions/cache compresses the results, and Bazel caches seem
192
- # to only increase by a few hundred megabytes across changes for unrelated branches.
193
- # Uncompressed cache on master is looking to be around 6GB (from observing jobs on master)
194
- BAZEL_CACHE_CUTOFF_MB : 6500
195
- run : |
196
- ./.github/workflows/check-bazel-cache-dir-size.sh "$BAZEL_CACHE_DIR" "$BAZEL_CACHE_CUTOFF_MB"
197
- # Letting the Build job above handle cache clean up for bazel-cache-repo
198
123
- name : Setup Bazel Base Image
199
124
uses : addnab/docker-run-action@v3
200
125
with :
@@ -211,7 +136,10 @@ jobs:
211
136
options : -v ${{ github.workspace }}:/workspaces/magma/ -v ${{ github.workspace }}/lte/gateway/configs:/etc/magma
212
137
run : |
213
138
cd /workspaces/magma
214
- bazel test //... --test_output=errors --cache_test_results=no
139
+ bazel/scripts/remote_cache_bazelrc_setup.sh "${{ env.CACHE_KEY }}" "${{ secrets.BAZEL_REMOTE_PASSWORD }}"
140
+ bazel test //... \
141
+ --cache_test_results=no \
142
+ --test_output=errors
215
143
- name : Run `bazel run //:check_starlark_format`
216
144
uses : addnab/docker-run-action@v3
217
145
with :
@@ -229,6 +157,7 @@ jobs:
229
157
options : -v ${{ github.workspace }}:/workspaces/magma/
230
158
run : |
231
159
cd /workspaces/magma
160
+ bazel/scripts/remote_cache_bazelrc_setup.sh "${{ env.CACHE_KEY }}" "${{ secrets.BAZEL_REMOTE_PASSWORD }}"
232
161
bazel/scripts/test_python_service_imports.sh
233
162
- name : Build space left after run
234
163
shell : bash
0 commit comments