Continuous Integration and Go
Artem Tanyhin
Posted on November 17, 2022
Hey there! Thanks for coming by. Today, I want to tell you how I created a Continuous Integration workflow for SSGo using GitHub Actions, as well as how I created some tests for a different Open Source repo. Maybe you'll find something useful, too!
CI Workflow
For my start, I decided to stick with GitHub's official guide, which also conveniently included running unit tests, which I described in my earlier post.
I made sure to specify Go version as 1.16 as this is the version that switched ioutil.ReadFile
to os.ReadFile
.
Adding linter
golangci-lint
has a beautiful GitHub Actions installation guide, so I used that and didn't have to worry about setting up VM linters on my own. Very nice!
Adding Node.js unit tests
Repo I picked for adding unit tests is izyum, which is another SSG written in Node.js and TypeScript.
I added some unit tests for a couple file utility functions. Since it involved file system, I had to use jest.mock on fs
module. After I was done with my changes, I opened a pull request.
Summary
Continuous Integration is crucial for keeping the project clean and working. Automatic tests and linting is right what every Open Source project needs, so I would encourage every repo manager to consider adding CI. You'll thank me later, haha!
Posted on November 17, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.