Skip to content

Commit 6fb4e49

Browse files
Merge #6197: ci: always build guix, save artifacts
770651a set hosts in guix-check (pasta) 580bbe6 feat: improve guix building; run always, save artifacts (pasta) 101a315 refactor: simplify caching setup, add a restore key to actually cache besides 1 run (pasta) 1b139e4 feat: automatically run guix-build on all tags pushed (pasta) Pull request description: ## Issue being fixed or feature implemented Previously, we only ran guix on 1 machine for all hosts; this slowed it down a lot. Let's move to GitHub action runners, but run them all separately. Then upload the artifacts. In the future there is significant caching I can add that should help a lot more. But currently, takes about 1 hour ## What was done? ## How Has This Been Tested? see: https://github.com/PastaPastaPasta/dash/actions/runs/10345024600 ## Breaking Changes None ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [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)_ ACKs for top commit: UdjinM6: utACK 770651a Tree-SHA512: 639b95c3b6a26f205ed00c138a9189f915cfc36a815516035e59ceda82675414b1bd31a361b33449b5e4c58a7655f3a7d616b362c23f7fa75e72b1284be06b9e
1 parent c0ca93c commit 6fb4e49

File tree

1 file changed

+67
-31
lines changed

1 file changed

+67
-31
lines changed

.github/workflows/guix-build.yml

Lines changed: 67 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
name: Guix Build
22

3+
permissions:
4+
packages: write
5+
36
on:
4-
pull_request:
5-
types: [ labeled ]
6-
workflow_dispatch:
7+
pull_request_target:
8+
push:
79

810
jobs:
9-
build:
10-
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-core" ]
11-
if: contains(github.event.pull_request.labels.*.name, 'guix-build')
12-
timeout-minutes: 480
11+
build-image:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
image-tag: ${{ steps.prepare.outputs.image-tag }}
15+
repo-name: ${{ steps.prepare.outputs.repo-name }}
1316
steps:
1417
- name: Checkout
1518
uses: actions/checkout@v4
@@ -22,37 +25,72 @@ jobs:
2225
uses: docker/setup-buildx-action@v3
2326

2427
- name: Commit variables
25-
id: dockerfile
28+
id: prepare
2629
run: |
2730
echo "hash=$(sha256sum ./dash/contrib/containers/guix/Dockerfile | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
2831
echo "host_user_id=$(id -u)" >> $GITHUB_OUTPUT
2932
echo "host_group_id=$(id -g)" >> $GITHUB_OUTPUT
33+
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '[:upper:]' '[:lower:]')
34+
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
35+
echo "::set-output name=image-tag::${BRANCH_NAME}"
36+
echo "::set-output name=repo-name::${REPO_NAME}"
37+
38+
- name: Login to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
3044

3145
- name: Build Docker image
32-
uses: docker/build-push-action@v5
46+
uses: docker/build-push-action@v6
3347
with:
3448
context: ${{ github.workspace }}/dash
3549
build-args: |
36-
USER_ID=${{ steps.dockerfile.outputs.host_user_id }}
37-
GROUP_ID=${{ steps.dockerfile.outputs.host_group_id }}
50+
USER_ID=${{ steps.prepare.outputs.host_user_id }}
51+
GROUP_ID=${{ steps.prepare.outputs.host_group_id }}
3852
build-contexts: |
3953
docker_root=${{ github.workspace }}/dash/contrib/containers/guix
4054
file: ./dash/contrib/containers/guix/Dockerfile
41-
load: true
42-
tags: guix_ubuntu:latest
43-
cache-from: type=gha
44-
cache-to: type=gha,mode=max
55+
push: true
56+
tags: |
57+
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:${{ steps.prepare.outputs.image-tag }}
58+
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:latest
59+
cache-from: type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:latest
60+
cache-to: type=inline,mode=max
61+
62+
build:
63+
needs: build-image
64+
# runs-on: [ "self-hosted", "linux", "x64", "ubuntu-core" ]
65+
runs-on: ubuntu-latest
66+
# if: ${{ contains(github.event.pull_request.labels.*.name, 'guix-build') }}
67+
strategy:
68+
matrix:
69+
build_target: [x86_64-linux-gnu, arm-linux-gnueabihf, aarch64-linux-gnu, riscv64-linux-gnu, x86_64-w64-mingw32, x86_64-apple-darwin, arm64-apple-darwin]
4570

46-
- name: Restore Guix cache and depends
71+
timeout-minutes: 480
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@v4
75+
with:
76+
ref: ${{ github.event.pull_request.head.sha }}
77+
path: dash
78+
fetch-depth: 0
79+
80+
- name: Cache Guix and depends
4781
id: guix-cache-restore
48-
uses: actions/cache/restore@v3
82+
uses: actions/cache@v3
4983
with:
5084
path: |
5185
${{ github.workspace }}/.cache
5286
${{ github.workspace }}/dash/depends/built
5387
${{ github.workspace }}/dash/depends/sources
5488
${{ github.workspace }}/dash/depends/work
55-
key: ${{ runner.os }}-guix
89+
/gnu/store
90+
key: ${{ runner.os }}-guix-${{ matrix.build_target }}-${{ github.sha }}
91+
restore-keys: |
92+
${{ runner.os }}-guix-${{ matrix.build_target }}
93+
${{ runner.os }}-guix-
5694
5795
- name: Create .cache folder if missing
5896
if: steps.guix-cache-restore.outputs.cache-hit != 'true'
@@ -67,8 +105,8 @@ jobs:
67105
-v ${{ github.workspace }}/dash:/src/dash \
68106
-v ${{ github.workspace }}/.cache:/home/ubuntu/.cache \
69107
-w /src/dash \
70-
guix_ubuntu:latest && \
71-
docker exec guix-daemon bash -c '/usr/local/bin/guix-start'
108+
ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-guix-builder:${{ needs.build-image.outputs.image-tag }} && \
109+
docker exec guix-daemon bash -c 'HOSTS=${{ matrix.build_target }} /usr/local/bin/guix-start'
72110
73111
- name: Ensure build passes
74112
run: |
@@ -77,17 +115,15 @@ jobs:
77115
exit 1
78116
fi
79117
80-
- name: Save Guix cache and depends
81-
id: guix-cache-save
82-
uses: actions/cache/save@v3
118+
- name: Compute SHA256 checksums
119+
continue-on-error: true # It will complain on depending on only some hosts
120+
run: |
121+
HOSTS=${{ matrix.build_target }} ./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash
122+
123+
- name: Upload build artifacts
124+
uses: actions/upload-artifact@v4
83125
with:
126+
name: guix-artifacts-${{ matrix.build_target }}
84127
path: |
85-
${{ github.workspace }}/.cache
86-
${{ github.workspace }}/dash/depends/built
87-
${{ github.workspace }}/dash/depends/sources
88-
${{ github.workspace }}/dash/depends/work
89-
key: ${{ steps.guix-cache-restore.outputs.cache-primary-key }}
128+
${{ github.workspace }}/dash/guix-build*/output/${{ matrix.build_target }}/
90129
91-
- name: Compute SHA256 checksums
92-
run: |
93-
./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash

0 commit comments

Comments
 (0)