Skip to content

Commit 6a1995e

Browse files
authored
ci: fix e2e templates tests failing on mise shim cwd resolution (#1885)
## Summary The scheduled e2e template tests have been failing on every matrix job since #1874 / #1880 adopted `apify/setup-apify-cli-action@v1.0.0`. The action installs apify-cli via a `mise` shim that resolves the apify version by walking up from cwd looking for a `mise.toml`. Our tests run `subprocess.run(['apify', ...], cwd=tmp_path / actor_name)` from pytest's default `tmp_path` (`/tmp/pytest-of-runner/...`), which is outside `MISE_TRUSTED_CONFIG_PATHS` and contains no mise config. The shim therefore errors with `No version is set for shim: apify`. This mirrors how `apify/crawlee` handles the same situation in `test/e2e/tools.mjs` (running `apify push` from a directory under the project root and setting `GIT_CEILING_DIRECTORIES`). ## Changes - `pyproject.toml`: pass `--basetemp=./.pytest-tmp` to the `e2e-templates-tests` poe task so pytest's `tmp_path` lives under the project root, where `mise`'s parent traversal finds the `mise.toml` written by `jdx/mise-action` to `$GITHUB_WORKSPACE`. - `.gitignore`: ignore `.pytest-tmp`. - `tests/e2e/project_template/test_static_crawlers_templates.py`: set `GIT_CEILING_DIRECTORIES=tmp_path` on the `apify push` call so git stops before reaching the project's `.git/`. Failing run: https://github.com/apify/crawlee-python/actions/runs/25541426007
1 parent 91c0764 commit 6a1995e

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ GEMINI.local.md
2222
# Cache
2323
__pycache__
2424
.pytest_cache
25+
.pytest-tmp
2526
.ruff_cache
2627
.ty_cache
2728
.uv-cache

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ uv run pytest \
337337
cmd = """
338338
uv run pytest \
339339
--numprocesses=${TESTS_CONCURRENCY:-auto} \
340+
--basetemp=./.pytest-tmp \
340341
tests/e2e/project_template
341342
"""
342343

tests/e2e/project_template/test_static_crawlers_templates.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ async def test_static_crawler_actor_at_apify(
8686
)
8787
subprocess.run(['apify', 'init', '-y', actor_name], capture_output=True, check=True, cwd=tmp_path / actor_name) # noqa: ASYNC221, S603, S607
8888

89-
build_process = subprocess.run(['apify', 'push'], capture_output=True, check=False, cwd=tmp_path / actor_name) # noqa: ASYNC221, S607
89+
build_process = subprocess.run( # noqa: ASYNC221
90+
['apify', 'push'], # noqa: S607
91+
capture_output=True,
92+
check=False,
93+
cwd=tmp_path / actor_name,
94+
# Prevent git from walking up into the surrounding project's .git/ when running under
95+
# a basetemp inside the repo (see --basetemp in the e2e-templates-tests poe task).
96+
env={**os.environ, 'GIT_CEILING_DIRECTORIES': str(tmp_path)},
97+
)
9098
# Get actor ID from build log
9199
actor_id_regexp = re.compile(r'https:\/\/console\.apify\.com\/actors\/(.*)#\/builds\/\d*\.\d*\.\d*')
92100

0 commit comments

Comments
 (0)