Create a PoC of using the Dynamic Child Pipelines feature on a small project
As described in #330731 (comment 573527318), we should create a PoC on a small project to generate the CI config programmatically, in order to be able to unit test it.
Copying Grzegorz's comment here for reference:
I thought about a few years ago, and although I think that we could build this feature, I would personally programatically generate a new
.gitlab-ci.yml
using the the Dynamic Child Pipelines feature.Because the generation happens in the context of the CI build, with variables, Git repository and everything, this can be actually fully unit tested. You can write an application that will read your environment configuration and you can set / stub the environment as a precondition for a test. This can be done in Go, Ruby or any other language, the outcome is going to be a simple
.gitlab-ci.yml
configuration that is fully unit tested @rymai @balasankarc.Example pseudo code:
module Pipeline class Environment def branch # ... end def variables # ... end end module Pipeline class Generate def initialize(environment) # ... end def generate! # ... end end end Pipeline::Generate .new(Pipeline::Environment.fabricate) .generate! # and tests describe 'CI/CD dynamic pipeline' do before do allow(environment).to receive(:variables).and_return(something) end it 'generates pipeline with build a, b ,c do expect(pipeline).to have_builds(a, b, c).with_variables(c, d, e) end end