Skip to content

Add Codecov upload step to "Test Go" workflow #124

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

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
push:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
Expand All @@ -18,6 +19,7 @@ on:
pull_request:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
Expand Down Expand Up @@ -54,3 +56,11 @@ jobs:

- name: Run tests
run: task go:test

- name: Send unit tests coverage to Codecov
if: matrix.operating-system == 'ubuntu-latest'
uses: codecov/codecov-action@v2
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: true
8 changes: 6 additions & 2 deletions workflow-templates/test-go-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ Markdown badge:

```markdown
[![Test Go status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/test-go-task.yml)
[![Codecov](https://codecov.io/gh/REPO_OWNER/REPO_NAME/branch/main/graph/badge.svg)](https://codecov.io/gh/REPO_OWNER/REPO_NAME)
```

Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
- Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
- If the coverage badge should reflect the coverage for a branch named something other than `main`, adjust the badge URL accordingly.

---

Asciidoc badge:

```adoc
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/test-go-task.yml/badge.svg["Test Go status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/test-go-task.yml"]
image:https://codecov.io/gh/{repository-owner}/{repository-name}/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/{repository-owner}/{repository-name}"]
```

Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
- Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
- If the coverage badge should reflect the coverage for a branch named something other than `main`, adjust the badge URL accordingly.

## Commit message

Expand Down
10 changes: 10 additions & 0 deletions workflow-templates/test-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
push:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
Expand All @@ -18,6 +19,7 @@ on:
pull_request:
paths:
- ".github/workflows/test-go-task.ya?ml"
- "codecov.ya?ml"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
Expand Down Expand Up @@ -54,3 +56,11 @@ jobs:

- name: Run tests
run: task go:test

- name: Send unit tests coverage to Codecov
if: matrix.operating-system == 'ubuntu-latest'
uses: codecov/codecov-action@v2
with:
file: ./coverage_unit.txt
flags: unit
fail_ci_if_error: true