forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
93 lines (82 loc) · 3.07 KB
/
guix-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Guix Build
on:
pull_request:
types: [ labeled ]
workflow_dispatch:
jobs:
build:
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-core" ]
if: contains(github.event.pull_request.labels.*.name, 'guix-build')
timeout-minutes: 480
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
path: dash
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Commit variables
id: dockerfile
run: |
echo "hash=$(sha256sum ./dash/contrib/containers/guix/Dockerfile | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
echo "host_user_id=$(id -u)" >> $GITHUB_OUTPUT
echo "host_group_id=$(id -g)" >> $GITHUB_OUTPUT
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/dash
build-args: |
USER_ID=${{ steps.dockerfile.outputs.host_user_id }}
GROUP_ID=${{ steps.dockerfile.outputs.host_group_id }}
build-contexts: |
docker_root=${{ github.workspace }}/dash/contrib/containers/guix
file: ./dash/contrib/containers/guix/Dockerfile
load: true
tags: guix_ubuntu:latest
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: 480
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'
- name: Ensure build passes
run: |
if [[ $? != 0 ]]; then
echo "Guix build failed!"
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