Skip to content

Commit 1813f40

Browse files
committed
🌩️ Use cloud caching
No need to use GitHub's action cache. The credentials used here are intended to be used by third parties. That is, they're safe to have in this workflow and may be copy-pasted into any projects that would like to use NativeLink as remote cache.
1 parent 7870459 commit 1813f40

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

.github/workflows/test-stdlib.yaml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
os: [ubuntu-24.04]
1919
runs-on: ${{ matrix.os }}
2020
timeout-minutes: 60
21+
permissions:
22+
id-token: write
2123
steps:
2224

2325
- name: Checkout
@@ -31,25 +33,36 @@ jobs:
3133
- name: Cache Nix derivations
3234
uses: >- # v6
3335
DeterminateSystems/magic-nix-cache-action@87e8236f46702ab0ce5a058b605a173ec88d618e
34-
- name: Mount bazel cache
35-
uses: >- # v4.0.2
36-
actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
36+
37+
- name: Get Web Identity Token via Cognito Identity Pool
38+
id: web_id_token
39+
# See: https://github.com/catnekaise/cognito-idpool-auth/issues/6
40+
uses: >- # alpha
41+
catnekaise/cognito-idpool-basic-auth@287d4dabb527d8b78d3df6e0436d46e3abd209d3
42+
with:
43+
# yamllint disable rule:line-length
44+
cognito-identity-pool-id: "us-east-2:7edef192-7c1c-4e55-8ab4-6035b9c2288f"
45+
aws-account-id: "471112781046"
46+
aws-region: "us-east-2"
47+
audience: "sts.amazonaws.com"
48+
49+
- name: Create secret from token
50+
uses: actions/github-script@v6
3751
with:
38-
path: |
39-
~/.cache/bazel
40-
key: >-
41-
${{ runner.os }}-bazel-${{ hashFiles(
42-
'.bazelversion',
43-
'.bazelrc',
44-
'MODULE.bazel',
45-
'MODULE.bazel.lock',
46-
'**/*.nix',
47-
'flake.lock'
48-
) }}
49-
restore-keys: |
50-
${{ runner.os }}-bazel-
52+
# yamllint disable rule:line-length
53+
script: >-
54+
core.setSecret('NATIVELINK_TOKEN',
55+
'${{ steps.web_id_token.outputs.cognito_identity_oidc_access_token }}')
5156
5257
- name: Invoke Bazel build in Nix shell
58+
env:
59+
NATIVELINK_TOKEN: ${{ env.NATIVELINK_TOKEN }}
5360
run: |
5461
nix develop --impure --command \
55-
bash -c "bazel test --jobs=4 @mojo//... --verbose_failures"
62+
bash -c "bazel test \
63+
--jobs=4 \
64+
--verbose_failures \
65+
--experimental_remote_cache_async \
66+
--remote_header=x-nativelink-api-key=$NATIVELINK_TOKEN \
67+
--remote_cache=grpcs://cas-gha-ci.build-faster.nativelink.net:443 \
68+
@mojo//..."

0 commit comments

Comments
 (0)