mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
66f67879dc
2f18c1af30
ci: deduplicate depends building (pasta) Pull request description: ## Issue being fixed or feature implemented Currently we build the same host / options multiple times. Don't do this! ## What was done? Now building depends only twice ## How Has This Been Tested? Local CI appears to be working ## Breaking Changes None ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: kwvg: utACK2f18c1af30
UdjinM6: utACK2f18c1af30
Tree-SHA512: 67460508a2e9458152f7c8bb5f4a1a786aedcfded0e5c54fb03d85010ba8bb87362b66a0c322b51aeba75752e36418fc235d8dc4197ef10695e234ccc5a00a39
190 lines
5.9 KiB
YAML
190 lines
5.9 KiB
YAML
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: Build Dependencies
|
|
needs: build-image
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- build_target: arm-linux
|
|
host: arm-linux-gnueabihf
|
|
- build_target: linux64
|
|
host: x86_64-pc-linux-gnu
|
|
|
|
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: Cache dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
depends/${{ matrix.host }}
|
|
key: ${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}
|
|
${{ runner.os }}-depends-${{ matrix.build_target }}
|
|
|
|
- name: Build dependencies
|
|
run: make -j$(nproc) -C depends HOST=${{ matrix.host }}
|
|
|
|
- name: Upload built depends
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: depends-${{ matrix.build_target }}
|
|
path: depends/${{ matrix.host }}
|
|
|
|
build:
|
|
name: Build
|
|
needs: [build-image, build-depends]
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- build_target: arm-linux
|
|
host: arm-linux-gnueabihf
|
|
depends_on: arm-linux
|
|
- build_target: linux64
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_tsan
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_ubsan
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_fuzz
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_cxx20
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_sqlite
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
- build_target: linux64_nowallet
|
|
host: x86_64-pc-linux-gnu
|
|
depends_on: linux64
|
|
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: Download built depends
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: depends-${{ matrix.depends_on }}
|
|
path: depends/${{ matrix.host }}
|
|
|
|
- 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
|