Skip to content

Commit ae5f47f

Browse files
nbdd0121marnovandermaas
authored andcommitted
Push the simulator build result to cache
1 parent 931a9d0 commit ae5f47f

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ jobs:
6666
substituters = https://nix-cache.lowrisc.org/public/ https://cache.nixos.org/
6767
trusted-public-keys = nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
6868
69+
- name: Setup Cache
70+
if: github.event_name != 'pull_request'
71+
run: |
72+
# Obtain OIDC token from GitHub
73+
GITHUB_ID_TOKEN=$(curl -sSf -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://ca.lowrisc.org" | jq -r .value)
74+
echo "::add-mask::$GITHUB_ID_TOKEN"
75+
# Exchange for a token for nix cache
76+
NIX_CACHE_TOKEN=$(curl -sSf -H "Authorization: Bearer $GITHUB_ID_TOKEN" "https://ca.lowrisc.org/api/nix-caches/public/token")
77+
echo "::add-mask::$NIX_CACHE_TOKEN"
78+
nix profile install nixpkgs#attic-client
79+
attic login --set-default lowrisc https://nix-cache.lowrisc.org/ "$NIX_CACHE_TOKEN"
80+
6981
- name: Nix Checks
7082
run: |
7183
nix fmt -- . --check
@@ -79,8 +91,20 @@ jobs:
7991
- name: Build Documentation
8092
run: nix build .#sonata-documentation -L
8193

94+
- name: Build simulator
95+
run: |
96+
nix build .#sonata-simulator -L
97+
if ${{ github.event_name != 'pull_request' }}; then
98+
attic push public result*
99+
fi
100+
82101
- name: Run tests on the simulator
83-
run: nix build .#tests-simulator -L
102+
run: |
103+
nix build .#tests-simulator -L
104+
if ${{ github.event_name != 'pull_request' }}; then
105+
# Cache the test result to avoid rerunning the test unless necessary.
106+
attic push public result*
107+
fi
84108
85109
fpga:
86110
runs-on: [ubuntu-22.04-fpga, sonata]
@@ -95,7 +119,7 @@ jobs:
95119
steps:
96120
- uses: actions/checkout@v4
97121

98-
# We only write to the cache when merging into main, so we don't need th authenticate on pull-request.
122+
# We only write to the cache when merging into main, so we don't need to authenticate on pull-request.
99123
- uses: google-github-actions/auth@v2
100124
if: github.event_name != 'pull_request'
101125
with:

0 commit comments

Comments
 (0)