This repository demonstrates the advanced usage of the orb circle-makotom-orbs/config-splitting
.
- Fork this repository.
- 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".
- 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
, andC-main-workflow
, which are defined in.circleci/config.yml
,subdir-a/.circleci/config.yml
,subdir-b/.circleci/config.yml
, andsubdir-c/.circleci/config.yml
respectively. - Make a change to
subdir-a/README.md
. You will see that the corresponding pipeline has 2 workflows:setup
andA-main-workflow
. - Make a change to
subdir-b/README.md
. You will see that the corresponding pipeline has 2 workflows:setup
andB-main-workflow
. - Make a change to
subdir-c/README.md
. You will see that the corresponding pipeline has 3 workflows:setup
,B-main-workflow
, andC-main-workflow
(emulating a situation thatsubdir-b
depends onsubdir-c
, and jobs for B need to be triggered upon updates in C).
- There are 3 "modular" configs:
subdir-a/.circleci/config.yml
,subdir-b/.circleci/config.yml
, andsubdir-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 thesetup
workflow. Thesetup
workflow callsrun-modular-configs-selectively
job of the config-splitting orb.- First, the job gets the list of
subdir
s of interest. For this repository.circleci/subdir-list.txt
is the list (as declared in.circleci/config.yml
for parametermodule-list-file
). - Second, the job selects
subdir
s which have changes against thebase-revision
(themain
branch for this repository). - Then, the job walks through
.circleci-config-dependencies
of each selectedsubdir
, to list "modular" configs to be combined. - Finally, the job combines the listed configs.
- Optional:
run-all-modular-configs
injectscontinue-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.
- First, the job gets the list of
- The selectively-combined config generated by the
setup
workflow is passed back to CircleCI and then is executed accordingly.