Conditional Services in a job

We have integration tests that work with a matrix of databases. We use the GitHub CI services feature to launch databaes to integration test against. However there are two problems:

  1. Some tests do not need a database service (e.g. sqlite)
  2. All services are launched for each matrix item. E.g. postgresql + mysql + redis are launched for every test in the matrix. But that is wasteful. We only need the database service corresponding to the case in the matrix.

How can this be achieved? So far I’ve seen how we can use the “incude” feature of matrix configuration. However that doesn’t help the first problem where we would want NO database service at all.

1 Like

I’m not aware of any conditional on the services section, but you can just start the service you actually need in a step. If you attach it to the network given by job.container.network the effect should be basically the same.

Thanks we will try this

1 Like