Testing & Deploying monorepo with parallel:matrix
Hi all. I have a Python monorepo, where I have a directory called protocols
that contains one directory per module, each with their own venv
and requirements.txt
. This folder is constantly growing as my team adds more and more “protocols”. A user on an unofficial Gitlab Discord pointed me toward using parallel:matrix
in order keep things DRY. I found this extremely powerful. See my config with sensitive details omitted:
.mod_list:
- PATH_NAME: "mod1"
FILE_NAME: "mod1.py"
- PATH_NAME: "mod2"
FILE_NAME: "mod2.py"
test-protocols:
stage: test
rules:
- changes:
- mods/${PATH_NAME}/**/*.py
script:
- cd "${CI_PROJECT_DIR}/mods/${PATH_NAME}"
- ~/task venv
- ~/task init
- ~/task test
parallel:
matrix: !reference [.mod_list]
deploy-protocols:
stage: deploy
rules:
- changes:
- mods/${PATH_NAME}/${FILE_NAME}
script: !reference [.deploy_script, script]
parallel:
matrix: !reference [.mod_list]
This works great in that modules are only tested/deployed when changes are made to their respective rules:changes
properties. However, the way things are now, if one module’s testing fails, all module deployments are skipped. See this screenshot to better illustrate:
In the example above, I would expect mod2
deployment to be skipped, but mod1
deployment to run since its tests did pass.
I’ve been perusing the Gitlab CI docs, but have yet to find something that I think can help me here. Wondering if maybe I can’t use parallel:matrix
in this manner at all.
Thanks in advance.