Skip to content

CI: make the backend test environment cache deterministic - #13

Merged
alessiopagliarulo merged 1 commit into
nextjsfrom
ci/deterministic-backend-cache
Oct 29, 2026
Merged

alessiopagliarulo merged 1 commit into
nextjsfrom
ci/deterministic-backend-cache

Conversation

@alessiopagliarulo

@alessiopagliarulo alessiopagliarulo commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

What user problem are we solving?

Backend Checks failed on nextjs after #12 merged (run 40934362759) with AttributeError: module 'charset_normalizer.md' has no attribute 'CharInfo', even though the identical tree passed on the PR (run 40933573380). The result depended on which cache GitHub served, not on the code.

Root cause

backend.yml restored two caches into the same conda env folder: a mamba env cache keyed only on environment.yml, and a poetry venv cache keyed on poetry.lock with restore-keys (partial matches). On the push run the mamba cache missed, so conda installed charset-normalizer 3.5.2. The venv cache then hit exactly and was extracted on top, bringing poetry's 3.1.0 files, and poetry install was skipped. The mixed package broke import requests, and that broken env was saved back as a cache.

What solution does this PR provide?

  • One cache for the dlp env, keyed on both training/environment.yml and training/poetry.lock, with no restore-keys. A hit is exactly the env those two files built.
  • poetry install always runs. It is close to a no-op on a correct cache and repairs anything else.
  • The new key prefix (dlp-env-...-1-) discards the poisoned caches.

Testing Methodology

Backend Checks on this PR (lint and test) must pass from a cold cache. After merge, the push run on nextjs should pass too.

🤖 Generated with Claude Code


Note

Low Risk
CI-only workflow changes; no runtime application code, though cache behavior affects whether backend lint/tests pass reliably.

Overview
Fixes non-deterministic Backend Checks caused by stacking two GitHub Actions caches on the same conda env path (mamba keyed on environment.yml plus poetry keyed on poetry.lock with partial restore-keys), which could mix conda and Poetry package versions and skip poetry install.

In .github/workflows/backend.yml (lint and test jobs), this replaces the dual-cache setup with one cache of /usr/share/miniconda3/envs/dlp, keyed on training/environment.yml and training/poetry.lock with no restore-keys. mamba env update runs only on cache miss; poetry install always runs so a valid cache stays fast but inconsistent layers get repaired. The new key prefix dlp-env-...-1- drops previously saved bad caches.

Reviewed by Cursor Bugbot for commit 0d68c5d. Bugbot is set up for automated code reviews on this repo. Configure here.

Two caches (mamba env and poetry venv) restored into the same env folder,
and the venv cache used restore-keys. On nextjs this mixed conda's
charset-normalizer 3.5.2 with poetry's 3.1.0, so the same commit passed
on the PR and failed on push (charset_normalizer.md has no CharInfo).

Use one cache keyed on environment.yml and poetry.lock with no partial
matches, and always run poetry install.
@alessiopagliarulo
alessiopagliarulo merged commit ed5fa15 into nextjs Oct 29, 2026
8 checks passed
@alessiopagliarulo
alessiopagliarulo deleted the ci/deterministic-backend-cache branch October 29, 2026 18:59
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.

1 participant