Skip to content

Commit

Permalink
ci: upload functional test logs as artifacts
Browse files Browse the repository at this point in the history
We want logs even if tests fail, so we need some extra logic. Also, we
shouldn't create artifacts if there's nothing to upload, so there's
extra logic for that too.
  • Loading branch information
kwvg committed Feb 25, 2025
1 parent b25e846 commit fc2efb6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
name: ${{ inputs.bundle-key }}

- name: Run functional tests
id: test
run: |
git config --global --add safe.directory "$PWD"
export BUILD_TARGET="${{ inputs.build-target }}"
Expand All @@ -48,3 +49,27 @@ jobs:
source ./ci/dash/matrix.sh
./ci/dash/test_integrationtests.sh ${INTEGRATION_TESTS_ARGS}
shell: bash

- name: Bundle test logs
id: bundle
if: success() || (failure() && steps.test.outcome == 'failure')
run: |
export BUILD_TARGET="${{ inputs.build-target }}"
echo "short-sha=$(git rev-parse --short=8 HEAD)" >> "${GITHUB_OUTPUT}"
( [ -d "testlogs" ] && echo "upload-logs=true" >> "${GITHUB_OUTPUT}" && ./ci/dash/bundle-logs.sh ) \
|| echo "upload-logs=false" >> "${GITHUB_OUTPUT}"
shell: bash

- name: Upload test logs
uses: actions/upload-artifact@v4
if: |
success() || (failure() && steps.test.outcome == 'failure')
&& steps.bundle.outputs.upload-logs == 'true'
with:
name: test_logs-${{ inputs.build-target }}-${{ steps.bundle.outputs.short-sha }}
path: |
test_logs-${{ inputs.build-target }}.tar.zst
test_logs-${{ inputs.build-target }}.tar.zst.sha256
compression-level: 0
overwrite: true
retention-days: 1
28 changes: 28 additions & 0 deletions ci/dash/bundle-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/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

SH_NAME="$(basename "${0}")"
LOG_DIRECTORY="testlogs"

if [ ! -d "${LOG_DIRECTORY}" ]; then
echo "${SH_NAME}: '${LOG_DIRECTORY}' directory missing, will skip!";
exit 0;
elif [ -z "${BUILD_TARGET}" ]; then
echo "${SH_NAME}: BUILD_TARGET not defined, cannot continue!";
exit 1;
fi

LOG_ARCHIVE="test_logs-${BUILD_TARGET}.tar.zst"
if [ -f "${LOG_ARCHIVE}" ]; then
echo "${SH_NAME}: ${LOG_ARCHIVE} already exists, cannot continue!";
exit 1;
fi

tar --use-compress-program="zstd -T0 -5" -cf "${LOG_ARCHIVE}" "${LOG_DIRECTORY}"
sha256sum "${LOG_ARCHIVE}" > "${LOG_ARCHIVE}.sha256";

0 comments on commit fc2efb6

Please sign in to comment.