From 6b1b515489cd514bfd489fee6063e798040d8b64 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 26 Nov 2023 01:38:28 +0300 Subject: [PATCH] ci: save/restore Guix cache and depends --- .github/workflows/guix-build.yml | 27 +++++++++++++++++++++++++++ contrib/containers/guix/Dockerfile | 11 ++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index bdc14911de313e..3eb93324499d33 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -42,6 +42,21 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + - name: Restore Guix cache and depends + id: guix-cache-restore + uses: actions/cache/restore@v3 + with: + path: | + ${{ github.workspace }}/.cache + ${{ github.workspace }}/dash/depends/built + ${{ github.workspace }}/dash/depends/sources + ${{ github.workspace }}/dash/depends/work + key: ${{ runner.os }}-guix + + - name: Create .cache folder if missing + if: steps.guix-cache-restore.outputs.cache-hit != 'true' + run: mkdir -p .cache + - name: Run Guix build timeout-minutes: 1440 run: | @@ -49,6 +64,7 @@ jobs: --name guix-daemon \ -e ADDITIONAL_GUIX_COMMON_FLAGS="--max-jobs=$(nproc --all)" \ -v ${{ github.workspace }}/dash:/src/dash \ + -v ${{ github.workspace }}/.cache:/home/ubuntu/.cache \ -w /src/dash \ guix_ubuntu:latest && \ docker exec guix-daemon bash -c '/usr/local/bin/guix-start' @@ -60,6 +76,17 @@ jobs: exit 1 fi + - name: Save Guix cache and depends + id: guix-cache-save + uses: actions/cache/save@v3 + with: + path: | + ${{ github.workspace }}/.cache + ${{ github.workspace }}/dash/depends/built + ${{ github.workspace }}/dash/depends/sources + ${{ github.workspace }}/dash/depends/work + key: ${{ steps.guix-cache-restore.outputs.cache-primary-key }} + - name: Compute SHA256 checksums run: | ./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash diff --git a/contrib/containers/guix/Dockerfile b/contrib/containers/guix/Dockerfile index 12b531a7150a05..aa42ce41c29a8c 100644 --- a/contrib/containers/guix/Dockerfile +++ b/contrib/containers/guix/Dockerfile @@ -79,9 +79,14 @@ COPY --from=docker_root ./scripts/entrypoint /usr/local/bin/entrypoint COPY --from=docker_root ./scripts/guix-check /usr/local/bin/guix-check COPY --from=docker_root ./scripts/guix-start /usr/local/bin/guix-start -# Create directory for mounting and grant necessary permissions -RUN mkdir -p /src/dash && \ - chown -R ${USER_ID}:${GROUP_ID} /src +# Create directories for mounting to save/restore cache and grant necessary permissions +RUN mkdir -p \ + /home/${USERNAME}/.cache \ + /src/dash/depends/{built,sources,work} && \ + chown -R ${USER_ID}:${GROUP_ID} \ + /home/${USERNAME}/.cache \ + /src + WORKDIR "/src/dash" # Switch to unprivileged context