Fix tox CI failure: replace invalid {homedir}/tmp with {envtmpdir}/{toxworkdir}#62
Closed
Fix tox CI failure: replace invalid {homedir}/tmp with {envtmpdir}/{toxworkdir}#62
Conversation
…x.ini Agent-Logs-Url: https://github.com/mitre/atomic/sessions/31ec9e8d-352a-4354-ba16-118f3c6f26d5 Co-authored-by: deacon-mp <61169193+deacon-mp@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CI failure in PR #61 for mitre/atomic
Fix tox CI failure: replace invalid {homedir}/tmp with {envtmpdir}/{toxworkdir}
Apr 30, 2026
Contributor
|
Superseded by #63 (which now has CI green and consolidates the tox fix). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
{homedir}is not a valid tox substitution on the CI runner — tox treats it literally, creating a{homedir}/tmpsubdirectory inside the repo. Thecp -R {toxinidir}destination then falls within the source tree, causingcp: cannot copy a directory into itself. Downstream,coverage-cifails withNo data to combinebecause tests never ran.Changes:
[testenv]/[testenv:py38]: Replacechangedir = {homedir}/tmpand all{homedir}/tmp/...path references with{envtmpdir}— a tox-managed per-env temp dir guaranteed outside the reposetenv = COVERAGE_FILE = {toxworkdir}/.coveragesocoverage run -pwrites.coverage.<host>.<pid>files to the stable.tox/dir, shared across all envs[testenv:coverage]/[testenv:coverage-ci]: Changechangedirto{toxworkdir}socoverage combineruns where the parallel data files were writtenallowlist_externals: Use bare command names (git,rm,cp) instead of absolute paths with wildcardsType of change
How Has This Been Tested?
Validated against the CI job logs from job 73814718704 confirming the root cause. The fix was reviewed via automated code review and CodeQL scan (no issues found).
Checklist:
Original prompt
Fix CI failure in PR #61 / job 73814718704 for
mitre/atomic.Observed failure (from Actions job logs for jobId 73814718704):
py310, commandcp -R /home/runner/work/atomic/atomic '{homedir}/tmp/plugins/atomic'fails with:/usr/bin/cp: cannot copy a directory, '/home/runner/work/atomic/atomic', into itself, '{homedir}/tmp/plugins/atomic'{homedir}/tmpresolves to a path under the checked-out repository directory on the runner, so{homedir}/tmp/plugins/atomicbecomes nested inside{toxinidir}andcprefuses recursion.coverage-cifails withNo data to combine.Repo context:
.github/workflows/testing.ymlrunstoxwith matrix envspy310,coverage-cietc.tox.inicurrently useschangedir = {homedir}/tmpand hardcodes multiple paths under{homedir}/tmpforgit clone,rm -rf,pip install -r,cp -R, and pytest rootdir.Required changes:
tox.iniso the working directory and intermediate files are created in a directory that is guaranteed NOT to be inside the repository (avoid{homedir}/tmp). Prefer tox-provided dirs like{envtmpdir}(per-env) or a stable shared directory under{toxworkdir}if needed.[testenv]and[testenv:py38]to use the new directory variable consistently:git clone ...target directoryrm -rf .../plugins/atomicpip install -r .../requirements.txtcp -R {toxinidir} .../plugins/atomiccoverage run ... --rootdir=... plugins/atomic/tests(ensure path to tests is correct after the copy)coverage-cican still find and combine coverage data. If using per-env temp dirs ({envtmpdir}), adjust the strategy so coverage data is in a shared location for combining, or run combine in the same directory where.coverage.*files are written. (A simple approach is to setCOVERAGE_FILEto a path under{toxworkdir}and usecoverage run -pto produce parallel data files there, or keep a stable shared working dir under{toxworkdir}.)Acceptance criteria:
py310/py311/py312/py313tox envs no longer fail with the recursive copy error.coverage-cino longer fails withNo data to combine.Reference PR:
Reference failing job:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for failing job 73814718704. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The job is failing in the
py310tox environment because the test setup tries to copy the repository into a destination that is inside the repository itself:From the logs:
cp -R /home/runner/work/atomic/atomic '{homedir}/tmp/plugins/atomic'/usr/bin/cp: cannot copy a directory ... into itselfThis happens because
{homedir}/tmpis resolving to a path under the GitHub Actions workspace (effectively inside the checked-out repo), so{homedir}/tmp/plugins/atomicends up being nested within{toxinidir}. As a result,cpdetects recursion and aborts. The downstreamcoverage-cifailure (No data to combine) is just a consequence of tests never running.Fix (recommended): stop using
{homedir}/tmpand use tox’s temp dirUpdate
tox.inito use{envtmpdir}(or{toxworkdir}) so the clone/copy happens outside the repo and is guaranteed not to be nested.Patch suggestion for
tox.ini(ref:d530b4a3f80d6bbc9a99621258825bc56fa95279)Replace the shared
[testenv]and[testenv:py38]changedir+ commands that hardcode{homedir}/tmpwith{envtmpdir}: