Search RU
Tasks / CI/CD / Stable CI cache key
Statement medium

Stable CI cache key

`cache_key(os_name, python_version, lockfile_bytes)` builds the dependency cache
key for CI.

Format:

```
pip-v1-<os_name>-py<python_version>-<sha256(lockfile_bytes)[:16]>
```

Rules:

- the same arguments always produce the same key;
- changing any byte of the lockfile changes the key;
- changing the Python version changes the key;
- changing the OS changes the key;
- the key does not depend on time, `random` or `hash()`;
- empty `os_name`, `python_version` or `lockfile_bytes`, and a non-`bytes`
lockfile, raise `ValueError`.

Write tests: stability (two calls), exact format, sensitivity to the lockfile,
the Python version and the OS, and invalid input.

ci-cdcachelockfilereproducibility
test_solution.py Python 3.14
AI mentor

The AI mentor is available after you log in: it sees your attempt history and does not spend resources on anonymous requests.

Log in and ask
Hints 1 of 3 unlocked · attempts: 0
Hint 1

Which three inputs decide whether the dependencies are compatible? What happens
if the key stops taking one of them into account?

Hint 2 — unlocks after 1 attempt
Hint 3 — unlocks after 3 attempts