Skip to content

Commit 65c2be9

Browse files
Upload coverage from the test job instead of a dedicated job (#188)
1 parent b43e482 commit 65c2be9

3 files changed

Lines changed: 29 additions & 80 deletions

File tree

.github/workflows/_codecov.yaml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/_test.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# All rights reserved.
55
# https://github.com/btschwertfeger
66
#
7-
# Template workflow to run the unit tests of the package
7+
# Template workflow to run the unit tests of the package and upload the
8+
# coverage report of the ubuntu-latest/3.11 matrix cell to Codecov.
89
#
910

1011
name: Test Spot
@@ -18,13 +19,19 @@ on:
1819
python-version:
1920
type: string
2021
required: true
22+
secrets:
23+
CODECOV_TOKEN:
24+
required: false
2125

2226
permissions: read-all
2327

2428
jobs:
2529
Test:
2630
name: Test ${{ inputs.os }} ${{ inputs.python-version }}
2731
runs-on: ${{ inputs.os }}
32+
env:
33+
OS: ${{ inputs.os }}
34+
PYTHON: ${{ inputs.python-version }}
2835
steps:
2936
- name: Checkout repository
3037
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
@@ -41,4 +48,20 @@ jobs:
4148
run: python -m pip install --user . -r requirements-dev.txt
4249

4350
- name: Run unit tests
44-
run: pytest -vv --retries 1 -n auto tests
51+
run: pytest -vv --retries 1 -n auto --cov --cov-report=xml tests
52+
53+
- name: Upload coverage to Codecov
54+
if: |
55+
inputs.os == 'ubuntu-latest'
56+
&& inputs.python-version == '3.11'
57+
&& github.actor == 'btschwertfeger'
58+
&& (github.event_name == 'push' || github.event_name == 'release')
59+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
60+
with:
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
files: coverage.xml
63+
env_vars: OS,PYTHON
64+
fail_ci_if_error: true
65+
flags: unittests
66+
name: codecov-umbrella
67+
verbose: true

.github/workflows/cicd.yaml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ jobs:
5757
os: ubuntu-latest
5858
python-version: "3.11"
5959

60-
## Run the unit tests for Python 3.8 until 3.11
60+
## Run the unit tests for Python 3.9 until 3.14 and upload the
61+
## coverage statistics to codecov
6162
##
6263
Test:
6364
needs: [Pre-Commit]
@@ -71,19 +72,8 @@ jobs:
7172
with:
7273
os: ${{ matrix.os }}
7374
python-version: ${{ matrix.python-version }}
74-
75-
## Generates and uploads the coverage statistics to codecov
76-
##
77-
CodeCov:
78-
if: |
79-
(success() && github.actor == 'btschwertfeger')
80-
&& (github.event_name == 'push' || github.event_name == 'release')
81-
needs: [Pre-Commit]
82-
uses: ./.github/workflows/_codecov.yaml
83-
with:
84-
os: ubuntu-latest
85-
python-version: "3.11"
86-
secrets: inherit
75+
secrets:
76+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8777

8878
## Uploads the package to test.pypi.org on master if triggered by
8979
## a regular commit/push.

0 commit comments

Comments
 (0)