DEV Community

Discussion on: A free CI (using Docker-Compose) for your Gitlab repositories?

Collapse
 
mr_nil profile image
Stephen Moretti

You can probably actually use a PHP image instead of the docker image - save yourself the effort of building a PHP image every time.

You should also look at stages and jobs to separate your spec tests from your unit tests and from your end to end tests. docs.gitlab.com/ee/ci/pipelines.html

Make sure you specify your image in each job rather than globally, so you don't cause yourself problems later down the line.

Collapse
 
einenlum profile image
Yann Rabiller

Hi Stephen, thanks for your comment!

I separated first my build in 3 builds (unit, specs, e2e): I thought it would do the before_script once, but it launches 3 different builds with the same before_script. In the end it seems the overall speed was quite negligable (especially if you put your specs and unit tests before e2e tests) and I was thinking that it would take me some build time (3 x 1 minute instead of 1 x 1 minute) so I ended doing only one build.

Am I wrong in my logic here? Isn't it counted as 3 x build time?

Collapse
 
mr_nil profile image
Stephen Moretti

So yes, with a before script, you will build on each job. However, your before is simply that you are building a php container. For that you can probably reuse an existing php docker image from docker hub, rather than build each time. When you apply that to your jobs rather than as a before script gitlab will cache the image and reuse rather than pull each time.

You can also do things with passing artefacts between jobs.

Separating your tasks into jobs and stages means that when you look at your pipeline you can see which job is currently running and which has actually failed without having to dig into the console output to work out what died.

If you want to go nuts, you can actually build containers in a repo in a pipeline, do some assurance and setting on your container, and stash the built image in the image registry in the repo for reuse in other pipelines.