Skip to content

Commit b27b409

Browse files
committed
Replace bazel cache setup with bazel-contrib/setup-bazel action in format and test workflows
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 91d5574 commit b27b409

File tree

2 files changed

+18
-102
lines changed

2 files changed

+18
-102
lines changed

.github/workflows/format.yml

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ jobs:
8888
steps:
8989
- uses: actions/checkout@v2
9090

91+
- uses: bazel-contrib/[email protected]
92+
with:
93+
bazelisk-cache: true
94+
disk-cache: ${{ github.sha }}
95+
repository-cache: true
96+
9197
- name: Format (bazel query)
9298
run: |
9399
bazel query 'deps(//bazel/cargo/...)'
@@ -122,41 +128,17 @@ jobs:
122128
steps:
123129
- uses: actions/checkout@v2
124130

125-
- name: set cache name
126-
id: vars
127-
# The cache tag consists of the following parts:
128-
# * clang-tidy- prefix
129-
# * matrix.name, which separates the cache for each build type.
130-
# * hash of WORKSPACE, .bazelrc, and .bazelversion, which is
131-
# purely to differentiate caches for substantial changes in bazel.
132-
# * github.sha, which is the commit hash of the commit used to generate
133-
# the cache entry.
134-
run: echo "CACHE_TAG=clang-tidy-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT"
135-
136-
- name: bazel cache
137-
uses: actions/cache/restore@v3
131+
- uses: bazel-contrib/[email protected]
138132
with:
139-
path: /tmp/bazel/cache
140-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
141-
restore-keys: |
142-
${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
143-
${{ steps.vars.outputs.CACHE_TAG }}-
144-
clang-tidy-${{ matrix.name }}-
145-
clang-tidy-
133+
bazelisk-cache: true
134+
disk-cache: ${{ github.sha }}
135+
repository-cache: true
146136

147137
- name: Bazel build
148138
run: >
149139
bazel build
150140
--config=hermetic-llvm
151141
--config clang-tidy
152142
--define engine=multi
153-
--disk_cache /tmp/bazel/cache
154143
--copt=-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -c3-)\"
155144
//...
156-
157-
- name: save bazel cache
158-
uses: actions/cache/save@v3
159-
if: always()
160-
with:
161-
path: /tmp/bazel/cache
162-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}

.github/workflows/test.yml

Lines changed: 8 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,18 @@ jobs:
4848
steps:
4949
- uses: actions/checkout@v2
5050

51-
- name: set cache name
52-
id: vars
53-
# The cache tag consists of the following parts:
54-
# * test-deps-bazel-cache- prefix
55-
# * hash of WORKSPACE, .bazelrc, and .bazelversion, which is
56-
# purely to differentiate caches for substantial changes in bazel.
57-
# * github.sha, which is the commit hash of the commit used to generate
58-
# the cache entry.
59-
run: echo "CACHE_TAG=test-deps-bazel-cache-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT"
60-
61-
- name: bazel cache
62-
uses: actions/cache/restore@v3
51+
- uses: bazel-contrib/[email protected]
6352
with:
64-
path: /tmp/bazel/cache
65-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
66-
restore-keys: |
67-
${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
68-
${{ steps.vars.outputs.CACHE_TAG }}-
69-
test-deps-bazel-cache-${{ matrix.name }}-
70-
test-deps-bazel-cache-
53+
bazelisk-cache: true
54+
disk-cache: ${{ github.sha }}
55+
repository-cache: true
7156

7257
- name: Bazel build
7358
run: >
7459
bazel build
7560
--verbose_failures
7661
--test_output=errors
7762
--config=clang
78-
--disk_cache /tmp/bazel/cache
7963
--config=hermetic-llvm
8064
-c opt
8165
$(bazel query 'kind(was.*_rust_binary, //test/test_data/...)')
@@ -100,22 +84,6 @@ jobs:
10084
if-no-files-found: error
10185
retention-days: 3
10286

103-
- name: remove unaccessed files from cache
104-
shell: bash
105-
run: >
106-
find /tmp/bazel/cache
107-
-type f
108-
-name '*'
109-
-amin +360
110-
-exec rm {} \;
111-
112-
- name: save bazel cache
113-
uses: actions/cache/save@v3
114-
if: always()
115-
with:
116-
path: /tmp/bazel/cache
117-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
118-
11987
build:
12088
name: ${{ matrix.action }} with ${{ matrix.name }}
12189

@@ -304,27 +272,11 @@ jobs:
304272
if: startsWith(matrix.run_under, 'docker')
305273
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
306274

307-
- name: set cache name
308-
id: vars
309-
# The cache tag consists of the following parts:
310-
# * bazel-cache- prefix
311-
# * matrix.name, which separates the cache for each build type.
312-
# * hash of WORKSPACE, .bazelrc, and .bazelversion, which is
313-
# purely to differentiate caches for substantial changes in bazel.
314-
# * github.sha, which is the commit hash of the commit used to generate
315-
# the cache entry.
316-
run: echo "CACHE_TAG=bazel-cache-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT"
317-
318-
- name: bazel cache
319-
uses: actions/cache/restore@v3
275+
- uses: bazel-contrib/[email protected]
320276
with:
321-
path: /tmp/bazel/cache
322-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
323-
restore-keys: |
324-
${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
325-
${{ steps.vars.outputs.CACHE_TAG }}-
326-
bazel-cache-${{ matrix.name }}-
327-
bazel-cache-
277+
bazelisk-cache: true
278+
disk-cache: ${{ github.sha }}
279+
repository-cache: true
328280

329281
- name: Download test data
330282
uses: actions/download-artifact@v4
@@ -349,7 +301,6 @@ jobs:
349301
--verbose_failures
350302
--test_output=errors
351303
--define engine=${{ matrix.engine }}
352-
--disk_cache /tmp/bazel/cache
353304
${{ matrix.flags }}
354305
-- //test/... ${{ matrix.targets }}
355306
@@ -361,24 +312,7 @@ jobs:
361312
--verbose_failures
362313
--test_output=errors
363314
--define engine=${{ matrix.engine }}
364-
--disk_cache /tmp/bazel/cache
365315
${{ matrix.flags }}
366316
--per_file_copt=src/signature_util.cc,test/signature_util_test.cc@-DPROXY_WASM_VERIFY_WITH_ED25519_PUBKEY=\"$(xxd -p -c 256 test/test_data/signature_key1.pub | cut -c3- | tr -d '\n')\"
367317
//test:signature_util_test
368318
369-
- name: remove unaccessed files from cache
370-
shell: bash
371-
run: >
372-
find /tmp/bazel/cache
373-
-type f
374-
-name '*'
375-
-amin +360
376-
-exec rm {} \;
377-
378-
- name: save bazel cache
379-
uses: actions/cache/save@v3
380-
if: always()
381-
with:
382-
path: /tmp/bazel/cache
383-
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }}
384-

0 commit comments

Comments
 (0)