Track status state per build step instead of per pipeline #107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the task
Because two builds on the same pipeline + branch don't necessarily always run the same build steps, the current state tracking is insufficient for handling those cases. Instead of tracking build state per pipeline, we should track it per build step.
Some details regarding Buildkite notification behavior:
context
field, which is eitherbuildkite/pipeline-name
for the former orbuildkite/pipeline-name/build-step
for the latter.The implementation:
For each status notification that passes the rule check (which should only be overall build notifications), we:
Future work:
It would be nice if build failure notifications also told us which build step failed. This can be done easily by making
Action.partition_status
returned the build steps that failed, so thatSlack.generate_status_notification
can include them in the final message.Final note:
Large diff size is due to the addition of HTTP request/response stubs - apologies.
How to test
Existing tests should pass.
Two cases are added; the second handles the behavior observed in production that motivated this PR.
status.success_test_different_steps_from_prev
This is for an incoming successful build on develop branch with a single build step, "notabot-test/build". There exist past successes for same branch + different steps, and for different branch + same step, but not for same branch + same step. Thus, it should generate a notification.
status.success_test_not_affected_by_unrelated_success_with_different_steps
This is for an incoming successful build on develop branch with two steps, "notabot-test/{build-infra,setup}". Here, previously a build with steps "build-infra" and "setup" failed on step "build-infra". Then a subsequent build with step "build" succeeded, so the overall pipeline state is a success. However, the more recent successful but unrelated build should not affect generation of another success notification, given the change in status state for "build-infra".
References