Skip to content

Commit 96d4a30

Browse files
UdjinM6ogabrielides
authored andcommitted
ci: Bump Guix build timeout and implement cacheing (dashpay#5727)
## Issue being fixed or feature implemented Hopefully fixes issues like >The job running on runner ubuntu-core-x64_i-05ed4263b8e049c7a has exceeded the maximum execution time of 360 minutes https://github.com/dashpay/dash/actions/runs/6932017275 https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes ## What was done? Bump timeouts for the job itself and for the corresponding step. Also, implemented caching for `.cache` and `depends` folders. ## How Has This Been Tested? dashpay#5729 https://github.com/dashpay/dash/actions/runs/6996271543/job/19031968814?pr=5729 ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
1 parent 4660170 commit 96d4a30

File tree

2 files changed

+44
-9
lines changed

2 files changed

+44
-9
lines changed

.github/workflows/guix-build.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,62 @@ jobs:
99
build:
1010
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-core" ]
1111
if: contains(github.event.pull_request.labels.*.name, 'guix-build')
12+
timeout-minutes: 480
1213
steps:
1314
- name: Checkout
1415
uses: actions/checkout@v4
1516
with:
1617
ref: ${{ github.event.pull_request.head.sha }}
18+
path: dash
1719

1820
- name: Set up Docker Buildx
1921
uses: docker/setup-buildx-action@v3
2022

2123
- name: Commit variables
2224
id: dockerfile
2325
run: |
24-
echo "hash=$(sha256sum ./contrib/containers/guix/Dockerfile | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
26+
echo "hash=$(sha256sum ./dash/contrib/containers/guix/Dockerfile | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
2527
echo "host_user_id=$(id -u)" >> $GITHUB_OUTPUT
2628
echo "host_group_id=$(id -g)" >> $GITHUB_OUTPUT
2729
2830
- name: Build Docker image
2931
uses: docker/build-push-action@v5
3032
with:
31-
context: ${{ github.workspace }}
33+
context: ${{ github.workspace }}/dash
3234
build-args: |
3335
USER_ID=${{ steps.dockerfile.outputs.host_user_id }}
3436
GROUP_ID=${{ steps.dockerfile.outputs.host_group_id }}
3537
build-contexts: |
36-
docker_root=${{ github.workspace }}/contrib/containers/guix
37-
file: ./contrib/containers/guix/Dockerfile
38+
docker_root=${{ github.workspace }}/dash/contrib/containers/guix
39+
file: ./dash/contrib/containers/guix/Dockerfile
3840
load: true
3941
tags: guix_ubuntu:latest
4042
cache-from: type=gha
4143
cache-to: type=gha,mode=max
4244

45+
- name: Restore Guix cache and depends
46+
id: guix-cache-restore
47+
uses: actions/cache/restore@v3
48+
with:
49+
path: |
50+
${{ github.workspace }}/.cache
51+
${{ github.workspace }}/dash/depends/built
52+
${{ github.workspace }}/dash/depends/sources
53+
${{ github.workspace }}/dash/depends/work
54+
key: ${{ runner.os }}-guix
55+
56+
- name: Create .cache folder if missing
57+
if: steps.guix-cache-restore.outputs.cache-hit != 'true'
58+
run: mkdir -p .cache
59+
4360
- name: Run Guix build
61+
timeout-minutes: 480
4462
run: |
4563
docker run --privileged -d --rm -t \
4664
--name guix-daemon \
4765
-e ADDITIONAL_GUIX_COMMON_FLAGS="--max-jobs=$(nproc --all)" \
48-
-v ${{ github.workspace }}:/src/dash \
66+
-v ${{ github.workspace }}/dash:/src/dash \
67+
-v ${{ github.workspace }}/.cache:/home/ubuntu/.cache \
4968
-w /src/dash \
5069
guix_ubuntu:latest && \
5170
docker exec guix-daemon bash -c '/usr/local/bin/guix-start'
@@ -57,6 +76,17 @@ jobs:
5776
exit 1
5877
fi
5978
79+
- name: Save Guix cache and depends
80+
id: guix-cache-save
81+
uses: actions/cache/save@v3
82+
with:
83+
path: |
84+
${{ github.workspace }}/.cache
85+
${{ github.workspace }}/dash/depends/built
86+
${{ github.workspace }}/dash/depends/sources
87+
${{ github.workspace }}/dash/depends/work
88+
key: ${{ steps.guix-cache-restore.outputs.cache-primary-key }}
89+
6090
- name: Compute SHA256 checksums
6191
run: |
62-
./contrib/containers/guix/scripts/guix-check ${{ github.workspace }}
92+
./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash

contrib/containers/guix/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ COPY --from=docker_root ./scripts/entrypoint /usr/local/bin/entrypoint
7979
COPY --from=docker_root ./scripts/guix-check /usr/local/bin/guix-check
8080
COPY --from=docker_root ./scripts/guix-start /usr/local/bin/guix-start
8181

82-
# Create directory for mounting and grant necessary permissions
83-
RUN mkdir -p /src/dash && \
84-
chown -R ${USER_ID}:${GROUP_ID} /src
82+
# Create directories for mounting to save/restore cache and grant necessary permissions
83+
RUN mkdir -p \
84+
/home/${USERNAME}/.cache \
85+
/src/dash/depends/{built,sources,work} && \
86+
chown -R ${USER_ID}:${GROUP_ID} \
87+
/home/${USERNAME}/.cache \
88+
/src
89+
8590
WORKDIR "/src/dash"
8691

8792
# Switch to unprivileged context

0 commit comments

Comments
 (0)