xref: /openssl/.github/workflows/make-test (revision 58ffcbbd)
1#!/usr/bin/env bash
2set -eo pipefail
3
4cleanup() {
5    # Remove if nothing was generated.
6    [ -d artifacts ] && find artifacts -type d -empty -delete
7}
8trap cleanup EXIT
9
10# Make a central directory to store all output artifacts of our test run to
11# avoid having to configure multiple upload-artifacts steps in the workflow
12# file.
13OSSL_CI_ARTIFACTS_PATH="artifacts/"
14if [ -n "${GITHUB_RUN_NUMBER}" ]; then
15    OSSL_CI_ARTIFACTS_PATH="artifacts/github-${GITHUB_JOB}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ID}/"
16fi
17mkdir -p "$OSSL_CI_ARTIFACTS_PATH"
18export OSSL_CI_ARTIFACTS_PATH="$(cd "$OSSL_CI_ARTIFACTS_PATH"; pwd)"
19
20# Run the tests. This might fail, but we need to capture artifacts anyway.
21set +e
22make test HARNESS_JOBS=${HARNESS_JOBS:-4} "$@"
23RESULT=$?
24set -e
25
26# Move an interesting subset of the test-runs data we want into the artifacts
27# staging directory.
28for test_name in quic_multistream; do
29    if [ -d "test-runs/test_${test_name}" ]; then
30        mv "test-runs/test_${test_name}" "$OSSL_CI_ARTIFACTS_PATH/"
31    fi
32done
33
34# Log the artifact tree.
35echo "::group::List of artifact files generated"
36echo "Test suite exited with $RESULT, artifacts path is $OSSL_CI_ARTIFACTS_PATH"
37(cd "$OSSL_CI_ARTIFACTS_PATH"; find . -type f | sort)
38echo "::endgroup::"
39
40echo "Archive artifacts"
41tar -czvf artifacts.tar.gz $OSSL_CI_ARTIFACTS_PATH
42
43exit $RESULT
44