Skip to content

Commit 098cf67

Browse files
authored
Add attic nix cache (#2274)
1 parent 8d84808 commit 098cf67

10 files changed

Lines changed: 38 additions & 10 deletions

File tree

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: Prepare Nix
33
description: "Common setup for all runs using Nix."
4+
inputs:
5+
nativelink_attic_token:
6+
required: true
47
runs:
58
using: "composite"
69
steps:
@@ -13,13 +16,13 @@ runs:
1316
with:
1417
source-tag: v3.13.0
1518

16-
# FIXME(palfrey): Replace with better cache. Workers are currently taking minutes to upload data
17-
# all the time, probably because we're at ~500GB of 10GB in the cache storage and it's breaking.
18-
# We've tried Flakehub, but it doesn't work for us because it assumes "branches on an org repo"
19-
# not our "fork and branch on your own repo" setup for it's auth so we can't currently use that.
20-
21-
# - name: Add Nix magic cache
22-
# uses: >- # https://github.com/DeterminateSystems/magic-nix-cache-action/releases/tag/v13
23-
# DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39
24-
# with:
25-
# source-tag: v0.1.6
19+
- name: Setup attic cache
20+
run: |
21+
nix build nixpkgs#attic-client
22+
# Note NATIVELINK_ATTIC_TOKEN is blank for PR builds as they don't have secret access
23+
./result/bin/attic login uc1-dev https://attic.uc1.scdev.nativelink.net/ $NATIVELINK_ATTIC_TOKEN
24+
./result/bin/attic use nativelink
25+
./result/bin/attic watch-store nativelink &
26+
shell: bash
27+
env:
28+
NATIVELINK_ATTIC_TOKEN: ${{ inputs.nativelink_attic_token }}

.github/workflows/coverage.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
3232
- name: Prepare Worker
3333
uses: ./.github/actions/prepare-nix
34+
with:
35+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
3436

3537
# Ubuntu 24.04 restricts unprivileged user namespaces by default, which breaks
3638
# the worker tests that use namespaces (e.g. for sandboxing).

.github/workflows/custom-image.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ jobs:
107107

108108
- name: Prepare Worker
109109
uses: ./.github/actions/prepare-nix
110+
with:
111+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
110112

111113
- name: Upload image
112114
id: upload

.github/workflows/image.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
3838
- name: Prepare Worker
3939
uses: ./.github/actions/prepare-nix
40+
with:
41+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
4042

4143
- name: Test image
4244
run: |

.github/workflows/lre.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
4040
- name: Prepare Worker
4141
uses: ./.github/actions/prepare-nix
42+
with:
43+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
4244

4345
- name: Build example with ${{ matrix.toolchain }} toolchain
4446
env:
@@ -65,6 +67,8 @@ jobs:
6567

6668
# - name: Prepare Worker
6769
# uses: ./.github/actions/prepare-nix
70+
# with:
71+
# nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
6872

6973
# - name: Start Kubernetes cluster
7074
# run: >

.github/workflows/nix.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ jobs:
3535
3636
- name: Prepare Worker
3737
uses: ./.github/actions/prepare-nix
38+
with:
39+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
3840

3941
- name: Invoke Bazel build in Nix shell
4042
run: |
@@ -65,6 +67,8 @@ jobs:
6567
6668
- name: Prepare Worker
6769
uses: ./.github/actions/prepare-nix
70+
with:
71+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
6872

6973
- name: Invoke Cargo build in Nix shell
7074
run: >
@@ -88,6 +92,8 @@ jobs:
8892
8993
- name: Prepare Worker
9094
uses: ./.github/actions/prepare-nix
95+
with:
96+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
9197

9298
- name: Test nix run
9399
run: |
@@ -107,6 +113,8 @@ jobs:
107113
108114
- name: Prepare Worker
109115
uses: ./.github/actions/prepare-nix
116+
with:
117+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
110118

111119
- name: Test ${{ matrix.test-name }} run
112120
run: |

.github/workflows/pre-commit.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
2626
- name: Prepare Worker
2727
uses: ./.github/actions/prepare-nix
28+
with:
29+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
2830

2931
- name: Run pre-commit hooks
3032
run: nix flake check

.github/workflows/tagged_image.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
3030
- name: Prepare Worker
3131
uses: ./.github/actions/prepare-nix
32+
with:
33+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
3234

3335
- name: Test image
3436
run: |

.github/workflows/web.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
4646
- name: Prepare Worker
4747
uses: ./.github/actions/prepare-nix
48+
with:
49+
nativelink_attic_token: ${{ secrets.NATIVELINK_ATTIC_TOKEN }}
4850

4951
- name: Test Build
5052
if: github.event_name == 'pull_request'

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@
525525
pkgs.lre.lre-cc.lre-cc-configs-gen
526526
pkgs.nativelink-tools.local-image-test
527527
pkgs.nativelink-tools.create-local-image
528+
pkgs.attic-client
528529
]
529530
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
530531
pkgs.apple-sdk_14

0 commit comments

Comments
 (0)