Skip to content

WIP: Gitlab CI run pipelines based on commit filename matching

What does this MR do?

This is an RFC WIP MR meant to close #19232 (moved), as a PoC. This is not ready for merge.

The attempt here was to add a key to the job config for Gitlab CI, so that the job is only run if any of the files in the most recent commit match. The issue called for a child key of only called paths. However, implementing it in this way would require more refactoring of current only-config logic than we were willing to take for our PoC.

Instead, we introduced a brand new config called include_paths, which accepts a list of filename regexes that will be checked against the filenames of the last commit. It is configured like so:

job:
  script: ...
  include_paths:
    - app/
    - *.rb
    - ...

Theoretically, it should be simple to also add functionality for exclude_paths, it will just take more time commitment to accomplish.

Are there points in the code the reviewer needs to double check?

The main thing to look out for is whether my code is conforming to architectural style of Gitlab's codebase. Also, I am open to better ideas on how to input the list of filenames from the commit into the CI::GitlabCiYamlProcessor class. I prefer to have it check all commits since the last time the pipeline ran (last "push"?), instead of just the last commit.

Why was this MR needed?

This offers finer-grain control over what jobs to run. This can result in considerable cost and time savings for lengthy build pipelines, that simple commits would otherwise trigger.

The linked issue documents this use-case well.

Does this MR meet the acceptance criteria?

Note that not all criteria is met, but that's because this is just a PoC. This is not ready for merge yet.

**Also, note that CI pipeline builds from my fork are failing. Some failures, such as rubocop, are things that I need to look at before merge. The reasons for other failures, like karma and spinach, are unknown to me.

What are the relevant issue numbers?

#19232 (moved)

Merge request reports