diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f3937fe..115f6a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,9 +34,6 @@ jobs: steps: - uses: ddev/github-action-add-on-test@v2 - env: - # Ensure that browser_output, junit, Nightwatch report are available as artifacts. - SKIP_CLEANUP: "true" with: ddev_version: ${{ matrix.ddev_version }} token: ${{ secrets.GITHUB_TOKEN }} @@ -44,23 +41,22 @@ jobs: addon_repository: ${{ env.GITHUB_REPOSITORY }} addon_ref: ${{ env.GITHUB_REF }} - - name: Archive browser_output + # The path for one of the files in artifact is not valid + - name: Zip artifacts that can't be processed by actions/upload-artifact + if: always() + run: | + for d in ${{ env.TESTDIR }}*/; do + if [ -d "$d/web/core/reports/nightwatch" ]; then + (cd "$d/web/core/reports" && zip -r nightwatch.zip nightwatch) + fi + done + + - name: Upload artifacts + if: always() uses: actions/upload-artifact@v4 with: - name: browser_output + name: artifact-${{ matrix.ddev_version }} path: | - web/sites/simpletest/browser_output - - - name: Archive junits - uses: actions/upload-artifact@v4 - with: - name: junits - path: | - *.junit.xml - - - name: Nightwatch reports - uses: actions/upload-artifact@v4 - with: - name: nightwatch - path: | - web/core/reports/nightwatch + ${{ env.TESTDIR }}*/web/sites/simpletest/browser_output + ${{ env.TESTDIR }}*/web/*.junit.xml + ${{ env.TESTDIR }}*/web/core/reports/nightwatch.zip diff --git a/tests/test.bats b/tests/test.bats index dc64048..c8aea4f 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -26,7 +26,6 @@ setup() { export DIR="$(cd "$(dirname "${BATS_TEST_FILENAME}")/.." >/dev/null 2>&1 && pwd)" export PROJNAME="test-$(basename "${GITHUB_REPO}")" - export SKIP_CLEANUP=1 mkdir -p ~/tmp export TESTDIR=$(mktemp -d ~/tmp/${PROJNAME}.XXXXXX) export DDEV_NONINTERACTIVE=true @@ -90,7 +89,13 @@ health_checks() { teardown() { set -eu -o pipefail ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 - [ ! -z "${SKIP_CLEANUP}" ] || ( [ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR} ) + # Persist TESTDIR if running inside GitHub Actions. Useful for uploading test result artifacts + # See example at https://github.com/ddev/github-action-add-on-test#preserving-artifacts + if [ -n "${GITHUB_ENV:-}" ]; then + [ -e "${GITHUB_ENV:-}" ] && echo "TESTDIR=${HOME}/tmp/${PROJNAME}" >> "${GITHUB_ENV}" + else + [ "${TESTDIR}" != "" ] && rm -rf "${TESTDIR}" + fi } @test "install from directory" {