Skip to content

Commit 6086530

Browse files
authored
Merge pull request #124 from per1234/codecov
Add Codecov upload step to "Test Go" workflow
2 parents ad19354 + eda241a commit 6086530

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

workflow-templates/dependabot/workflow-template-copies/.github/workflows/test-go-task.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
push:
1111
paths:
1212
- ".github/workflows/test-go-task.ya?ml"
13+
- "codecov.ya?ml"
1314
- "go.mod"
1415
- "go.sum"
1516
- "Taskfile.ya?ml"
@@ -18,6 +19,7 @@ on:
1819
pull_request:
1920
paths:
2021
- ".github/workflows/test-go-task.ya?ml"
22+
- "codecov.ya?ml"
2123
- "go.mod"
2224
- "go.sum"
2325
- "Taskfile.ya?ml"
@@ -54,3 +56,11 @@ jobs:
5456

5557
- name: Run tests
5658
run: task go:test
59+
60+
- name: Send unit tests coverage to Codecov
61+
if: matrix.operating-system == 'ubuntu-latest'
62+
uses: codecov/codecov-action@v2
63+
with:
64+
file: ./coverage_unit.txt
65+
flags: unit
66+
fail_ci_if_error: true

workflow-templates/test-go-task.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ Markdown badge:
3838

3939
```markdown
4040
[![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)
41+
[![Codecov](https://codecov.io/gh/REPO_OWNER/REPO_NAME/branch/main/graph/badge.svg)](https://codecov.io/gh/REPO_OWNER/REPO_NAME)
4142
```
4243

43-
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)).
44+
- 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)).
45+
- If the coverage badge should reflect the coverage for a branch named something other than `main`, adjust the badge URL accordingly.
4446

4547
---
4648

4749
Asciidoc badge:
4850

4951
```adoc
5052
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"]
53+
image:https://codecov.io/gh/{repository-owner}/{repository-name}/branch/main/graph/badge.svg["Codecov", link="https://codecov.io/gh/{repository-owner}/{repository-name}"]
5154
```
5255

53-
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)).
56+
- 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)).
57+
- If the coverage badge should reflect the coverage for a branch named something other than `main`, adjust the badge URL accordingly.
5458
5559
## Commit message
5660

workflow-templates/test-go-task.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
push:
1111
paths:
1212
- ".github/workflows/test-go-task.ya?ml"
13+
- "codecov.ya?ml"
1314
- "go.mod"
1415
- "go.sum"
1516
- "Taskfile.ya?ml"
@@ -18,6 +19,7 @@ on:
1819
pull_request:
1920
paths:
2021
- ".github/workflows/test-go-task.ya?ml"
22+
- "codecov.ya?ml"
2123
- "go.mod"
2224
- "go.sum"
2325
- "Taskfile.ya?ml"
@@ -54,3 +56,11 @@ jobs:
5456

5557
- name: Run tests
5658
run: task go:test
59+
60+
- name: Send unit tests coverage to Codecov
61+
if: matrix.operating-system == 'ubuntu-latest'
62+
uses: codecov/codecov-action@v2
63+
with:
64+
file: ./coverage_unit.txt
65+
flags: unit
66+
fail_ci_if_error: true

0 commit comments

Comments
 (0)