You need to guarantee that a Python service's dependencies are exactly what was tested. What do you do?
AdvancedScenarioTesting, CI/CD, packaging & services
Answer
Situation read → Reproducibility and supply-chain integrity.
What I'd do →
- Lock all dependencies, including transitive, with hashes (
pip-compile --generate-hashesoruv lock). - Install with
pip install --require-hashes --no-deps -r requirements.txt(oruv sync --frozen) in the image build. - Build the image once, test that image, promote the same digest to production.
- Generate an SBOM (Syft) and scan (Trivy/Grype); sign the image (cosign).
Why → Hashes stop tampered packages; promoting the same digest guarantees "tested == deployed".
Interview tip → "Build once, promote by digest" is the key line.
More on Testing, CI/CD, packaging & services
You join a team whose Python automation repo has no tests. Where do you start?BeginnerYour pytest suite takes 12 minutes. How do you speed it up?IntermediateA test passes locally but fails in CI only when run with the rest of the suite. What do you suspect?IntermediateYou want a reusable CI pipeline for 15 Python tool repos. What goes in it?IntermediateYour Python Docker image is 1.1 GB. How do you shrink it?IntermediateYou want to distribute an internal CLI to 200 engineers. What are your options?Intermediate