CI: fix flaky isolated_filesystem failures in functional_test#141
Merged
Conversation
remove the MR stage
Cache key only hashed pyproject.toml, so lockfile-only dependency updates restored a stale .venv across runs.
…ch.chdir Avoids depending on click.testing.CliRunner.isolated_filesystem, which is failing to resolve on the CI container despite click 8.2.1 having it. Standard pytest fixtures are more idiomatic and avoid the issue.
|
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.



Problem
Four
tests_ce/functional_tests/test_cli/test_cli.pytests were failing in CI with:All four tests use
runner.isolated_filesystem()(aclick.testing.CliRunnercontext manager). The 16 other tests in the same file — samerunner = CliRunner()instance, just noisolated_filesystemcall — all passed. Tests pass locally with the same pinned versions (click 8.2.1,typer 0.16.0), and every click version from 7.1.2 → 8.4.1 ships the method, so this is a CI-environment issue, not a code or version-spec issue.Changes
Robust test rewrite (primary fix). Replaced
runner.isolated_filesystem()with pytest's standardtmp_path+monkeypatch.chdir(tmp_path)in the 4 affected tests. Same isolation guarantee, no dependency on click's testing surface, more idiomatic.Cache-key correctness. The
.venvcache key in.github/workflows/main.ymlhashed onlypyproject.toml. Since transitive deps live inuv.lock, lock-only updates couldn't invalidate the cached venv. Updated all 9 cache key references to:Diagnostic step added to
functional_testthat prints click/typer versions, file paths,CliRunnerMRO, andhasattr(runner, 'isolated_filesystem'), plusuv pip list | grep click|typer. Leaves a trail so we can pinpoint the underlying CI env issue (likely a partial/corrupt restored.venv) without it blocking the build.Verification
test_cli.pypass locally.tmp_path+monkeypatch.chdir, which doesn't depend on the broken surface area.Follow-up
Once the diagnostic step runs in CI we'll know whether the restored
.venvhas the expected click version. If it turns out cache corruption is real, we should consider either dropping the cache entirely or runninguv sync --frozenin each test job rather than trusting the cached.venv.