|
51 | 51 | - uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34 |
52 | 52 | - uses: nix-community/cache-nix-action@b426b118b6dc86d6952988d396aa7c6b09776d08 # v7.0.0 |
53 | 53 | with: |
54 | | - primary-key: build-${{ runner.os }}-${{ matrix.name }}-${{ hashFiles('.github/workflows/build-checks.yml', 'flake.lock') }} |
| 54 | + # Store the result in its own cache, |
| 55 | + # which will be merged below |
| 56 | + primary-key: check-${{ runner.os }}-${{ matrix.name }}-${{ hashFiles('.github/workflows/build-checks.yml') }} |
| 57 | + # Try and restore the main cache |
| 58 | + restore-prefixes-first-match: | |
| 59 | + all-checks-${{ runner.os }}- |
| 60 | + check-${{ runner.os }}-${{ matrix.name }}- |
| 61 | + # When saving the cache, |
| 62 | + # try to keep it under 2GiB |
| 63 | + gc-max-store-size: 2147483648 |
| 64 | + # Purge old versions of this check, if any |
55 | 65 | purge: true |
56 | | - purge-last-accessed: 2629800 # 1 month |
57 | | - purge-prefixes: build-${{ runner.os }}-${{ matrix.name }}- |
| 66 | + purge-created: 0 |
58 | 67 | purge-primary-key: never |
| 68 | + purge-prefixes: check-${{ runner.os }}-${{ matrix.name }}- |
| 69 | + # Only save if it's not a PR |
| 70 | + save: ${{ github.event_name != 'pull_request' }} |
59 | 71 | - run: nix build -L ".#${CHECK_ATTR}" |
| 72 | + |
| 73 | + # TODO: this should be a matrix on the runners of the nix-build job. |
| 74 | + # Currently works only because we only target x86_64-linux |
| 75 | + merge-caches: |
| 76 | + # Only save if it's not a PR |
| 77 | + if: ${{ github.event_name != 'pull_request' }} |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: nix-build |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 82 | + with: |
| 83 | + persist-credentials: false |
| 84 | + - uses: nixbuild/nix-quick-install-action@25aff27c252e0c8cdda3264805f7b6bcd92c8718 # v29 |
| 85 | + - uses: nix-community/cache-nix-action@8351fb9f51c580c96c509987ebb99e38aed956ce # v5.2.1 |
| 86 | + with: |
| 87 | + primary-key: all-checks-${{ runner.os }}-${{ hashFiles('.github/workflows/build-checks.yml') }} |
| 88 | + # Restore all caches of the nix-build job |
| 89 | + # from the given runner OS |
| 90 | + restore-prefixes-all-matches: check-${{ runner.os }}- |
| 91 | + purge: true |
| 92 | + # Purge every check, |
| 93 | + # and old versions of the merged cache |
| 94 | + purge-prefixes: | |
| 95 | + check-${{ runner.os }}- |
| 96 | + all-checks-${{ runner.os }}- |
| 97 | + # Created more than 0 seconds ago relative to the start of the `Post Restore` phase |
| 98 | + purge-created: 0 |
| 99 | + # Except the cache we just created, |
| 100 | + # if we're on the main branch |
| 101 | + purge-primary-key: ${{ github.ref == 'refs/heads/master' && 'never' || 'always' }} |
0 commit comments