coverage: Include code that runs in subprocesses

This commit is contained in:
antonblr 2020-12-22 20:27:00 -08:00
parent da01ee0a4b
commit 8550c29180
3 changed files with 4 additions and 51 deletions

View File

@ -137,22 +137,13 @@ jobs:
- name: Test with coverage
if: "matrix.use_coverage"
env:
_PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
COVERAGE_PROCESS_START: ".coveragerc"
_PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
run: "tox -e ${{ matrix.tox_env }}"
run: "tox -e ${{ matrix.tox_env }}-coverage"
- name: Prepare coverage token
if: (matrix.use_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' ))
run: |
python scripts/append_codecov_token.py
- name: Report coverage
if: (matrix.use_coverage)
- name: Upload coverage
if: matrix.use_coverage && github.repository == 'pytest-dev/pytest'
env:
CODECOV_NAME: ${{ matrix.name }}
run: bash scripts/report-coverage.sh -F GHA,${{ runner.os }}
run: bash scripts/upload-coverage.sh -F GHA,${{ runner.os }}
linting:
runs-on: ubuntu-latest

View File

@ -1,36 +0,0 @@
"""
Appends the codecov token to the 'codecov.yml' file at the root of the repository.
This is done by CI during PRs and builds on the pytest-dev repository so we can
upload coverage, at least until codecov grows some native integration with GitHub Actions.
See discussion in https://github.com/pytest-dev/pytest/pull/6441 for more information.
"""
import os.path
from textwrap import dedent
def main():
this_dir = os.path.dirname(__file__)
cov_file = os.path.join(this_dir, "..", "codecov.yml")
assert os.path.isfile(cov_file), "{cov_file} does not exist".format(
cov_file=cov_file
)
with open(cov_file, "a") as f:
# token from: https://codecov.io/gh/pytest-dev/pytest/settings
# use same URL to regenerate it if needed
text = dedent(
"""
codecov:
token: "1eca3b1f-31a2-4fb8-a8c3-138b441b50a7"
"""
)
f.write(text)
print("Token updated:", cov_file)
if __name__ == "__main__":
main()

View File

@ -10,9 +10,7 @@ else
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
fi
python -m coverage combine
python -m coverage xml
python -m coverage report -m
# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
bash codecov-upload.sh -Z -X fix -f coverage.xml "$@"