We have a multi-repo microservices setup with a codefresh.yml config in each repo.
We build a docker image for testing, run tests, build a production image, then commit the new tag to the gitops repo.
Most of the steps are heavily parameterized and identical between services, except for the testing steps in the middle, which vary a lot. We use native Codefresh “service containers” YAML for testing, not an external docker-compose, so we can’t even encapsulate testing steps into a shell script with the same name in each repo.
Of course with this setup, repetition is a huge problem and any change needs to be copy/pasted into every service (which also means n commits because we don’t use a monorepo)
Our problem would be solved instantly if Codefresh YAML allowed importing config snippets from a different path, and merged them before execution. I could put the common stuff in a shared repo somewhere (or at worst in a identical file in each repo, still a small win over a slightly different one). Then import it from the repo’s codefresh.yml which would have only the specific testing steps.
Or the other way round : all pipelines using the same shared codefresh config that only loads the different testing steps from each repo.
This isn’t currently possible is it ?
Is there a chance this could be implemented ?
If not, what do you suggest as an alternative ?
Basically the plan is to reuse the whole pipeline, instead of importing different parts of it. This is very easy if you have a single programming language in your company. Otherwise you need one pipeline for each programming language.
First of all thanks for your response. Just so you know, I’m a colleague of @renaud and I’ve been trying to follow your suggestion to define a unique pipeline to be used by our different microservices, but I’ve just reached a blocker when it comes to defining a step for running integration tests, as this would be the step that differs the most between services since we need to link different dependencies (messaging emulator, DB and so on).
Basically, the problem comes when I try to define the services for this step using composition with a local docker-compose.yaml file as one of the examples of Codefresh’s documentation mentions (Service Containers - Docs). My step is defined as follows:
For me everything looks normal unless I’m missing something obvious but then when running that step on my pipeline I get the following error
[SYSTEM] .
Message Failed to prepare composition: services
Caused by Failed to read file /codefresh/volume/docker-compose.yaml
Documentation Link https://codefresh.io/docs/docs/codefresh-yaml/steps/freestyle/
I tried multiple combinations of this definition already and none of them worked. Could you give me a hand here?
I just tried both suggestions and the second one worked like a charm! As you said, it seems that composition property doesn’t point to the correct directory I will raise an issue about this.
If you have an approval step in your pipeline make sure that you have enabled this option Approval · Codefresh | Docs
If you don’t have an approval step, then I don’t see why the file should not be there. There are some rare conditions with parallel steps that lead to file issues.
It is best to open a support ticket with the build URL and let our team investigate.
[SYSTEM] .
Message Failed to prepare composition: services
Caused by Failed to read file /codefresh/volume/<my-project>/docker-compose.yml
Documentation Link https://codefresh.io/docs/docs/codefresh-yaml/steps/freestyle/
I’ve checked that the file exists (by debugging the previous step), and is readable by everyone.