|
66 | 66 | substituters = https://nix-cache.lowrisc.org/public/ https://cache.nixos.org/ |
67 | 67 | trusted-public-keys = nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= |
68 | 68 |
|
| 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 | +
|
69 | 81 | - name: Nix Checks |
70 | 82 | run: | |
71 | 83 | nix fmt -- . --check |
|
79 | 91 | - name: Build Documentation |
80 | 92 | run: nix build .#sonata-documentation -L |
81 | 93 |
|
| 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 | +
|
82 | 101 | - 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 |
84 | 108 |
|
85 | 109 | fpga: |
86 | 110 | runs-on: [ubuntu-22.04-fpga, sonata] |
|
95 | 119 | steps: |
96 | 120 | - uses: actions/checkout@v4 |
97 | 121 |
|
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. |
99 | 123 | - uses: google-github-actions/auth@v2 |
100 | 124 | if: github.event_name != 'pull_request' |
101 | 125 | with: |
|
0 commit comments