Skip to content

Commit 7729b3d

Browse files
weitzmanstasadev
andauthored
fix: make artifact uploads work (#67)
* Pass along TESTDIR value to GITHUB_ENV * Tweak test * See if Nightwatch artifact works * Fixing artifact uploads * Check if artifacts from several tests are stored * Check if artifacts are still uploaded for failed tests * Add always() * revert debug commits --------- Co-authored-by: Stanislav Zhuk <[email protected]>
1 parent 68747ea commit 7729b3d

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,29 @@ jobs:
3434

3535
steps:
3636
- uses: ddev/github-action-add-on-test@v2
37-
env:
38-
# Ensure that browser_output, junit, Nightwatch report are available as artifacts.
39-
SKIP_CLEANUP: "true"
4037
with:
4138
ddev_version: ${{ matrix.ddev_version }}
4239
token: ${{ secrets.GITHUB_TOKEN }}
4340
debug_enabled: ${{ github.event.inputs.debug_enabled }}
4441
addon_repository: ${{ env.GITHUB_REPOSITORY }}
4542
addon_ref: ${{ env.GITHUB_REF }}
4643

47-
- name: Archive browser_output
44+
# The path for one of the files in artifact is not valid
45+
- name: Zip artifacts that can't be processed by actions/upload-artifact
46+
if: always()
47+
run: |
48+
for d in ${{ env.TESTDIR }}*/; do
49+
if [ -d "$d/web/core/reports/nightwatch" ]; then
50+
(cd "$d/web/core/reports" && zip -r nightwatch.zip nightwatch)
51+
fi
52+
done
53+
54+
- name: Upload artifacts
55+
if: always()
4856
uses: actions/upload-artifact@v4
4957
with:
50-
name: browser_output
58+
name: artifact-${{ matrix.ddev_version }}
5159
path: |
52-
web/sites/simpletest/browser_output
53-
54-
- name: Archive junits
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: junits
58-
path: |
59-
*.junit.xml
60-
61-
- name: Nightwatch reports
62-
uses: actions/upload-artifact@v4
63-
with:
64-
name: nightwatch
65-
path: |
66-
web/core/reports/nightwatch
60+
${{ env.TESTDIR }}*/web/sites/simpletest/browser_output
61+
${{ env.TESTDIR }}*/web/*.junit.xml
62+
${{ env.TESTDIR }}*/web/core/reports/nightwatch.zip

tests/test.bats

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ setup() {
2626

2727
export DIR="$(cd "$(dirname "${BATS_TEST_FILENAME}")/.." >/dev/null 2>&1 && pwd)"
2828
export PROJNAME="test-$(basename "${GITHUB_REPO}")"
29-
export SKIP_CLEANUP=1
3029
mkdir -p ~/tmp
3130
export TESTDIR=$(mktemp -d ~/tmp/${PROJNAME}.XXXXXX)
3231
export DDEV_NONINTERACTIVE=true
@@ -90,7 +89,13 @@ health_checks() {
9089
teardown() {
9190
set -eu -o pipefail
9291
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
93-
[ ! -z "${SKIP_CLEANUP}" ] || ( [ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR} )
92+
# Persist TESTDIR if running inside GitHub Actions. Useful for uploading test result artifacts
93+
# See example at https://github.com/ddev/github-action-add-on-test#preserving-artifacts
94+
if [ -n "${GITHUB_ENV:-}" ]; then
95+
[ -e "${GITHUB_ENV:-}" ] && echo "TESTDIR=${HOME}/tmp/${PROJNAME}" >> "${GITHUB_ENV}"
96+
else
97+
[ "${TESTDIR}" != "" ] && rm -rf "${TESTDIR}"
98+
fi
9499
}
95100

96101
@test "install from directory" {

0 commit comments

Comments
 (0)