11# golang ci template using github actions
22
3- [ ![ Build Status] ( https://github.com/jandelgado/golang-ci-template-github-actions/workflows/test%20and%20build /badge.svg )] ( https://github.com/jandelgado/golang-ci-template-github-actions/actions?workflow=test%20and%20build )
3+ [ ![ Build Status] ( https://github.com/jandelgado/golang-ci-template-github-actions/workflows/run%20tests /badge.svg )] ( https://github.com/jandelgado/golang-ci-template-github-actions/actions?workflow=run%20tests )
44[ ![ Coverage Status] ( https://coveralls.io/repos/github/jandelgado/golang-ci-template-github-actions/badge.svg?branch=master )] ( https://coveralls.io/github/jandelgado/golang-ci-template-github-actions?branch=master )
5- [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/jandelgado/golang-ci-template-github-actions )] ( https://goreportcard.com/report/github.com/jandelgado/golang-ci-template-github-actions )
5+ [ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/jandelgado/golang-ci-template-github-actions )] ( https://goreportcard.com/report/github.com/jandelgado/golang-ci-template-github-actions )
66
77<!-- vim-markdown-toc GFM -->
88
99* [ Info] ( #info )
10+ * [ Go-Version] ( #go-version )
1011* [ Dependabot] ( #dependabot )
1112* [ Creating a release] ( #creating-a-release )
12- * [ Test coverage (coveralls)] ( #test-coverage-coveralls )
13+ * [ Linting & Test] ( #linting--test )
14+ * [ Linter] ( #linter )
15+ * [ Test] ( #test )
1316* [ Author] ( #author )
1417
1518<!-- vim-markdown-toc -->
1619
17- ## Info
20+ ## Info
1821
1922This repository serves as a template for github-actions integrated go projects.
2023It consists of a ` hello, world! ` like example in source file [ main.go] ( main.go )
21- which gets compiled into the binary ` golang-ci-template-github-actions ` . The CI
22- runs some [ linters ] ( https://github.com/golangci/golangci-lint-action ) on the
23- code, before the unit tests are executed. Test coverage is uploaded to
24- coveralls.io.
24+ which gets compiled into the binary ` my-app ` using goreleaser . The CI is
25+ configured to run
26+ [ golangci-linter ] ( https://github.com/golangci/golangci-lint-action ) on the code,
27+ before the unit tests are executed. Test coverage is uploaded to coveralls.io.
2528
2629[ goreleaser] ( https://github.com/goreleaser/goreleaser ) is used to create the
27- final multi-plattform assets, which are automatically uploaded to the
30+ final multi-plattform assets, which are automatically uploaded to the
2831[ release] ( https://github.com/jandelgado/golang-ci-template-github-actions/releases/latest ) .
2932The [ release-process] ( #creating-a-release ) is triggered by pushing a git tag to
3033the repository.
3134
3235Finally, a docker image is built, which gets published to
33- [ ghcr.io] ( https://github.com/jandelgado/golang-ci-template-github-actions/pkgs/container/golang-ci-template-github-actions ) .
36+ [ ghcr.io] ( https://github.com/jandelgado/golang-ci-template-github-actions/pkgs/container/my-app ) .
3437Run it with
3538
3639``` console
37- $ docker run --rm ghcr.io/jandelgado/golang-ci-template-github-actions :latest
40+ $ docker run --rm ghcr.io/jandelgado/my-app :latest
3841hello, world!
3942```
4043
44+ ## Go-Version
45+
46+ The go version to use is configured in ` go.mod ` with the ` toolchain ` directive.
47+ When building locally, set ` GOTOOLCHAIN ` to ` auto ` to automatically install
48+ the configured toolchain (introduced with go 1.21).
49+
4150## Dependabot
4251
43- We use [ dependabot] ( https://docs.github.com/en/code-security/dependabot ) to
52+ We use [ dependabot] ( https://docs.github.com/en/code-security/dependabot ) to
4453both keep the go dependencies as well as the used github action up-to-date.
4554The configuration can be found [ here] ( .github/dependabot.yml ) .
4655
@@ -53,28 +62,41 @@ $ git tag -a "v1.2.3" -m "this is release v1.2.3"
5362$ git push origin v1.2.3
5463```
5564
56- The push of the new tag triggers the CI, which uses goreleaser to:
57- * build multiplatform release artifacts
58- * create a new release
59- * upload the artifacts, which are then available on the [ releases page] ( /jandelgado/golang-ci-template-github-actions/releases ) .
65+ The push of the new tag triggers the CI, which uses goreleaser with
66+ [ this configuration] ( .goreleaser.yml ) to
6067
61- Finally, a docker image is built, which gets published to
68+ * build multi-platform release artifacts
69+ * create a new release
70+ * upload the artifacts, which are then available on the [ releases page] ( /jandelgado/golang-ci-template-github-actions/releases ) .
71+
72+ Finally, a docker image is built using the previously built artefacts. The image
73+ is published to
6274[ ghcr.io] ( https://github.com/jandelgado/golang-ci-template-github-actions/pkgs/container/golang-ci-template-github-actions ) .
6375
64- ## Test coverage (coveralls)
76+ To run goreleaser locally, start the tool with ` gorelaser build --snapshot --clean ` .
77+
78+ ## Linting & Test
79+
80+ ### Linter
81+
82+ [ golangci-linter] ( https://github.com/golangci/golangci-lint-action ) is
83+ configured for code-linting. The report is uploaded so that linting results
84+ are visible in the MR:
85+
86+ ![ pr screenshot] ( images/linter.png )
87+
88+ ### Test
6589
6690We use the
6791[ coveralls-github-action] ( https://github.com/coverallsapp/github-action ) to
6892upload the golang coverage to coveralls.
6993
70- Don't forget to enable ` Leave comments (x) ` in coveralls, under `repo
71- settings` > ` pull request alerts`, so that the coveralls-action posts a comment
94+ Don't forget to enable ` Leave comments (x) ` in coveralls, under
95+ ` repo settings` > ` pull request alerts ` , so that the coveralls-action posts a comment
7296with the test coverage to affected pull requests:
7397
7498![ pr screenshot] ( images/pr.png )
7599
76100## Author
77101
78- (c) copyright 2021 by Jan Delgado, License MIT
79-
80-
102+ (c) copyright 2021-2025 by Jan Delgado, License MIT
0 commit comments