ci: build sqlite and tsan depends correctly #63
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: 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 }} | |
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 | |
- 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: | |
include: | |
- depends_name: arm-linux-gnueabihf | |
build_target: arm-linux | |
- depends_name: x86_64-pc-linux-gnu_debug | |
build_target: linux64 | |
- depends_name: x86_64-pc-linux-gnu_multiprocess | |
build_target: linux64_multiprocess | |
- depends_name: x86_64-pc-linux-gnu_sqlite | |
build_target: linux64_sqlite | |
- depends_name: x86_64-pc-linux-gnu_nowallet | |
build_target: linux64_nowallet | |
- depends_name: x86_64-pc-linux-gnu_tsan | |
build_target: linux64_tsan | |
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: | | |
BUILD_TARGET="${{ matrix.build_target }}" | |
source ./ci/dash/matrix.sh | |
echo "dep_opts=${DEP_OPTS}" >> $GITHUB_OUTPUT | |
dep_hash="$(echo -n ${DEP_OPTS} | sha256sum | head -c 64)" | |
echo "\"${{ matrix.depends_name }}\" has DEP_OPTS \"${DEP_OPTS}\" with hash \"${dep_hash}\"" | |
echo "dep_hash=${dep_hash}" >> $GITHUB_OUTPUT | |
echo "\"${{ matrix.depends_name }}\" has HOST \"${HOST}\"" | |
echo "dep_host=${HOST}" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Cache depends | |
uses: actions/cache@v4 | |
with: | |
path: | | |
depends/built | |
depends/${{ steps.det-params.outputs.dep_host }} | |
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: env HOST=${{ steps.det-params.outputs.dep_host }} ${{ steps.det-params.outputs.dep_opts }} make -j$(nproc) -C depends | |
build: | |
name: ${{ matrix.build_target }} | |
needs: [build-image, build-depends] | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- build_target: arm-linux | |
depends_name: arm-linux-gnueabihf | |
- build_target: linux64 | |
depends_name: x86_64-pc-linux-gnu_debug | |
- build_target: linux64_cxx20 | |
depends_name: x86_64-pc-linux-gnu_debug | |
- build_target: linux64_fuzz | |
depends_name: x86_64-pc-linux-gnu_debug | |
- build_target: linux64_multiprocess | |
depends_name: x86_64-pc-linux-gnu_multiprocess | |
- build_target: linux64_nowallet | |
depends_name: x86_64-pc-linux-gnu_nowallet | |
- build_target: linux64_sqlite | |
depends_name: x86_64-pc-linux-gnu_sqlite | |
- build_target: linux64_tsan | |
depends_name: x86_64-pc-linux-gnu_tsan | |
- build_target: linux64_ubsan | |
depends_name: x86_64-pc-linux-gnu_debug | |
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: | | |
BUILD_TARGET="${{ matrix.build_target }}" | |
source ./ci/dash/matrix.sh | |
dep_hash="$(echo -n ${DEP_OPTS} | sha256sum | head -c 64)" | |
echo "\"${{ matrix.build_target }}\" has DEP_OPTS \"${DEP_OPTS}\" with hash \"${dep_hash}\"" | |
echo "dep_hash=${dep_hash}" >> $GITHUB_OUTPUT | |
echo "\"${{ matrix.build_target }}\" has HOST \"${HOST}\"" | |
echo "dep_host=${HOST}" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Restore depends cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
depends/built | |
depends/${{ steps.det-params.outputs.dep_host }} | |
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" | |
CCACHE_SIZE="400M" | |
CACHE_DIR="/cache" | |
mkdir /output | |
BASE_OUTDIR="/output" | |
BUILD_TARGET="${{ matrix.build_target }}" | |
source ./ci/dash/matrix.sh | |
./ci/dash/build_src.sh | |
./ci/dash/test_unittests.sh | |
shell: bash | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts-${{ matrix.build_target }} | |
path: | | |
/output |