specify path to clone into #85
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Guix Build | |
permissions: | |
packages: write | |
on: | |
pull_request_target: | |
types: [labeled] | |
push: | |
workflow_dispatch: | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
outputs: | |
image-tag: ${{ steps.prepare.outputs.image-tag }} | |
repo-name: ${{ steps.prepare.outputs.repo-name }} | |
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: prepare | |
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 | |
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '[:upper:]' '[:lower:]') | |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
echo "::set-output name=image-tag::${BRANCH_NAME}" | |
echo "::set-output name=repo-name::${REPO_NAME}" | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: ${{ github.workspace }}/dash | |
build-args: | | |
USER_ID=${{ steps.prepare.outputs.host_user_id }} | |
GROUP_ID=${{ steps.prepare.outputs.host_group_id }} | |
build-contexts: | | |
docker_root=${{ github.workspace }}/dash/contrib/containers/guix | |
file: ./dash/contrib/containers/guix/Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:${{ steps.prepare.outputs.image-tag }} | |
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:latest | |
cache-from: type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:latest | |
cache-to: type=inline,mode=max | |
guix_build: | |
needs: build-image | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-guix-builder:${{ needs.build-image.outputs.image-tag }} | |
options: --user root | |
strategy: | |
matrix: | |
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] | |
timeout-minutes: 480 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: /src/dash | |
- name: Cache Guix and depends | |
id: guix-cache-restore | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ github.workspace }}/.cache | |
${{ github.workspace }}/dash/depends/built | |
${{ github.workspace }}/dash/depends/sources | |
${{ github.workspace }}/dash/depends/work | |
/gnu/store | |
key: ${{ runner.os }}-guix-${{ matrix.build_target }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-guix-${{ matrix.build_target }} | |
${{ runner.os }}-guix- | |
- name: Create .cache folder if missing | |
if: steps.guix-cache-restore.outputs.cache-hit != 'true' | |
run: mkdir -p ${{ github.workspace }}/.cache | |
- name: Start Guix Processes | |
working-directory: ${{ github.workspace }} | |
run: | | |
/usr/local/bin/entrypoint | |
# - name: Start Guix Container | |
# 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 \ | |
# ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-guix-builder:${{ steps.prepare.outputs.image-tag }} | |
- name: Restore Guix Archive | |
working-directory: ${{ github.workspace }} | |
run: | | |
if [ -f ${{ github.workspace }}/.cache/guix-archive.nar ]; then | |
/usr/local/bin/guix-restore-cache | |
else | |
echo "Guix archive file not found, skipping import." | |
fi | |
shell: bash | |
- name: Run Guix Build | |
continue-on-error: true | |
working-directory: ${{ github.workspace }} | |
run: | | |
HOSTS=${{ matrix.build_target }} timeout 60 /usr/local/bin/guix-start ${{ github.workspace }} | |
- name: Ensure build passes | |
run: | | |
if [[ $? != 0 ]]; then | |
echo "Guix build failed!" | |
exit 1 | |
fi | |
shell: bash | |
- name: Call Guix Archive | |
working-directory: ${{ github.workspace }} | |
run: | | |
/usr/local/bin/guix-save-cache ${{ github.workspace }} | |
shell: bash | |
- name: Compute SHA256 checksums | |
working-directory: ${{ github.workspace }} | |
continue-on-error: true | |
run: | | |
./dash/contrib/containers/guix/scripts/guix-check ${{ github.workspace }}/dash | |
shell: bash |