Skip to content

Conversation

@danielrbradley
Copy link
Contributor

@danielrbradley danielrbradley commented Mar 17, 2025

Part 1: Allow using ENV vars for temp directory control

  • Add specific environment variable to always retain directories and fix instruction that didn't work for passing tests to use the new variable.
  • Document environment variables in readme and document decision process for retaining directories in code comments.
  • Allow setting a default temp dir via env var - this would allow it to be configured more easily in CI so that we can grab failed test directories as workflow assets.

Example config file to use this locally when running in VSCode:

{
  "go.testTimeout": "320s",
  "go.testEnvVars": {
    "PULUMITEST_TEMP_DIR": "${workspaceFolder}/.tmp",
  }
}

Part 2: Run with custom temp dir in CI & capture failures

This highlighted that we need to make the initial directory creation safe (added a mutex & rewrote a bad test). This also sets up an example of how to execute tests in CI and capture the temp directory on failure.

GitHub actions example:

      - name: Run acceptance tests
        run: go test
        env:
          PULUMITEST_TEMP_DIR: ${{ github.workspace }}/test_temp
          PULUMITEST_RETAIN_FILES_ON_FAILURE: "true"

      - name: Upload test_temp directory on failure
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          path: test_temp

Example test run with failing test: https://github.com/pulumi/providertest/actions/runs/13902023819?pr=127

- Add specific environment variable to always retain.
- Fix instruction that doesn't actually always retain directories.
- Document decision process for retaining directories.
- Document environment variables in readme.
@danielrbradley danielrbradley self-assigned this Mar 17, 2025
@danielrbradley danielrbradley requested review from a team and guineveresaenger March 17, 2025 11:44
@danielrbradley danielrbradley changed the title Fix retention of temp dir instructions & document Fix retention of temp dir & document Mar 17, 2025
@danielrbradley danielrbradley changed the title Fix retention of temp dir & document Fix retention & location of temp dir via env vars Mar 17, 2025
Use per-test temp dir to avoid having to delete global directory used by other tests.
Retain files in CI (not default)
@danielrbradley danielrbradley merged commit 5bc96e4 into main Mar 17, 2025
3 checks passed
@danielrbradley danielrbradley deleted the fix-retain-temp-dirs branch March 17, 2025 17:37
@pulumi-bot
Copy link

This PR has been shipped in release v0.1.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants