Skip to content

Commit

Permalink
CI: Try to use the GitHub cache for the Guix store
Browse files Browse the repository at this point in the history
Unfortunately, Guix does not have anything comparable to Cachix,
therefore caching the build results might need some other tricks.
  • Loading branch information
sigprof committed Nov 4, 2023
1 parent 6f92401 commit 8c61ac3
Showing 1 changed file with 58 additions and 6 deletions.
64 changes: 58 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,53 @@ jobs:

runs-on: ${{ matrix.os }}
steps:
- name: Guix cache
uses: actions/cache@v3.3.2
- name: Prepare the Guix store before restoring from cache
working-directory: .
run: |
# Make the Guix store writable for the current user
sudo mkdir -p /gnu/store /var/guix/db /var/guix/gcroots /var/guix/profiles
sudo chown -R ${USER}: /gnu /var/guix
sudo chmod -R u+w /gnu /var/guix
- name: Restore the Guix store from cache
id: restore_cache
uses: actions/cache/restore@v3.3.2
with:
path: ~/.cache/guix
key: guix-cache-${{ github.sha }}
path: |
~/.cache/guix
/gnu
/var/guix/db/db.sqlite
/var/guix/gcroots
/var/guix/profiles
key: guix-store-${{ github.sha }}-${{ github.run_id }}
restore-keys: |
guix-cache-
guix-store-${{ github.sha }}-
guix-store-
- name: Fix up permissions for the Guix store
working-directory: .
run: |
# Fix up permissions for the Guix store when restoring from cache
sudo chown -R root:root /gnu /var/guix
sudo chmod 755 /gnu
sudo chmod -R u-w /gnu/store
sudo chmod 1775 /gnu/store
- name: Install Guix
uses: sigprof/guix-install-action@0fe71536357cf2a15be1960cd2dbce2cf89ba06a
uses: sigprof/guix-install-action@65e5b79e7f00e3f72ea1beb13431e036cc8ca2d2
with:
useExistingGuix: ${{ steps.restore_cache.outputs.cache-matched-key != '' }}
pullAfterInstall: false

- name: Ensure no locale warning
id: guix_setup_check
working-directory: .
run: test -z "$(guix --version 2>&1 >/dev/null)"

- name: Fail
working-directory: .
run: false

- name: Checkout the project source
uses: actions/checkout@v4.1.1
with:
Expand Down Expand Up @@ -173,6 +205,26 @@ jobs:
- name: Test 'qmk clean'
run: guix shell -m ../guix-qmk/manifest.scm -- qmk clean

- name: Prepare to save the Guix store
id: guix_shutdown
if: always() && !cancelled() && (steps.guix_setup_check.outcome == 'success')
working-directory: .
run: |
sudo systemctl stop guix-daemon.service
sudo systemctl stop gnu-store.mount
- name: Save the Guix store in the cache
if: always() && !cancelled() && (steps.guix_shutdown.outcome == 'success')
uses: actions/cache/save@v3.3.2
with:
path: |
~/.cache/guix
/gnu
/var/guix/db/db.sqlite
/var/guix/gcroots
/var/guix/profiles
key: guix-store-${{ github.sha }}-${{ github.run_id }}

finish:
needs:
- setup
Expand Down

0 comments on commit 8c61ac3

Please sign in to comment.