Test the selected gems in one child pipeline
What does this MR do?
In !259323 (merged), gems:test runs a generated child pipeline with one trigger job per selected gem, and each trigger starts a pipeline for that gem. That gives root -> gems:test -> gem pipeline, the maximum depth GitLab allows. The reviewer also has to open one pipeline per gem.
The generated child pipeline now includes the .gitlab-ci.yml of each selected gem, so all selected gems run in one child pipeline. This removes one nesting level. It addresses !259323 (comment 3945989103). This MR targets the branch of that MR.
To make the include possible, gems/gem.gitlab-ci.yml and gems/gem-pg.gitlab-ci.yml no longer use pipeline-level keys (workflow, top-level variables, default). Their settings (image, tags, cache, before_script, after_script, variables) move to a hidden base job per gem. Every key is prefixed with the gem name, for example gitlab-utils:rspec, gitlab-utils:rubocop, gitlab-utils:validate-gem and .gitlab-utils:ruby_matrix. The 7 gems that add or change jobs in their own .gitlab-ci.yml use the prefixed names: gitlab-active-context, gitlab-backup-cli, gitlab-database-load_balancing, gitlab-housekeeper, diff_match_patch, sidekiq and sidekiq-reliable-fetch. The other 33 gems only include the template and do not change.
The existing path (static gem trigger jobs, still the default) keeps working with the same files. Each gem still runs in its own child pipeline, only the job names have the prefix.
Behaviour changes:
- Job names in gem pipelines have the gem prefix in both paths.
- In the existing path, gem child pipelines lose their custom name (
[<gem> gem] Ruby <version> pipeline) and theauto_cancel: on_new_commit: nonesetting on the default branch, becauseworkflowis pipeline-level. - gitlab-database-load_balancing used
workflow:rulesto switchBUNDLE_GEMFILEtoGemfile.nextin rails-next pipelines. That is now a rule on its rspec job only, so its rubocop and validation jobs useGemfilein rails-next pipelines. The gem is an empty stub today. needs: pipeline: $PARENT_PIPELINE_IDtoclone-gitlab-repostays.gems:testnow passesPARENT_PIPELINE_ID,CI_FETCH_REPO_GIT_STRATEGYandFF_NETWORK_PER_BUILDto the child pipeline.
Verified with the CI lint API (dry run on this branch):
- The root config is valid.
- The generated child pipeline with all 40 gems is valid (288 jobs), so including
.gitlab/ci/version.ymlfrom every gem works. - Each gem file alone (the existing path) is valid.
- For all 40 gems, the jobs per gem are the same as on master apart from the prefix. For 9 gems (the 7 custom ones, gitlab-utils and gitlab-database-lock_retries),
before_script,script,after_script,tags,whenandallow_failureare the same as on master. - The specs for the generator pass.
Not verified: a real pipeline (I pushed with ci.skip), and job variables, because the lint API does not compare them.
To try it, run a pipeline on this MR with GLCI_GEMS_TEST_ALL=true (all gems in one child pipeline) or GLCI_GEMS_DEPENDENCY_GRAPH=true.
Related issues
- #630714 (closed)
- Follow-up of !259323 (merged)
Checklist
Pre-merge
- Different pipeline types: same rules as !259323 (merged). Only the shape of the generated child pipeline and the gem job names change.
- Non-canonical projects (gitlab-foss, security, dev, personal forks): no change.
- Pipeline performance: one child pipeline instead of one per gem. The same gem jobs run.
- Add a duration chart to https://app.periscopedata.com/app/gitlab/652085/Engineering-Productivity---Pipeline-Build-Durations if there are new jobs added to merge request pipelines (no new jobs)
Post-merge
- Consider communicating these changes to the broader team following the communication guideline for pipeline changes