From 8550c29180afb6f1138c81645f7d92f644aaf74d Mon Sep 17 00:00:00 2001 From: antonblr Date: Tue, 22 Dec 2020 20:27:00 -0800 Subject: [PATCH] coverage: Include code that runs in subprocesses --- .github/workflows/main.yml | 17 +++------ scripts/append_codecov_token.py | 36 ------------------- ...{report-coverage.sh => upload-coverage.sh} | 2 -- 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 scripts/append_codecov_token.py rename scripts/{report-coverage.sh => upload-coverage.sh} (88%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index beb501785..a3ea24b7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/scripts/append_codecov_token.py b/scripts/append_codecov_token.py deleted file mode 100644 index 5c617aafb..000000000 --- a/scripts/append_codecov_token.py +++ /dev/null @@ -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() diff --git a/scripts/report-coverage.sh b/scripts/upload-coverage.sh similarity index 88% rename from scripts/report-coverage.sh rename to scripts/upload-coverage.sh index fbcf20ca9..ad3dd4828 100755 --- a/scripts/report-coverage.sh +++ b/scripts/upload-coverage.sh @@ -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 "$@"