Skip to content

ci: add macOS and Windows builds to GitHub Actions, fix LC_ALL warning in Guix container, introduce artifact collection script for GitHub Actions #1091

ci: add macOS and Windows builds to GitHub Actions, fix LC_ALL warning in Guix container, introduce artifact collection script for GitHub Actions

ci: add macOS and Windows builds to GitHub Actions, fix LC_ALL warning in Guix container, introduce artifact collection script for GitHub Actions #1091

Workflow file for this run

name: CI
on:
push:
pull_request_target:
permissions:
contents: read
packages: write
env:
DOCKER_DRIVER: overlay2
FAST_MODE: false
jobs:
build-image:
name: Build Image
runs-on: ubuntu-22.04
outputs:
image-tag: ${{ steps.prepare.outputs.image-tag }}
repo-name: ${{ steps.prepare.outputs.repo-name }}
dep-matrix: ${{ steps.prepare.outputs.dep-matrix }}
src-matrix: ${{ steps.prepare.outputs.src-matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Prepare
id: prepare
run: |
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '[:upper:]' '[:lower:]')
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "image-tag=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "repo-name=${REPO_NAME}" >> $GITHUB_OUTPUT
echo "dep-matrix=$(jq -r '.dep' -c .github/workflows/matrix.json)" >> $GITHUB_OUTPUT
echo "src-matrix=$(jq -r '.src' -c .github/workflows/matrix.json)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./contrib/containers/ci
file: ./contrib/containers/ci/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:${{ steps.prepare.outputs.image-tag }}
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest
cache-from: type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest
cache-to: type=inline
build-depends:
name: ${{ matrix.depends_name }}
needs: build-image
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build-image.outputs.dep-matrix) }}
container:
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache depends sources
uses: actions/cache@v4
with:
path: |
depends/sources
key: depends-sources-${{ hashFiles('depends/packages/*') }}
restore-keys: |
depends-sources-
- name: Determine params
id: det-params
run: |
dep_name="${{ matrix.depends_name }}"
dep_opts="${{ matrix.dep_opts }}"
dep_hash="$(echo -n ${dep_opts} | sha256sum | head -c 64)"
echo "\"${dep_name}\" has DEP_OPTS \"${dep_opts}\" with hash \"${dep_hash}\""
echo "dep_hash=${dep_hash}" >> $GITHUB_OUTPUT
- name: Cache depends
uses: actions/cache@v4
with:
path: |
depends/${{ matrix.host }}
depends/built
depends/sdk-sources
depends/SDKs
key: ${{ runner.os }}-depends-${{ matrix.depends_name }}-${{ hashFiles('depends/packages/*') }}-${{ steps.det-params.outputs.dep_hash }}
restore-keys: |
${{ runner.os }}-depends-${{ matrix.depends_name }}-${{ hashFiles('depends/packages/*') }}-
${{ runner.os }}-depends-${{ matrix.depends_name }}-
- name: Build depends
run: |
export HOST="${{ matrix.host }}"
mkdir -p depends/SDKs depends/sdk-sources
if [[ "${HOST}" == "x86_64-apple-darwin" ]]; then
./ci/dash/setup-sdk.sh
fi
env ${{ matrix.dep_opts }} make -j$(nproc) -C depends
shell: bash
build:
name: ${{ matrix.build_target }}
needs: [build-image, build-depends]
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build-image.outputs.src-matrix) }}
container:
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Determine params
id: det-params
run: |
dep_name="${{ matrix.depends_name }}"
dep_opts="$(jq -r ".dep.include[] | select(.depends_name == \"${{ matrix.depends_name }}\") | .dep_opts" -c .github/workflows/matrix.json)"
dep_hash="$(echo -n ${dep_opts} | sha256sum | head -c 64)"
echo "\"${dep_name}\" has DEP_OPTS \"${dep_opts}\" with hash \"${dep_hash}\""
echo "dep_hash=${dep_hash}" >> $GITHUB_OUTPUT
dep_host="$(jq -r ".dep.include[] | select(.depends_name == \"${{ matrix.depends_name }}\") | .host" -c .github/workflows/matrix.json)"
echo "\"${dep_name}\" has HOST \"${dep_host}\""
echo "dep_host=${dep_host}" >> $GITHUB_OUTPUT
- name: Restore depends cache
uses: actions/cache/restore@v4
with:
path: |
depends/${{ steps.det-params.outputs.dep_host }}
depends/built
depends/sdk-sources
depends/SDKs
key: ${{ runner.os }}-depends-${{ matrix.depends_name }}-${{ hashFiles('depends/packages/*') }}-${{ steps.det-params.outputs.dep_hash }}
restore-keys: |
${{ runner.os }}-depends-${{ matrix.depends_name }}-${{ hashFiles('depends/packages/*') }}-
${{ runner.os }}-depends-${{ matrix.depends_name }}-
- name: Determine PR Base SHA
id: vars
run: |
echo "PR_BASE_SHA=${{ github.event.pull_request.base.sha || '' }}" >> $GITHUB_OUTPUT
- name: CCache
uses: actions/cache@v4
with:
path: |
/cache
key: ${{ runner.os }}-${{ matrix.build_target }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.build_target }}-${{ github.sha }}
${{ runner.os }}-${{ matrix.build_target }}-${{ steps.vars.outputs.PR_BASE_SHA }}
${{ runner.os }}-${{ matrix.build_target }}
- name: Build source and run tests
run: |
git config --global --add safe.directory "$PWD"
export ARTIFACT_PATH="/output"
export BUILD_TARGET="${{ matrix.build_target }}"
export CACHE_DIR="/cache"
export CCACHE_SIZE="400M"
source ./ci/dash/matrix.sh
./ci/dash/build_src.sh
./ci/dash/test_unittests.sh
./ci/dash/create-artifacts.sh
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts_${{ matrix.build_target }}
path: |
/output/artifacts_${{ matrix.build_target }}.tar.zst
/output/artifacts_${{ matrix.build_target }}.tar.zst.sha256
compression-level: 0
retention-days: 3