Skip to content

Commit da11a13

Browse files
committed
CI: Cache dependencies between runs
This should be more reliable than the old cache-install action because all the software is operated according to their intended interfaces.
1 parent d13d5ac commit da11a13

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/maven.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020
- uses: cachix/install-nix-action@v31
21+
- name: List pre-installed store paths
22+
run: find /nix/store -mindepth 1 -maxdepth 1 | sort > pre-installed
23+
- uses: actions/cache/restore@v4
24+
id: cache
25+
with:
26+
path: cache-closure.nar
27+
key: nix-${{ hashFiles('.github/workflows/maven.yml', 'default.nix', 'nix/**', 'pom.xml', 'local-maven-repo') }}
28+
- name: Import cache
29+
if: steps.cache.outputs.cache-hit == 'true'
30+
run: nix-store --import < cache-closure.nar
31+
- name: Build dependency cache
32+
if: steps.cache.outputs.cache-hit != 'true'
33+
run: nix-build --out-link dependencies nix/github-workflow-dependencies.nix
34+
- name: Export cache
35+
if: steps.cache.outputs.cache-hit != 'true'
36+
run: |
37+
find /nix/store -mindepth 1 -maxdepth 1 | sort > store-paths
38+
nix-store --export $(comm -13 pre-installed store-paths) > cache-closure.nar
39+
- uses: actions/cache/save@v4
40+
if: steps.cache.outputs.cache-hit != 'true'
41+
with:
42+
path: cache-closure.nar
43+
key: nix-${{ hashFiles('.github/workflows/maven.yml', 'default.nix', 'nix/**', 'pom.xml', 'local-maven-repo') }}
2144
- name: Build
2245
run: nix-build
2346
- name: Upload Javadoc artifact

0 commit comments

Comments
 (0)