From b4a0f70b34adf26b5e74a8cd9a5e2fa9fa1623d4 Mon Sep 17 00:00:00 2001 From: Benjamin Thomas Schwertfeger Date: Sat, 4 Jul 2026 07:47:32 +0200 Subject: [PATCH] Upload coverage from the test job instead of a dedicated job --- .github/workflows/_codecov.yaml | 64 --------------------------------- .github/workflows/_test.yaml | 27 ++++++++++++-- .github/workflows/cicd.yaml | 18 +++------- 3 files changed, 29 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/_codecov.yaml diff --git a/.github/workflows/_codecov.yaml b/.github/workflows/_codecov.yaml deleted file mode 100644 index 9d4a19b..0000000 --- a/.github/workflows/_codecov.yaml +++ /dev/null @@ -1,64 +0,0 @@ -# -*- mode: yaml; coding: utf-8 -*- -# -# Copyright (C) 2023 Benjamin Thomas Schwertfeger -# All rights reserved. -# https://github.com/btschwertfeger -# -# Template workflow to build the project for a specific os -# and Python version, run the tests and upload the results to codecov. -# - -name: CodeCov - -on: - workflow_call: - inputs: - os: - type: string - required: true - python-version: - type: string - required: true - -permissions: read-all - -concurrency: - group: codecov-${{ github.ref }} - cancel-in-progress: true - -jobs: - codecov: - name: Coverage - runs-on: ${{ inputs.os }} - env: - OS: ${{ inputs.os }} - PYTHON: ${{ inputs.python-version }} - - steps: - - name: Checkout repository - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 - with: - python-version: ${{ inputs.python-version }} - - - name: Install dependencies - run: python -m pip install --upgrade pip - - - name: Install package - run: python -m pip install . -r requirements-dev.txt - - - name: Generate coverage report - run: pytest --retries 1 -n auto --cov --cov-report=xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f #v7.0.0 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.xml - env_vars: OS,PYTHON - fail_ci_if_error: true - flags: unittests - name: codecov-umbrella - verbose: true diff --git a/.github/workflows/_test.yaml b/.github/workflows/_test.yaml index 2b397d6..b301f49 100644 --- a/.github/workflows/_test.yaml +++ b/.github/workflows/_test.yaml @@ -4,7 +4,8 @@ # All rights reserved. # https://github.com/btschwertfeger # -# Template workflow to run the unit tests of the package +# Template workflow to run the unit tests of the package and upload the +# coverage report of the ubuntu-latest/3.11 matrix cell to Codecov. # name: Test Spot @@ -18,6 +19,9 @@ on: python-version: type: string required: true + secrets: + CODECOV_TOKEN: + required: false permissions: read-all @@ -25,6 +29,9 @@ jobs: Test: name: Test ${{ inputs.os }} ${{ inputs.python-version }} runs-on: ${{ inputs.os }} + env: + OS: ${{ inputs.os }} + PYTHON: ${{ inputs.python-version }} steps: - name: Checkout repository uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 @@ -41,4 +48,20 @@ jobs: run: python -m pip install --user . -r requirements-dev.txt - name: Run unit tests - run: pytest -vv --retries 1 -n auto tests + run: pytest -vv --retries 1 -n auto --cov --cov-report=xml tests + + - name: Upload coverage to Codecov + if: | + inputs.os == 'ubuntu-latest' + && inputs.python-version == '3.11' + && github.actor == 'btschwertfeger' + && (github.event_name == 'push' || github.event_name == 'release') + uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + env_vars: OS,PYTHON + fail_ci_if_error: true + flags: unittests + name: codecov-umbrella + verbose: true diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 8d974de..adc0f7a 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -57,7 +57,8 @@ jobs: os: ubuntu-latest python-version: "3.11" - ## Run the unit tests for Python 3.8 until 3.11 + ## Run the unit tests for Python 3.9 until 3.14 and upload the + ## coverage statistics to codecov ## Test: needs: [Pre-Commit] @@ -71,19 +72,8 @@ jobs: with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} - - ## Generates and uploads the coverage statistics to codecov - ## - CodeCov: - if: | - (success() && github.actor == 'btschwertfeger') - && (github.event_name == 'push' || github.event_name == 'release') - needs: [Pre-Commit] - uses: ./.github/workflows/_codecov.yaml - with: - os: ubuntu-latest - python-version: "3.11" - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} ## Uploads the package to test.pypi.org on master if triggered by ## a regular commit/push.