From 914227ca1c703ce28242b86b08e5e350d75ebdbf Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 18 Aug 2024 11:45:51 +1200 Subject: [PATCH] Set TMPDIR to RUNNER_TEMP on CI The upload artifact action can't collect artifacts from /tmp/ in the test runners. So now that we are writing the screenshots that we want to collect later to the pytest `tmp_path` location we need to make sure that lives somewhere the later actions can find it. Pytest uses `tempfile.gettempdir()` to find the temp dir, and that respects a number of environment variables including `TMPDIR`. This commits sets TMPDIR to RUNNER_TEMP in in our test runners to make pytest uses the temp dir that's mounted into the action containers. For the docker based runners I can use the `env` map, but for the ubuntu ones it didn't let me expand `${{ runner.temp }}` in the end map under `step`, so I'm writing it to the env file for the runner instead. It failed to parse the action yaml and said: > Unrecognized named-value: 'runner'. Located at position 1 within expression: runner.temp For the user part of the `pytest-of-$user` directory, I looked at the new screenshot related test summary lines to see what the user was called. `runner` on the ubuntu containers and `user` in our docker containers. Pytest maintains the "pytest-current" symlink to the latest temp folder. --- .github/workflows/bleeding.yml | 3 ++- .github/workflows/ci.yml | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bleeding.yml b/.github/workflows/bleeding.yml index 97d95adde..ce4531b00 100644 --- a/.github/workflows/bleeding.yml +++ b/.github/workflows/bleeding.yml @@ -27,6 +27,7 @@ jobs: PY_COLORS: "1" DOCKER: "${{ matrix.image }}" CI: true + TMPDIR: "${{ runner.temp }}" volumes: # Hardcoded because we can't use ${{ runner.temp }} here apparently. - /home/runner/work/_temp/:/home/runner/work/_temp/ @@ -54,7 +55,7 @@ jobs: with: name: "end2end-screenshots-${{ steps.info.outputs.date }}-${{ steps.info.outputs.sha_short }}-${{ matrix.image }}" path: | - ${{ runner.temp }}/pytest-screenshots/*.png + ${{ runner.temp }}/pytest-of-user/pytest-current/pytest-screenshots/*.png if-no-files-found: ignore if: failure() irc: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94f561999..1e0c84bc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,7 @@ jobs: DOCKER: "${{ matrix.image }}" CI: true PYTEST_ADDOPTS: "--color=yes" + TMPDIR: "${{ runner.temp }}" volumes: # Hardcoded because we can't use ${{ runner.temp }} here apparently. - /home/runner/work/_temp/:/home/runner/work/_temp/ @@ -131,7 +132,7 @@ jobs: with: name: "end2end-screenshots-${{ steps.info.outputs.date }}-${{ steps.info.outputs.sha_short }}-${{ matrix.image }}" path: | - ${{ runner.temp }}/pytest-screenshots/*.png + ${{ runner.temp }}/pytest-of-user/pytest-current/pytest-screenshots/*.png if-no-files-found: ignore if: failure() @@ -237,6 +238,8 @@ jobs: - name: Upgrade 3rd party assets run: "tox exec -e ${{ matrix.testenv }} -- python scripts/dev/update_3rdparty.py --gh-token ${{ secrets.GITHUB_TOKEN }}" if: "startsWith(matrix.os, 'windows-')" + - name: "Set TMPDIR for pytest" + run: 'echo "TMPDIR=${{ runner.temp }}" >> "$GITHUB_ENV"' - name: "Run ${{ matrix.testenv }}" run: "dbus-run-session -- tox -e ${{ matrix.testenv }} -- ${{ matrix.args }}" if: "startsWith(matrix.os, 'ubuntu-')" @@ -263,7 +266,7 @@ jobs: with: name: "end2end-screenshots-${{ steps.info.outputs.date }}-${{ steps.info.outputs.sha_short }}-${{ matrix.testenv }}-${{ matrix.os }}" path: | - ${{ runner.temp }}/pytest-screenshots/*.png + ${{ runner.temp }}/pytest-of-runner/pytest-current/pytest-screenshots/*.png if-no-files-found: ignore if: failure()