Skip to content

codecov coverage uploaded after tests succeed #6705

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

Closed
97 changes: 62 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ on:
# A pre-commit hook (scripts/check_all_tests_are_covered.py)
# enforces that test run just once per OS / floatX setting.

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:

changes:
Expand Down Expand Up @@ -166,14 +173,12 @@ jobs:
- name: Run tests
run: |
conda activate pymc-test
python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
python -m pytest -vv --cov=pymc --cov-report=xml:coverage/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
env_vars: TEST_SUBSET
name: ${{ matrix.os }} ${{ matrix.floatx }}
fail_ci_if_error: false
name: coverage
path: coverage/coverage-${{ matrix.id }}.xml

windows:
needs: changes
Expand Down Expand Up @@ -242,14 +247,12 @@ jobs:
# The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682).
run: >-
conda activate pymc-test &&
python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET%
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
python -m pytest -vv --cov=pymc --cov-report=xml:coverage/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET%
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
env_vars: TEST_SUBSET
name: ${{ matrix.os }} ${{ matrix.floatx }}
fail_ci_if_error: false
name: coverage
path: coverage/coverage-${{ matrix.id }}.xml

macos:
needs: changes
Expand Down Expand Up @@ -321,14 +324,12 @@ jobs:
python --version
- name: Run tests
run: |
python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
python -m pytest -vv --cov=pymc --cov-report=xml:coverage/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
env_vars: TEST_SUBSET
name: ${{ matrix.os }} ${{ matrix.floatx }}
fail_ci_if_error: false
name: coverage
path: coverage/coverage-${{ matrix.id }}.xml

external_samplers:
needs: changes
Expand Down Expand Up @@ -394,14 +395,12 @@ jobs:
pip install git+https://github.com/blackjax-devs/[email protected]
- name: Run tests
run: |
python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
python -m pytest -vv --cov=pymc --cov-report=xml:coverage/coverage-${{ matrix.os }}-${{ matrix.python-version }}.xml --no-cov-on-fail --cov-report term --durations=50 $TEST_SUBSET
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
env_vars: TEST_SUBSET
name: JAX tests - ${{ matrix.os }} ${{ matrix.floatx }}
fail_ci_if_error: false
name: coverage
path: coverage/coverage-${{ matrix.id }}.xml

float32:
needs: changes
Expand Down Expand Up @@ -466,14 +465,12 @@ jobs:
# The ">-" in the next line replaces newlines with spaces (see https://stackoverflow.com/a/66809682).
run: >-
conda activate pymc-test &&
python -m pytest -vv --cov=pymc --cov-report=xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET%
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
python -m pytest -vv --cov=pymc --cov-report=xml:coverage/coverage-${steps.matrix-id.outputs.id}.xml --no-cov-on-fail --cov-report term --durations=50 %TEST_SUBSET%
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
env_vars: TEST_SUBSET
name: ${{ matrix.os }} ${{ matrix.floatx }}
fail_ci_if_error: false
name: coverage
path: coverage/coverage-${{ matrix.id }}.xml

all_tests:
if: ${{ always() }}
Expand All @@ -488,3 +485,33 @@ jobs:
needs.external_samplers.result != 'success' ||
needs.float32.result != 'success' ) }}
run: exit 1


upload-coverage:
runs-on: ubuntu-latest
needs: [all_tests, changes]
if: ${{ needs.all_tests.result == 'success' && needs.changes.outputs.changes == 'true'}}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install -U coverage>=5.1 coveralls
- name: Download coverage files
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- name: Merge coverage reports
run: |
# Find all coverage reports and merge them into a single file
python -m coverage combine --append coverage/*.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }} # use token for more robust uploads
directory: ./coverage/
fail_ci_if_error: true