Promoting an artifact between stages
Implement `promotion_steps(records, pipeline, target)`: check that one and the
same artifact can be promoted up to the `target` stage.
`pipeline` is an ordered list of stages, for example
`["build", "test", "staging", "prod"]`.
`records` is a list of `StageArtifact(stage, sha256, status="passed")`.
Rules:
- `pipeline` is a non-empty list of unique non-empty strings;
- `target` must be present in `pipeline`;
- a record for a stage that is not in `pipeline` raises `PromotionError`;
- a duplicate record for one stage raises `PromotionError`;
- every stage from the start of the pipeline up to `target` inclusive must have
a record with status `"passed"`;
- `sha256` is 64 lowercase `0-9a-f` characters; otherwise `PromotionError`;
- the digest must match across every checked stage: rebuilding between stages is
forbidden;
- records after `target` are not checked and do not affect the plan;
- return the list of stages from the start of the pipeline up to `target`
inclusive;
- `PromotionError` inherits from `ValueError`.
The hidden tests cover a successful plan, a digest mismatch, a missing and a
failed stage, a foreign stage, a duplicate, an invalid digest, and records after
the target.
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 askHint 1
Why compare the digest at every stage if the artifact is "the same one"? What
exactly breaks when staging rebuilds after test?