Skip to content

Advanced config splitting: Conditional selection of configs to combine

Notifications You must be signed in to change notification settings

circle-makotom/circle-select-split-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advanced config splitting: Conditional selection of configs to combine

This repository demonstrates the advanced usage of the orb circle-makotom-orbs/config-splitting.

Quick hands-on

  1. Fork this repository.
  2. Go to https://app.circleci.com/settings/project/github/YOUR_GITHUB_ORG_NAME/circle-select-split-config/advanced and enable the option "Enable dynamic config using setup workflows".
  3. Go to https://app.circleci.com/settings/project/github/YOUR_GITHUB_ORG_NAME/circle-select-split-config and hit the "Follow Project" button there. This action will trigger the first pipeline for your forked project, and you will find that the first pipeline has generated 3 workflows: setup, A-main-workflow, B-main-workflow, and C-main-workflow, which are defined in .circleci/config.yml, subdir-a/.circleci/config.yml, subdir-b/.circleci/config.yml, and subdir-c/.circleci/config.yml respectively.
  4. Make a change to subdir-a/README.md. You will see that the corresponding pipeline has 2 workflows: setup and A-main-workflow.
  5. Make a change to subdir-b/README.md. You will see that the corresponding pipeline has 2 workflows: setup and B-main-workflow.
  6. Make a change to subdir-c/README.md. You will see that the corresponding pipeline has 3 workflows: setup, B-main-workflow, and C-main-workflow (emulating a situation that subdir-b depends on subdir-c, and jobs for B need to be triggered upon updates in C).

Behind the scene

  • There are 3 "modular" configs: subdir-a/.circleci/config.yml, subdir-b/.circleci/config.yml, and subdir-c/.circleci/config.yml. Note that these "modular" configs are syntactically valid CircleCI configs, except that these can reference resources defined in the "shared" config (an injected config explained in the below).
  • The "modular" configs to be combined are listed in .circleci/modular-config-list.txt.
  • .circleci/config.yml defines the setup workflow. The setup workflow calls run-modular-configs-selectively job of the config-splitting orb.
    • First, the job gets the list of subdirs of interest. For this repository .circleci/subdir-list.txt is the list (as declared in .circleci/config.yml for parameter module-list-file).
    • Second, the job selects subdirs which have changes against the base-revision (the main branch for this repository).
    • Then, the job walks through .circleci-config-dependencies of each selected subdir, to list "modular" configs to be combined.
    • Finally, the job combines the listed configs.
    • Optional: run-all-modular-configs injects continue-shared.yml into the combined config. This will let "modular" configs listed in .circleci/modular-config-list.txt to reference resources (commands, jobs, etc.) defined in the single "shared" config, avoiding common config stanzas appearing in each "modular" config.
  • The selectively-combined config generated by the setup workflow is passed back to CircleCI and then is executed accordingly.

About

Advanced config splitting: Conditional selection of configs to combine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published