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 the auto_cancel: on_new_commit: none setting on the default branch, because workflow is pipeline-level.
  • gitlab-database-load_balancing used workflow:rules to switch BUNDLE_GEMFILE to Gemfile.next in rails-next pipelines. That is now a rule on its rspec job only, so its rubocop and validation jobs use Gemfile in rails-next pipelines. The gem is an empty stub today.
  • needs: pipeline: $PARENT_PIPELINE_ID to clone-gitlab-repo stays. gems:test now passes PARENT_PIPELINE_ID, CI_FETCH_REPO_GIT_STRATEGY and FF_NETWORK_PER_BUILD to 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.yml from 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, when and allow_failure are 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.

Checklist

Pre-merge

Post-merge

Merge request reports

Loading
Loading