DEV Community

Discussion on: Write Dynamic GitLab pipelines in TypeScript

Collapse
 
bcouetil profile image
Benoit COUETIL ๐Ÿ’ซ • Edited

I love uncharted territories on GitLab, thank you for sharing ! You should add #gitlab tag, it has better traction that some of the ones you defined.

For now i do not really understand the advantages f your workflow...

Type safety. Configuration mistakes get caught at compile time, not during a failing pipeline run.

gitlab-ci-local can also do it, without any abstraction layer.

Reuse and abstraction. You can share constants, extract helpers, and centralize common job definitions without copy-pasting YAML blocks across files.

extends, references and includes can also do it without any abstraction layer.

Developer experience. You get autocomplete, inline documentation (TSDoc), safe refactoring, and earlier detection of invalid or unused variables.

IDE extension and gitlab-ci-local can also do that without any abstraction layer

Collapse
 
sleeyax profile image
Sleeyax • Edited

Thank you for the reply. I appreciate your input!

Let me clarify how this fits my workflow:

1. "Type safety" via gitlab-ci-local

Thatโ€™s not really instant type checking though. gitlab-ci-local validates YAML after itโ€™s written and run through a separate tool. AFAIK it doesnโ€™t prevent you from writing invalid configs in the first place.

Itโ€™s also a fairly large, non-official dependency that weโ€™d need to enforce across the team. In our case, we already work exclusively in TypeScript in a complex NX monorepo, so this is just native TS tooling doing what it already does best.

2. extends, includes, anchors
We used all of those extensively before. They help, but theyโ€™re still string-based and fairly fragile: typo a job name, forget to include a file, or misunderstand merge behavior and things silently stop working.

Importing files and composing objects in TypeScript proved more simple for us.

3. IDE extensions / DX without abstraction

Interesting. I wasn't aware of a widely used IDE extension for GitLab CI that gives the same level of refactoring and safety. Which one? I have GitLab workflow installed in vscode and for .gitlab-ci.yml files specifically it only helps with hinting the YAML field names.

Anyways, I feel like enforcing a specific IDE plugin across the team is still not the most ideal approach. With TypeScript, autocomplete, refactoring, docs, and error checking are already there. No extra tooling or setup beyond what we already use every day.

Conclusion
Just to be clear, the goal of this article isn't to say "GitLab YAML bad". This different approach just fits our project and team better. Weโ€™re already very TS-minded, and once pipelines reach a certain size and complexity, treating them as code instead of configuration has proven easier to reason about and maintain for us.

I'll try to update the article so it's a little more nuanced.

Collapse
 
bcouetil profile image
Benoit COUETIL ๐Ÿ’ซ • Edited

Thanks. Indeed you would gain depth in it by addressing inner reader questions like those.

i've never been around a project with development abstraction layer on GitLab for my past 7 years actively doing GitLab consulting, But I'd like to see that in action whenever I get the chance. But for now, nothing convince me of doing it for myself (on projects I get to choose).