Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Codecov to CI #34

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# https://docs.codecov.com/docs/codecovyml-reference
codecov:
require_ci_to_pass: true
notify:
wait_for_ci: true

# https://docs.codecov.com/docs/coverage-configuration
coverage:
range: "50...65"

# https://docs.codecov.com/docs/commit-status
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: 50%

# https://docs.codecov.com/docs/flags#recommended-automatic-flag-management
flag_management:
default_rules:
carryforward: false

# https://docs.codecov.com/docs/pull-request-comments
comment:
layout: reach,diff,files,flags

# https://docs.codecov.com/docs/github-checks
# Annotations may be hidden by pressing the "a" key or by unselecting "Show annotations" in the top right of the file.
github_checks:
annotations: true
17 changes: 17 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ jobs:
- name: Run linters
run: bin/task lint

# The token is not required but should make uploads more stable.
# If secrets are unavailable (for example, for a pull request from a fork), it fallbacks to the tokenless uploads.
#
# Unfortunately, it seems that tokenless uploads fail too often.
# See https://github.com/codecov/codecov-action/issues/837.
#
# We also can't use ${{ vars.CODECOV_TOKEN }}: https://github.com/orgs/community/discussions/44322
- name: Upload coverage information to codecov
if: always()
uses: codecov/codecov-action@v4
with:
token: 44625ce5-0586-4c09-93b3-8135f5fc2fb5
AlekSi marked this conversation as resolved.
Show resolved Hide resolved
files: ./cover.txt
flags: test
fail_ci_if_error: true
verbose: true

- name: Check dirty
run: |
git status
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ tasks:
test-short:
desc: "Run short tests"
cmds:
- go test -short -race ./...
- go test -short -race -coverpkg=./... -coverprofile=cover.txt ./...

test:
desc: "Run all tests (requires MONGODB_URI set)"
cmds:
- go test -race -count=1 ./...
- go test -race -count=1 -coverpkg=./... -coverprofile=cover.txt ./...
env:
MONGODB_URI: mongodb://localhost:27017/

Expand Down