Skip to content

Commit

Permalink
ci: save/restore Guix cache and depends
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Nov 26, 2023
1 parent 079434b commit 6b1b515
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/guix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,29 @@ 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: |
docker run --privileged -d --rm -t \
--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'
Expand All @@ -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
11 changes: 8 additions & 3 deletions contrib/containers/guix/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b1b515

Please sign in to comment.