Simplify syntax when enforcing that a predecessor job runs in a DAG
Problem to solve
We are implementing an MVC for a directed acyclic graph (DAG) execution model in GitLab CI via https://gitlab.com/gitlab-org/gitlab-ce/issues/47063#note_198535521, which introduces the following syntax for marking a job as running after another job, without waiting for its own stage:
deploy:
stage: deploy
needs: [test]
...
A tradeoff we made in was relying on only/except
rules to specify when a job should be run. A common use case for certain DAG use cases, though, is that a job should never trigger if the job it needs didn't run. In the MVC you would achieve that by adding the same only/except
rules to all the jobs in series.
Intended users
Further details
Proposal
We can make this easier by introducing an optional require: true
value to the needs:
syntax, which will allow you to specify that the job should not run unless the job pointed to also runs:
deploy:
stage: deploy
needs:
- job: test
require: true
...
This will provide a nicer syntax so users do not have to repeat the same only/except
rules everywhere.
Implementation
User @ensc provided a potential implementation approach that can be referenced at https://gitlab.com/gitlab-org/gitlab-ce/issues/47063#note_198418523.