Post

Running multicontainer application in GitHub Actions

GitHub Actions is one of the most amazing feature in GitHub. It allowes you to automate different tasks by creating different workflows in your pipeline. Github is offering 2000 Action minutes per month in Github Free plan which is more than sufficient for users like me.

I was curious if it would be even possible to use GitHub Actions for build and run multicontainer application (basically web application with database) and perform selenium test against it. So I decided to create small proof of concept (POC) project Docker compose in Github actions.

I have created small bare bone Java application running in Tomcat server and which is using Firebird Sql database. Then I have created simple Docker Compose file which I tweaked on my local computer and tried to run it in GitHub Actions and surprisingly it was working!

So next I tried to complete whole pipeline which contains following steps:

  1. Build Java Web application and produce WAR file
  2. Build Docker image for Web application
  3. Start multicontainer application in docker compose
  4. Restore database testing content in database container
  5. Install Google Chrome for testing (which includes selenium driver)
  6. Run selenium test against application which produces screen shots
  7. Archive screen shots (you can find them in the detail of each workflow in Artifacts section)

Complete pipeline is here.

Docker compose in Github actions POC

This pipeline can be triggered on each commit or pull-request and each run of pipeline creates new clean and isolated testing environment. You don’t need any dedicated testing virtual machine or kubernetes cluster anymore and you can run as many tests as you want all for free.

Described POC proofs that GirHub Actions is very powerfull tool in which you can build, configure, run and test nontrivial multicontainer applications. This is not limited only to web applications with sql database neither to selenium tests.

Feel free to fork this POC project and do your own experiments. Please let me know in case you will find any improvement or other interesting complex scenario.

This post is licensed under CC BY 4.0 by the author.