Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: extract "slim" container to run functional tests and add multiprocess and tsan, drop unneeded packages #6604

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**
!contrib/containers/ci/Dockerfile
!contrib/containers/ci/ci.Dockerfile
!contrib/containers/ci/ci-slim.Dockerfile
!contrib/containers/deploy/Dockerfile
!contrib/containers/develop/Dockerfile
31 changes: 22 additions & 9 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ name: Build container

on:
workflow_call:
inputs:
context:
description: "Path to use for build context"
required: true
type: string
file:
description: "Path to Dockerfile"
required: true
type: string
name:
description: "Container name"
required: true
type: string
outputs:
path:
description: "Path to built container"
value: ghcr.io/${{ jobs.build.outputs.repo }}/dashcore-ci-runner:${{ jobs.build.outputs.tag }}
value: ghcr.io/${{ jobs.build.outputs.repo }}/${{ inputs.name }}:${{ jobs.build.outputs.tag }}

env:
DOCKER_DRIVER: overlay2
Expand Down Expand Up @@ -44,15 +57,15 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./contrib/containers/ci
file: ./contrib/containers/ci/Dockerfile
context: ${{ inputs.context }}
file: ${{ inputs.file }}
push: true
tags: |
ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:${{ hashFiles('./contrib/containers/ci/Dockerfile') }}
ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:${{ steps.prepare.outputs.tag }}
ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:latest
ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:${{ hashFiles(inputs.file) }}
ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:${{ steps.prepare.outputs.tag }}
ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:latest
cache-from: |
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:${{ hashFiles('./contrib/containers/ci/Dockerfile') }}
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:${{ steps.prepare.outputs.tag }}
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/dashcore-ci-runner:latest
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:${{ hashFiles(inputs.file) }}
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:${{ steps.prepare.outputs.tag }}
type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo }}/${{ inputs.name }}:latest
cache-to: type=inline
6 changes: 3 additions & 3 deletions .github/workflows/build-depends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ jobs:
path: |
depends/built
depends/${{ steps.setup.outputs.HOST }}
key: depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-${{ hashFiles('depends/packages/*') }}
key: depends-${{ hashFiles('contrib/containers/ci/ci.Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-${{ hashFiles('depends/packages/*') }}
restore-keys: |
depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-
depends-${{ hashFiles('contrib/containers/ci/Dockerfile') }}-${{ inputs.build-target }}-
depends-${{ hashFiles('contrib/containers/ci/ci.Dockerfile') }}-${{ inputs.build-target }}-${{ steps.setup.outputs.DEP_HASH }}-
depends-${{ hashFiles('contrib/containers/ci/ci.Dockerfile') }}-${{ inputs.build-target }}-

- name: Build depends
run: |
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
with:
path: |
/cache
key: ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
key: ccache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-${{ github.sha }}
restore-keys: |
ccache-${{ hashFiles('contrib/containers/ci/Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-
ccache-${{ hashFiles('contrib/containers/ci/ci.Dockerfile', 'depends/packages/*') }}-${{ inputs.build-target }}-

- name: Build source
run: |
Expand All @@ -87,6 +87,14 @@ jobs:
ccache -c
shell: bash

- name: Run linters
if: inputs.build-target == 'linux64_multiprocess'
run: |
export BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
./ci/dash/lint-tidy.sh
shell: bash

- name: Run unit tests
run: |
BASE_OUTDIR="/output"
Expand Down
46 changes: 38 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ jobs:
container:
name: Build container
uses: ./.github/workflows/build-container.yml
with:
context: ./contrib/containers/ci
file: ./contrib/containers/ci/ci.Dockerfile
name: dashcore-ci-runner

container-slim:
name: Build slim container
uses: ./.github/workflows/build-container.yml
with:
context: ./contrib/containers/ci
file: ./contrib/containers/ci/ci-slim.Dockerfile
name: dashcore-ci-slim

depends-arm-linux:
name: arm-linux-gnueabihf
Expand Down Expand Up @@ -158,35 +170,53 @@ jobs:
test-linux64:
name: linux64-test
uses: ./.github/workflows/test-src.yml
needs: [container, src-linux64]
needs: [container-slim, src-linux64]
with:
bundle-key: ${{ needs.src-linux64.outputs.key }}
build-target: linux64
container-path: ${{ needs.container.outputs.path }}
container-path: ${{ needs.container-slim.outputs.path }}

test-linux64_multiprocess:
name: linux64_multiprocess-test
uses: ./.github/workflows/test-src.yml
needs: [container-slim, src-linux64_multiprocess]
with:
bundle-key: ${{ needs.src-linux64_multiprocess.outputs.key }}
build-target: linux64_multiprocess
container-path: ${{ needs.container-slim.outputs.path }}

test-linux64_nowallet:
name: linux64_nowallet-test
uses: ./.github/workflows/test-src.yml
needs: [container, src-linux64_nowallet]
needs: [container-slim, src-linux64_nowallet]
with:
bundle-key: ${{ needs.src-linux64_nowallet.outputs.key }}
build-target: linux64_nowallet
container-path: ${{ needs.container.outputs.path }}
container-path: ${{ needs.container-slim.outputs.path }}

test-linux64_sqlite:
name: linux64_sqlite-test
uses: ./.github/workflows/test-src.yml
needs: [container, src-linux64_sqlite]
needs: [container-slim, src-linux64_sqlite]
with:
bundle-key: ${{ needs.src-linux64_sqlite.outputs.key }}
build-target: linux64_sqlite
container-path: ${{ needs.container.outputs.path }}
container-path: ${{ needs.container-slim.outputs.path }}

test-linux64_tsan:
name: linux64_tsan-test
uses: ./.github/workflows/test-src.yml
needs: [container-slim, src-linux64_tsan]
with:
bundle-key: ${{ needs.src-linux64_tsan.outputs.key }}
build-target: linux64_tsan
container-path: ${{ needs.container-slim.outputs.path }}

test-linux64_ubsan:
name: linux64_ubsan-test
uses: ./.github/workflows/test-src.yml
needs: [container, src-linux64_ubsan]
needs: [container-slim, src-linux64_ubsan]
with:
bundle-key: ${{ needs.src-linux64_ubsan.outputs.key }}
build-target: linux64_ubsan
container-path: ${{ needs.container.outputs.path }}
container-path: ${{ needs.container-slim.outputs.path }}
7 changes: 4 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ builder-image:
- echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
script:
- cd contrib/containers/ci
- export DOCKER_BUILDKIT=1
- docker pull $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG || true
- docker pull $CI_REGISTRY_IMAGE:builder-develop || true
- docker build --cache-from $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG --cache-from $CI_REGISTRY_IMAGE:builder-develop -t $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG -f Dockerfile .
- docker build --cache-from $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG --cache-from $CI_REGISTRY_IMAGE:builder-develop -t $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG -f ci.Dockerfile .
- docker push $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG

.build-depends-template:
Expand All @@ -56,7 +57,7 @@ builder-image:
# Let all branches share the same cache, which is ok because the depends subsystem is able to handle this properly (it works with hashes of all scripts)
key:
files:
- contrib/containers/ci/Dockerfile
- contrib/containers/ci/ci.Dockerfile
prefix: ${CI_JOB_NAME}
paths:
- depends/built
Expand Down Expand Up @@ -116,7 +117,7 @@ builder-image:
# Let all branches share the same cache, which is ok because ccache is able to handle it
key:
files:
- contrib/containers/ci/Dockerfile
- contrib/containers/ci/ci.Dockerfile
prefix: ${CI_JOB_NAME}
paths:
- cache/ccache
Expand Down
25 changes: 7 additions & 18 deletions ci/dash/build_src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ set -e

source ./ci/dash/matrix.sh

unset CC; unset CXX
unset DISPLAY
unset CC CXX DISPLAY;

if [ "$PULL_REQUEST" != "false" ]; then test/lint/commit-script-check.sh $COMMIT_RANGE; fi

Expand Down Expand Up @@ -51,6 +50,8 @@ make distdir VERSION=$BUILD_TARGET
cd dashcore-$BUILD_TARGET
bash -c "./configure $BITCOIN_CONFIG_ALL $BITCOIN_CONFIG" || ( cat config.log && false)

# This step influences compilation and therefore will always be a part of the
# compile step
if [ "${RUN_TIDY}" = "true" ]; then
MAYBE_BEAR="bear --config src/.bear-tidy-config"
MAYBE_TOKEN="--"
Expand All @@ -65,22 +66,10 @@ if [ -n "$USE_VALGRIND" ]; then
${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh
fi

if [ "${RUN_TIDY}" = "true" ]; then
set -eo pipefail
cd src
( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"
cd ..
iwyu_tool.py \
"src/compat" \
"src/init" \
"src/rpc/fees.cpp" \
"src/rpc/signmessage.cpp" \
-p . "${MAKEJOBS}" \
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
|& tee "/tmp/iwyu_ci.out"
cd src
fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out
git --no-pager diff
# GitHub Actions can segment a job into steps, linting is a separate step
# so Actions runners will perform this step separately.
if [ "${RUN_TIDY}" = "true" ] && [ "${GITHUB_ACTIONS}" != "true" ]; then
${BASE_ROOT_DIR}/ci/dash/lint-tidy.sh
fi

if [ "$RUN_SECURITY_TESTS" = "true" ]; then
Expand Down
29 changes: 29 additions & 0 deletions ci/dash/lint-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Copyright (c) 2025 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C.UTF-8

set -eo pipefail

# Warning: This script does not generate the compilation database these linters rely
# only on nor do they set the requisite build parameters. Make sure you do
# that *before* running this script.

cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}/src"
( run-clang-tidy -quiet "${MAKEJOBS}" ) | grep -C5 "error"

cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}"
iwyu_tool.py \
"src/compat" \
"src/init" \
"src/rpc/fees.cpp" \
"src/rpc/signmessage.cpp" \
-p . "${MAKEJOBS}" \
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
2>&1 | tee "/tmp/iwyu_ci.out"

cd "${BASE_ROOT_DIR}/build-ci/dashcore-${BUILD_TARGET}/src"
fix_includes.py --nosafe_headers < /tmp/iwyu_ci.out
git --no-pager diff
2 changes: 1 addition & 1 deletion ci/dash/slim-workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TARGETS=(
"build-ci/dashcore-${BUILD_TARGET}/src/qt/qrc_dash_locale.cpp"
)

# Delete directories we don't need
# Delete what we don't need
for target in "${TARGETS[@]}"
do
if [[ -d "${target}" ]] || [[ -f "${target}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion ci/dash/test_integrationtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if [ "$BASEDIR" != "" ]; then
for f in $LOGFILES; do
d2="testlogs/$d/$(dirname $f)"
mkdir -p $d2
cp testdatadirs/$BASEDIR/$d/$f $d2/
mv testdatadirs/$BASEDIR/$d/$f $d2/
done
done
fi
Expand Down
26 changes: 16 additions & 10 deletions contrib/containers/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
## Containers

This directory contains configuration files for containerization utilities.
This directory contains configuration files for containers. Containers that depends on other containers require BuildKit to
be enabled in order for syntax extensions to work correctly.

Currently two Docker containers exist, `ci` defines how Dash's GitLab CI container is built and the `dev` builds on top of the `ci` to provide a containerized development environment that is as close as possible to CI for contributors! See also [Dash on Docker Hub](https://hub.docker.com/u/dashpay) i.e. for the [dashd container](https://hub.docker.com/r/dashpay/dashd).
| Name | Depends On | Purpose |
| --------- | -----------| -------------------------------------------------------------------------- |
| `ci-slim` | None | Slimmed down container used to run functional tests and (some) linters |
| `ci` | `ci-slim` | Full container used to (cross) compile |
| `develop` | `ci` | Interactive environment to allow debugging in an environment that's 1:1 CI |
| `deploy` | None | Packaging of builds for release on Docker Hub |
| `guix` | None | Interactive environment for building (and packaging) with Guix |

### Usage Guide

We utilise edrevo's [dockerfile-plus](https://github.com/edrevo/dockerfile-plus), a syntax extension that
leverages Docker [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) to reduce
We utilise edrevo's [devthefuture/dockerfile-x](https://codeberg.org/devthefuture/dockerfile-x), a syntax extension that
leverages Docker [BuildKit](https://docs.docker.com/build/buildkit/) to reduce
the amount of repetitive code.

As BuildKit is opt-in within many currently supported versions of Docker (as of this writing), you need to
set the following environment variables before continuing. While not needed after the initial `docker compose build`
(barring updates to the `Dockerfile`), we recommend placing this in your `~/.bash_profile`/`~/.zshrc` or equivalent
As BuildKit is opt-in within some versions of Docker, you may need to set the following environment variables before
continuing. While not needed after the initial `docker compose build` (barring updates to the `Dockerfile`), we
recommend placing this in your `~/.bash_profile`/`~/.zshrc` or equivalent

```bash
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
```

After that, it's simply a matter of building and running your own development container. You can use extensions
for your IDE like Visual Studio Code's [Remote Containers](https://code.visualstudio.com/docs/remote/containers)
to run terminal commands from inside the terminal and build Dash Core.
You can use extensions for your IDE like Visual Studio Code's [Remote Containers](https://code.visualstudio.com/docs/remote/containers)
to run terminal commands from inside the terminal and work with Dash Core.

```bash
cd contrib/containers/develop
Expand Down
Loading
Loading