Github Actions¶
Debugging with Act¶
Without any tools, the only way to debug your Github actions is to repeatedly push commits to your repository. This can get messy as it will litter the Git history with work on the actions themselves and results in a time-consuming trial and error approach.
Installing Act¶
To use act
you must have Docker installed on your system, if you are using a CGroups V2 enabled Linux such as
Fedora 31 or above you will need to disable this in your Grub boot configuration or Docker will not work as it still
does not support it.
Using Act¶
Once your installation is complete you can start to use act
locally to simulate the CI environment.
It is important to note that the Docker images used by Act are not 100% like for like with Github's container images
but are close enough to use the native Github actions.
When running your actions locally, if you encounter any strange errors then you may need to change the image used by act
from the default lite version to the full fat version.
The larger image weighs in at more than 18 GB, once downloaded it will be cached by your local Docker image registry to avoid multiple downloads of the same image.
The default container image is intentionally smaller
Installing Software¶
As Github actions are all hosted inside Docker images root
access is available without a password.
This means you can use apt
to install any native Ubuntu packages as required.
We recommend that you use native actions configured with Yaml where possible instead of apt
.
It is important to note that all images provided are based on Ubuntu.
Mysql port error¶
If your test container makes use of Mysql you must ensure that you disable your local mysql instance of you may receive errors about ports already being in use. The port can be changed in your actions configuration if needed.
If you rerun your actions multiple times to debug and you receive a port error on the first or subsequent run you will need to destroy the Mysql image that was setup by act before it can continue.
Here is a short script that will destroy all local Mysql Docker containers, make sure you check the output before running this as all data in these images will be lost, if you use Docker in your development stack.
docker ps | grep 'mysql' | awk '{ print $1}' | xargs docker rm -f;