2023-05-16 05:15:34 +02:00
|
|
|
name: Guix Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [ labeled ]
|
2023-07-28 18:43:31 +02:00
|
|
|
workflow_dispatch:
|
2023-05-16 05:15:34 +02:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2023-07-28 18:43:31 +02:00
|
|
|
runs-on: [ "self-hosted", "linux", "x64", "ubuntu-core" ]
|
2023-05-16 05:15:34 +02:00
|
|
|
if: contains(github.event.pull_request.labels.*.name, 'guix-build')
|
2023-12-01 16:11:35 +01:00
|
|
|
timeout-minutes: 480
|
2023-05-16 05:15:34 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-10-20 15:14:46 +02:00
|
|
|
uses: actions/checkout@v4
|
2023-06-07 05:30:12 +02:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2023-12-01 16:11:35 +01:00
|
|
|
path: dash
|
2024-01-12 04:43:42 +01:00
|
|
|
fetch-depth: 0
|
2023-05-16 05:15:34 +02:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2023-10-20 15:14:46 +02:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-05-16 05:15:34 +02:00
|
|
|
|
2023-06-25 21:22:27 +02:00
|
|
|
- name: Commit variables
|
2023-05-16 05:15:34 +02:00
|
|
|
id: dockerfile
|
|
|
|
run: |
|
2023-12-01 16:11:35 +01:00
|
|
|
echo "hash=$(sha256sum ./dash/contrib/containers/guix/Dockerfile | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
|
2023-07-07 23:04:22 +02:00
|
|
|
echo "host_user_id=$(id -u)" >> $GITHUB_OUTPUT
|
|
|
|
echo "host_group_id=$(id -g)" >> $GITHUB_OUTPUT
|
2023-05-16 05:15:34 +02:00
|
|
|
|
|
|
|
- name: Build Docker image
|
2023-10-20 15:14:46 +02:00
|
|
|
uses: docker/build-push-action@v5
|
2023-05-16 05:15:34 +02:00
|
|
|
with:
|
2023-12-01 16:11:35 +01:00
|
|
|
context: ${{ github.workspace }}/dash
|
2023-06-25 21:22:27 +02:00
|
|
|
build-args: |
|
|
|
|
USER_ID=${{ steps.dockerfile.outputs.host_user_id }}
|
|
|
|
GROUP_ID=${{ steps.dockerfile.outputs.host_group_id }}
|
|
|
|
build-contexts: |
|
2023-12-01 16:11:35 +01:00
|
|
|
docker_root=${{ github.workspace }}/dash/contrib/containers/guix
|
|
|
|
file: ./dash/contrib/containers/guix/Dockerfile
|
2023-05-16 05:15:34 +02:00
|
|
|
load: true
|
2023-06-25 21:22:27 +02:00
|
|
|
tags: guix_ubuntu:latest
|
2023-10-20 15:14:46 +02:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|
2023-05-16 05:15:34 +02:00
|
|
|
|
2023-12-01 16:11:35 +01:00
|
|
|
- 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
|
|
|
|
|
2023-05-16 05:15:34 +02:00
|
|
|
- name: Run Guix build
|
2023-12-01 16:11:35 +01:00
|
|
|
timeout-minutes: 480
|
2023-05-16 05:15:34 +02:00
|
|
|
run: |
|
2023-06-25 21:22:27 +02:00
|
|
|
docker run --privileged -d --rm -t \
|
|
|
|
--name guix-daemon \
|
2023-06-28 20:59:16 +02:00
|
|
|
-e ADDITIONAL_GUIX_COMMON_FLAGS="--max-jobs=$(nproc --all)" \
|
2023-12-01 16:11:35 +01:00
|
|
|
-v ${{ github.workspace }}/dash:/src/dash \
|
|
|
|
-v ${{ github.workspace }}/.cache:/home/ubuntu/.cache \
|
2023-06-25 21:22:27 +02:00
|
|
|
-w /src/dash \
|
|
|
|
guix_ubuntu:latest && \
|
2023-06-28 20:59:16 +02:00
|
|
|
docker exec guix-daemon bash -c '/usr/local/bin/guix-start'
|
2023-05-16 05:15:34 +02:00
|
|
|
|
|
|
|
- name: Ensure build passes
|
|
|
|
run: |
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo "Guix build failed!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-06-28 20:59:16 +02:00
|
|
|
|
2023-12-01 16:11:35 +01:00
|
|
|
- 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 }}
|
|
|
|
|
2023-06-28 20:59:16 +02:00
|
|
|
- name: Compute SHA256 checksums
|
2023-05-16 05:15:34 +02:00
|
|
|
run: |
|
2023-12-01 16:11:35 +01:00
|
|
|
./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash
|