Skip to content

Commit 48d208a

Browse files
authored
Add Codecov integration (#89)
1 parent 131c47e commit 48d208a

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ jobs:
3434
with:
3535
name: dist
3636
path: dist
37+
- name: Upload coverage to Codecov
38+
uses: codecov/codecov-action@v1
39+
with:
40+
file: ./coverage.out

README.md

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![go.mod](https://img.shields.io/github/go-mod/go-version/golang-templates/seed)](go.mod)
66
[![Build Status](https://img.shields.io/github/workflow/status/golang-templates/seed/build)](https://github.com/golang-templates/seed/actions?query=workflow%3Abuild+branch%3Amaster)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/golang-templates/seed)](https://goreportcard.com/report/github.com/golang-templates/seed)
8+
[![Codecov](https://codecov.io/gh/golang-templates/seed/branch/master/graph/badge.svg)](https://codecov.io/gh/golang-templates/seed)
89

910
This is a GitHub repository template for Go. It has been created for ease-of-use for anyone who wants to:
1011

@@ -18,7 +19,7 @@ It includes:
1819
- dependency management using [Go Modules](https://github.com/golang/go/wiki/Modules),
1920
- code formatting using [gofumpt](https://github.com/mvdan/gofumpt),
2021
- linting with [golangci-lint](https://github.com/golangci/golangci-lint),
21-
- unit testing with [testify](https://github.com/stretchr/testify), [race detector](https://blog.golang.org/race-detector) and [code covarage HTML report](https://blog.golang.org/cover),
22+
- unit testing with [testify](https://github.com/stretchr/testify), [race detector](https://blog.golang.org/race-detector), code covarage [HTML report](https://blog.golang.org/cover) and [Codecov report](https://codecov.io/),
2223
- releasing using [GoReleaser](https://github.com/goreleaser/goreleaser),
2324
- dependencies scanning and updating thanks to [Dependabot](https://dependabot.com),
2425
- [Visual Studio Code](https://code.visualstudio.com) configuration with [Go](https://code.visualstudio.com/docs/languages/go) and [Remote Container](https://code.visualstudio.com/docs/remote/containers) support.
@@ -29,9 +30,10 @@ It includes:
2930

3031
## Usage
3132

33+
1. Sign up on [Codecov](https://codecov.io/) and configure [Codecov GitHub Application](https://github.com/apps/codecov) for all repositories.
3234
1. Click the `Use this template` button (alt. clone or download this repository).
3335
1. Replace all occurences of `golang-templates/seed` to `your_org/repo_name` in all files.
34-
1. Rename folder `cmd/seed` to `cmd/repo_name` and update [.goreleaser.yml](.goreleaser.yml).
36+
1. Rename folder `cmd/seed` to `cmd/app_name` and update [.goreleaser.yml](.goreleaser.yml) accordingly.
3537
1. Update [LICENSE](LICENSE) and [README.md](README.md).
3638

3739
## Build
@@ -77,15 +79,11 @@ However, changing to any other CI server should be very simple, because this rep
7779

7880
You can also use the `docker` make target to run the build using a docker container.
7981

80-
### How can I use Make on Windows
82+
### How can I build on Windows
8183

82-
Use [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10).
83-
Alternatively install [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) and [Make Windows port](https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058).
84-
85-
### How can I create a Docker image, deb/rpm/snap package, Homebrew Tap, Scoop App Manifest etc.
86-
87-
Take a look at GoReleaser [docs](https://goreleaser.com/customization/) as well as [its repo](https://github.com/goreleaser/goreleaser/) how it is dogfooding its functionality.
84+
Install [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) and add an alias in `~/.bashrc`: `alias make='mingw32-make.exe'`
8885

86+
Alternatively use [WSL (Windows Subsystem for Linux)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) or develop inside a [Remote Container](https://code.visualstudio.com/docs/remote/containers).
8987

9088
### How can I create an application installation script
9189

@@ -103,6 +101,10 @@ godownloader --repo=your_org/repo_name > ./install.sh
103101
curl -sSfL https://raw.githubusercontent.com/your_org/repo_name/master/install.sh | sh -s -- -b /usr/local/bin
104102
```
105103

104+
### How can I create a Docker image, deb/rpm/snap package, Homebrew Tap, Scoop App Manifest etc.
105+
106+
Take a look at GoReleaser [docs](https://goreleaser.com/customization/) as well as [its repo](https://github.com/goreleaser/goreleaser/) how it is dogfooding its functionality.
107+
106108
### How can I create a library instead of an application
107109

108110
You can change the [.goreleaser.yml](.goreleaser.yml) to contain:
@@ -121,32 +123,6 @@ Alternatively, you can completly remove the usage of GoReleaser if you prefer ha
121123
122124
By default `go test` records code coverage for the package that is currently tested. If you want to get more accurate (cross-package) coverage, then consider using [go-acc](https://github.com/ory/go-acc). [Read more](https://www.ory.sh/golang-go-code-coverage-accurate/).
123125

124-
### How to integrate with Codecov
125-
126-
1. Sing up on [Codecov](https://codecov.io/) and setup your repository.
127-
1. Additionally consider configuring [Codecov GitHub Application](https://github.com/apps/codecov) for better integration.
128-
1. Add [codecov-action](https://github.com/codecov/codecov-action) to [.github/workflows/build.yml](.github/workflows/build.yml):
129-
130-
```yaml
131-
- name: Upload coverage to Codecov
132-
uses: codecov/[email protected]
133-
with:
134-
file: ./coverage.out
135-
```
136-
137-
4. Add a badge in [README.md](README.md):
138-
139-
```md
140-
[![codecov](https://codecov.io/gh/your_org/repo_name/branch/master/graph/badge.svg)](https://codecov.io/gh/your_org/repo_name)
141-
```
142-
143-
Codecov integration example:
144-
- [repository](https://github.com/pellared/codecov-integration-example),
145-
- [coverage report](https://codecov.io/gh/pellared/codecov-integration-example/src/master/cmd/seed/main.go),
146-
- [pull request comment](https://github.com/pellared/codecov-integration-example/pull/3#issuecomment-653814033).
147-
148-
Read [Codecov docs](https://docs.codecov.io/docs/quick-start) for further information and troubleshooting.
149-
150126
### How to automate generating git tags for next release version
151127

152128
Auto-tagging can be done in many ways e.g. by using GitHub Actions like:

0 commit comments

Comments
 (0)