actions: optimize guix cache

This commit is contained in:
tobtoht 2023-05-31 02:33:24 +02:00
parent 9acd13601e
commit f6b6befbc4
No known key found for this signature in database
GPG key ID: E45B10DD027D2472

View file

@ -16,16 +16,52 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: depends sources cache - name: depends sources cache
id: cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: contrib/depends/sources path: contrib/depends/sources
key: sources-${{ hashFiles('contrib/depends/packages/*') }} key: sources-${{ hashFiles('contrib/depends/packages/*') }}
- name: download depends sources - name: download depends sources
if: steps.cache.outputs.cache-hit != 'true'
run: make -C contrib/depends download run: make -C contrib/depends download
cache-guix:
runs-on: ubuntu-latest
needs: [cache-sources]
steps:
- name: guix cache
uses: actions/cache@v3
with:
path: |
gnu/store
guix_db.sqlite
key: guix-${{ hashFiles('contrib/guix/manifest.scm') }}
- name: move guix store
run: |
if [[ -e "guix_db.sqlite" ]]; then
sudo mkdir -p /var/guix/db
sudo mv gnu /gnu
sudo cp guix_db.sqlite /var/guix/db/db.sqlite
sudo chmod 1775 /gnu/store
sudo chown 0644 /var/guix/db/db.sqlite
sudo chown -R root:root /gnu/store /var/guix/db/db.sqlite
fi
- name: set apt conf
run: ${{env.APT_SET_CONF}}
- name: install dependencies
run: sudo apt update; sudo apt -y install guix git ca-certificates
- name: dry run
run: DRY_RUN=1 SUBSTITUTE_URLS='http://ci.guix.gnu.org' JOBS=2 ./contrib/guix/guix-build
- name: prepare guix store for caching
run: |
sudo systemctl stop guix-daemon
sudo mv /gnu gnu
sudo mv /var/guix/db/db.sqlite guix_db.sqlite
build-guix: build-guix:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [cache-sources] needs: [cache-guix]
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -55,12 +91,12 @@ jobs:
fetch-depth: 0 fetch-depth: 0
submodules: recursive submodules: recursive
- name: guix cache - name: guix cache
uses: actions/cache@v3 uses: actions/cache/restore@v3
with: with:
path: | path: |
gnu/store gnu/store
guix_db.sqlite guix_db.sqlite
key: guix-${{ matrix.toolchain.host }}-${{ hashFiles('contrib/guix/manifest.scm') }} key: guix-${{ hashFiles('contrib/guix/manifest.scm') }}
- name: move guix store - name: move guix store
run: | run: |
if [[ -e "guix_db.sqlite" ]]; then if [[ -e "guix_db.sqlite" ]]; then
@ -85,7 +121,7 @@ jobs:
- name: set apt conf - name: set apt conf
run: ${{env.APT_SET_CONF}} run: ${{env.APT_SET_CONF}}
- name: install dependencies - name: install dependencies
run: sudo apt update; sudo apt -y install guix git ca-certificates ${{ matrix.toolchain.packages }} run: sudo apt update; sudo apt -y install guix git ca-certificates
- name: build - name: build
run: SUBSTITUTE_URLS='http://ci.guix.gnu.org' HOSTS="${{ matrix.toolchain.host }}" JOBS=2 ./contrib/guix/guix-build run: SUBSTITUTE_URLS='http://ci.guix.gnu.org' HOSTS="${{ matrix.toolchain.host }}" JOBS=2 ./contrib/guix/guix-build
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
@ -93,8 +129,3 @@ jobs:
name: ${{ matrix.toolchain.name }} name: ${{ matrix.toolchain.name }}
path: | path: |
guix/guix-build-*/output/${{ matrix.toolchain.host }}/* guix/guix-build-*/output/${{ matrix.toolchain.host }}/*
- name: prepare guix store for caching
run: |
sudo systemctl stop guix-daemon
sudo mv /gnu gnu
sudo mv /var/guix/db/db.sqlite guix_db.sqlite