Hey folks, I'm looking to add some automated acceptance tests into my existing GitLab CI + Docker setup and am looking for advice/guidance from anyone who may have experience with a similar setup.
My current Gitlab CI pipeline involves separate Build and Deploy stages. The build stage builds a docker image of my application, and pushes it up to my docker registry. The Deploy stage then grabs that image and deploys it. I want to add a Test stage to my pipeline which runs my acceptance tests, but am struggling with wrapping my head around exactly how to make that happen.
So far, my thinking on this seems to be divided into two different approaches which can be categorized based on the order of the stages in the pipeline:
Test -> Build -> Deploy: In this approach, the tests are run before the docker of my application image is built. I could have the test stage use a specific docker image which has a web server and database and whatever else I need.
Build -> Test -> Deploy: In this one, we first build the docker image and then run it (via docker-compose or something so that I can spin up database container with it). This option seem attractive because it will more closely simulate my actual production environment, but is kind of nasty because it requires I build the image even in cases where tests fail which takes time and resources.
I know it's a pretty specific situation, but if you have experience with a similar setup how would you do it?