Skip to content

Commit

Permalink
ci: use helper script to bundle artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Feb 24, 2025
1 parent b4e2269 commit 57cf278
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/build-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ on:
description: "Key needed to access cached depends"
required: true
type: string
outputs:
key:
description: "Key needed for restoring artifacts bundle"
value: ${{ jobs.build-src.outputs.key }}

jobs:
build-src:
name: Build source
runs-on: ubuntu-24.04
outputs:
key: ${{ steps.bundle.outputs.key }}
container:
image: ${{ inputs.container-path }}
options: --user root
Expand Down Expand Up @@ -89,9 +95,20 @@ jobs:
./ci/dash/test_unittests.sh
shell: bash

- name: Upload build artifacts
- name: Bundle artifacts
id: bundle
run: |
export BUILD_TARGET="${{ inputs.build-target }}"
export BUNDLE_KEY="build-${BUILD_TARGET}-$(git rev-parse --short=8 HEAD)"
./ci/dash/bundle-artifacts.sh create
echo "key=${BUNDLE_KEY}" >> "${GITHUB_OUTPUT}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ inputs.build-target }}
name: ${{ steps.bundle.outputs.key }}
path: |
/output
${{ steps.bundle.outputs.key }}.tar.zst
compression-level: 0
overwrite: true
retention-days: 3
64 changes: 64 additions & 0 deletions ci/dash/bundle-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
# Copyright (c) 2024-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

SH_NAME="$(basename "${0}")"
VERB="${1}"

if [ -z "${BUILD_TARGET}" ]; then
echo "${SH_NAME}: BUILD_TARGET not defined, cannot continue!";
exit 1;
elif [ -z "${BUNDLE_KEY}" ]; then
echo "${SH_NAME}: BUNDLE_KEY not defined, cannot continue!";
exit 1;
elif [ ! "$(command -v zstd)" ]; then
echo "${SH_NAME}: zstd not found, cannot continue!";
exit 1;
elif [ -z "${VERB}" ]; then
echo "${SH_NAME}: Verb missing, acceptable values 'create' or 'extract'";
exit 1;
elif [ "${VERB}" != "create" ] && [ "${VERB}" != "extract" ]; then
echo "${SH_NAME}: Invalid verb '${VERB}', expected 'create' or 'extract'";
exit 1;
fi

OUTPUT_ARCHIVE="${BUNDLE_KEY}.tar.zst"
if [ -f "${OUTPUT_ARCHIVE}" ] && [ "${VERB}" = "create" ]; then
echo "${SH_NAME}: ${OUTPUT_ARCHIVE} already exists, cannot continue!";
exit 1;
elif [ ! -f "${OUTPUT_ARCHIVE}" ] && [ "${VERB}" = "extract" ]; then
echo "${SH_NAME}: ${OUTPUT_ARCHIVE} missing, cannot continue!";
exit 1;
fi

if [ "${VERB}" = "create" ]; then
EXCLUSIONS=(
"*.a"
"*.o"
"build-ci/dashcore-${BUILD_TARGET}/src/bench/bench_dash"
"build-ci/dashcore-${BUILD_TARGET}/src/bench/bench_dash.exe"
"build-ci/dashcore-${BUILD_TARGET}/src/qt/test/test_dash-qt"
"build-ci/dashcore-${BUILD_TARGET}/src/qt/test/test_dash-qt.exe"
"build-ci/dashcore-${BUILD_TARGET}/src/test/test_dash"
"build-ci/dashcore-${BUILD_TARGET}/src/test/test_dash.exe"
"build-ci/dashcore-${BUILD_TARGET}/src/test/fuzz/fuzz"
)
EXCLUSIONS_ARG=""
for excl in "${EXCLUSIONS[@]}"
do
EXCLUSIONS_ARG+=" --exclude=${excl}";
done

# shellcheck disable=SC2086
tar ${EXCLUSIONS_ARG} --use-compress-program="zstd -T0 -5" -cf "${OUTPUT_ARCHIVE}" "build-ci";
elif [ "${VERB}" = "extract" ]; then
tar --use-compress-program="unzstd" -xf "${OUTPUT_ARCHIVE}";
else
echo "${SH_NAME}: Generic error";
exit 1;
fi
1 change: 1 addition & 0 deletions contrib/containers/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ RUN apt-get update && apt-get install $APT_ARGS \
wine-stable \
wine64 \
zip \
zstd \
&& rm -rf /var/lib/apt/lists/*

# Make sure std::thread and friends is available
Expand Down

0 comments on commit 57cf278

Please sign in to comment.