on
Run Golang Tests with Github Actions
Automation is great (right?!) and it can be so easy these days to run your tests automatically on any new pull request or code change. In this post we outline how you can automatically run your Go (golang) test for your project by using Github Actions. The results will then show within Github and is configured using a yaml file.
To get this running, you will need to create a workflow file (as shown below). Which will essentially do the following:
- Download Go (using setup-go)
- Grab project files & dependencies
- Build the project
- Run your tests
{project}/.github/workflows/go.yml
|
|
Commit this file and push, and it will run automatically for you.
Example
Secrets
Most of the above is as simple as copy and paste, but near the end we have added some example environment variables, AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
. These use Github secrets and allow you pass important/sensitive information to your application/tests.
|
|
For more info on setting these up, try Github’s help docs.