Refine CI statuses
Description
Currently a CI pipeline / build status is a symbol / string. Statuses are being persisted as enum
values (defined in HasStatus
concern). We calculate statuses using SQL queries, which is quite fast.
But this solution is not flexible enough. See discussion starting here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6801#note_17742888 and merge request https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6801.
What we are trying to solve in !6801 (closed) is improving support for situation when pipeline is successful, but there were builds that failed that were allowed to fail.
The problem with this approach, is that we will need to add a new status each time we want to decorate / extend statuses. Consider @nick.thomas' comment:
What if in the future we want to introduce an icon to say 'this pipeline passed but it is stale - i.e., passed > 48 hours ago'?
Proposal
I wonder if using a 'primitive' value for pipeline / build status weakens our CI model. Would it make sense to introduce Ci::Status
module which would hold Ci::Status::Success
and all statuses that we have (along with Ci::Status::Core
)? With this approach it would be possible to decorate statuses with Ci::Status::Warning
or Ci::Status::Stale
which would make it possible to scale statuses "horizontally" instead of making implementation "vertical" (not sure if this is a good analogy) and leverage polymorphism.
The point here is to keep core statuses simple, and extend implementation in layer above core statuses.
What do you think @ayufan @godfat @nick.thomas @rymai?