diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8187c0f..a734de3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Go +name: Continuous Integration env: GO_VERSION: "1.23" @@ -59,6 +59,14 @@ jobs: name: code-coverage path: coverage.txt + - name: check test coverage + uses: vladopajic/go-test-coverage@v2 + with: + profile: coverage.txt + threshold-file: 0 + threshold-package: 0 + threshold-total: 30 + coverage: name: "Code coverage report" if: github.event_name == 'pull_request' diff --git a/Makefile b/Makefile index 3f93bb5..9289225 100644 --- a/Makefile +++ b/Makefile @@ -8,5 +8,5 @@ lint: golangci-lint run ./... test: - go test -race -coverprofile=coverage.txt ./... + go test -covermode=atomic -race -coverprofile=coverage.txt ./... diff --git a/README.md b/README.md index 8b19eda..0459806 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -# go-ci \ No newline at end of file +# Golang CI/CD with Github Actions + +[![coverage](https://raw.githubusercontent.com/edmarfelipe/go-ci/badges/.badges/main/coverage.svg)](/.github/.testcoverage.yml) + +This repository is a simple example of how to use Github Actions to build and test a Golang application. + +## Features + +- Build with Cache to speed up the process +- Run tests with coverage +- Push code coverage to PR comments +- Push linting errors to PR code review