Feature/decentralize unit test
Tested here: https://gitlab.builder.ai/devsecops/giuseppedf/giusepped-app/-/pipelines
Tests involved checking all the rules for all branches and MR. This job will run following the same rule unit tests used to follow before.
Quirk behavior: on gitlab 13.1 we found out that the rule: exists:
- Dockerfile.unit-test
changes:
- Dockerfile.unit-test
Altough semantically correct, doesn't work on MR. For those MR that includes a change in the Dockerfile.unit-test the built_test will always run.
On feature branches and master branches the rule works perfectly and runs the build_test job only if the Dockerfile.unit-test exists and it's changed.
More on the approach: One thing to notice is that the image pulled for each branch is different, I didn't see a better way to re-use as much as possible the code other than having 4 different jobs with different rules that extend the unit test job.
MR of the docs to also review: https://gitlab.builder.ai/docs/devsecops/-/merge_requests/64/pipelines