1
1
# golang ci template using github actions
2
2
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 )
4
4
[ ![ 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 )
6
6
7
7
<!-- vim-markdown-toc GFM -->
8
8
9
9
* [ Info] ( #info )
10
+ * [ Go-Version] ( #go-version )
10
11
* [ Dependabot] ( #dependabot )
11
12
* [ Creating a release] ( #creating-a-release )
12
- * [ Test coverage (coveralls)] ( #test-coverage-coveralls )
13
+ * [ Linting & Test] ( #linting--test )
14
+ * [ Linter] ( #linter )
15
+ * [ Test] ( #test )
13
16
* [ Author] ( #author )
14
17
15
18
<!-- vim-markdown-toc -->
16
19
17
- ## Info
20
+ ## Info
18
21
19
22
This repository serves as a template for github-actions integrated go projects.
20
23
It 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.
25
28
26
29
[ 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
28
31
[ release] ( https://github.com/jandelgado/golang-ci-template-github-actions/releases/latest ) .
29
32
The [ release-process] ( #creating-a-release ) is triggered by pushing a git tag to
30
33
the repository.
31
34
32
35
Finally, 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 ) .
34
37
Run it with
35
38
36
39
``` console
37
- $ docker run --rm ghcr.io/jandelgado/golang-ci-template-github-actions :latest
40
+ $ docker run --rm ghcr.io/jandelgado/my-app :latest
38
41
hello, world!
39
42
```
40
43
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
+
41
50
## Dependabot
42
51
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
44
53
both keep the go dependencies as well as the used github action up-to-date.
45
54
The configuration can be found [ here] ( .github/dependabot.yml ) .
46
55
@@ -53,28 +62,41 @@ $ git tag -a "v1.2.3" -m "this is release v1.2.3"
53
62
$ git push origin v1.2.3
54
63
```
55
64
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
60
67
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
62
74
[ ghcr.io] ( https://github.com/jandelgado/golang-ci-template-github-actions/pkgs/container/golang-ci-template-github-actions ) .
63
75
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
65
89
66
90
We use the
67
91
[ coveralls-github-action] ( https://github.com/coverallsapp/github-action ) to
68
92
upload the golang coverage to coveralls.
69
93
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
72
96
with the test coverage to affected pull requests:
73
97
74
98
![ pr screenshot] ( images/pr.png )
75
99
76
100
## Author
77
101
78
- (c) copyright 2021 by Jan Delgado, License MIT
79
-
80
-
102
+ (c) copyright 2021-2025 by Jan Delgado, License MIT
0 commit comments