Add support for failing status checks
What does this MR do and why?
- Previously, it was only possible to approve an external status check. The existence of a
StatusCheckResponse
was implicitly an approval. - This MR adds support for a failing status without creating breaking changes.
API Changes
-
[POST] projects/:id/merge_requests/:iid/status_check_responses
now accepts an optionalstatus
parameter which can beapproved
orfailed
. When no value is passed, it is assumed the response isapproved
. This is to avoid introducing a breaking change. -
[GET] projects/:id/merge_requests/:iid/status_checks
returnspassed
instead ofapproved
in the status field. - Documentation has been updated.
Frontend changes
- Updates text (using : instead of ,)
- Shows failure icons if any status checks fail
- More useful test showing total numbers of failing, pending and approved checks
Backend and database changes
- Adds a new column (
status
) toexternal_status_checks
- Updates API responses to show all 3 potential statuses.
- Reasoning for no index: !81005 (comment 849423603)
- Places the breaking changes in this MR behind a default-off feature flag.
Migration
Up
== 20220217113058 AddStatusToStatusCheckResponses: migrating ==================
-- add_column(:status_check_responses, :status, :integer, {:default=>0, :null=>false, :limit=>2})
-> 0.0080s
== 20220217113058 AddStatusToStatusCheckResponses: migrated (0.0080s) =========
Down
== 20220217113058 AddStatusToStatusCheckResponses: reverting ==================
-- remove_column(:status_check_responses, :status, :integer, {:default=>0, :null=>false})
-> 0.0108s
== 20220217113058 AddStatusToStatusCheckResponses: reverted (0.0129s) =========
Screenshots or screen recordings
Flag on | Flag off | |
---|---|---|
All pending | 1 | |
All passed | ||
Mixed statuses | Not possible. All statuses are passing. |
How to set up and validate locally
- Create a new project.
- Create three external status checks for that project. https://docs.gitlab.com/ee/user/project/merge_requests/status_checks.html#add-or-update-a-status-check
- Create a new branch, make a small change, and create a merge request on that project.
- In the MR widget, validate that all 3 status checks are pending.
- Approve one, fail one, and do nothing to the other. (API docs)
- Assert that the widget looks as expected.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #329636 (closed)
Edited by Max Woolf