summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-02-24 15:15:18 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-02-24 20:44:17 -0500
commit84cbf083a18a814c501eecb450d7ac4126e74054 (patch)
tree31bd5beecd6f6d6ca1d736b2e87c5264a3f271a6
parentec9668269897631a263b71fb9727555570e9f24f (diff)
downloadpython-coveragepy-git-84cbf083a18a814c501eecb450d7ac4126e74054.tar.gz
build: nicer publishing of HTML report
Also, this correctly combines results from different runners.
-rw-r--r--.github/workflows/coverage.yml65
-rw-r--r--coverage/cmdline.py2
-rw-r--r--igor.py6
-rw-r--r--metacov.ini5
4 files changed, 57 insertions, 21 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 60ae9e03..632babfa 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -5,7 +5,8 @@ name: "Coverage"
on:
push:
- branches: ["master"]
+ branches:
+ - master
# as currently structured, this adds too many jobs (checks?), so don't run it
# on pull requests yet.
#pull_request:
@@ -40,6 +41,8 @@ jobs:
steps:
- name: "Check out the repo"
uses: "actions/checkout@v2"
+ with:
+ fetch-depth: "0"
- name: "Set up Python"
uses: "actions/setup-python@v2"
@@ -65,7 +68,15 @@ jobs:
run: |
set -xe
python -m tox
- python -m igor combine_html
+
+ - name: "Combine"
+ env:
+ COVERAGE_COVERAGE: "yes"
+ COVERAGE_RCFILE: "metacov.ini"
+ COVERAGE_METAFILE: ".metacov"
+ run: |
+ set -xe
+ COVERAGE_DEBUG=dataio python -m igor combine_html
mv .metacov .metacov.${{ matrix.python-version }}.${{ matrix.os }}
- name: "Upload coverage data"
@@ -95,7 +106,6 @@ jobs:
set -xe
python -VV
python -m site
- python -m pip install -r requirements/ci.pip
python setup.py --quiet clean develop
python igor.py zip_mods install_egg
@@ -105,9 +115,15 @@ jobs:
name: metacov
- name: "Combine and report"
+ id: combine
+ env:
+ COVERAGE_RCFILE: "metacov.ini"
+ COVERAGE_METAFILE: ".metacov"
run: |
set -xe
python -m igor combine_html
+ python -m coverage json
+ echo "::set-output name=total::$(python -c "import json;print(format(json.load(open('coverage.json'))['totals']['percent_covered'],'.2f'))")"
- name: "Upload to codecov"
uses: codecov/codecov-action@v1
@@ -120,17 +136,24 @@ jobs:
name: html_report
path: htmlcov
- - name: Create slug
- id: slug
- run: |
- echo "::set-output name=slug::$(date +'%Y%m%d')_$(echo ${{github.sha}} | cut -c 1-12)"
+ - name: "Upload JSON report"
+ uses: actions/upload-artifact@v2
+ with:
+ name: json_report
+ path: coverage.json
- - name: Create URL
- id: url
+ - name: "Create info for pushing to report repo"
+ id: info
run: |
- echo "::set-output name=url::https://nedbat.github.io/coverage-reports/reports/${{ steps.slug.outputs.slug }}/htmlcov"
-
- - name: Pushes to another repository
+ export SHA10=$(echo ${{ github.sha }} | cut -c 1-10)
+ export SLUG=$(date +'%Y%m%d')_$SHA10
+ export REF="${{ github.ref }}"
+ echo "::set-output name=sha10::$SHA10"
+ echo "::set-output name=slug::$SLUG"
+ echo "::set-output name=url::https://nedbat.github.io/coverage-reports/reports/$SLUG/htmlcov"
+ echo "::set-output name=branch::${REF#refs/heads/}"
+
+ - name: "Push to report repository"
uses: sebastian-palma/github-action-push-to-another-repository@allow-creating-destination-directory
env:
API_TOKEN_GITHUB: ${{ secrets.COVERAGE_REPORTS_TOKEN }}
@@ -138,17 +161,23 @@ jobs:
source-directory: 'htmlcov'
destination-github-username: 'nedbat'
destination-repository-name: 'coverage-reports'
- destination-repository-directory: 'reports/${{ steps.slug.outputs.slug }}'
+ destination-repository-directory: 'reports/${{ steps.info.outputs.slug }}'
empty-repository: false
create-destination-directory: true
target-branch: main
- commit-message: "Coverage report for ${{ github.sha }}"
+ commit-message: >-
+ ${{ steps.combine.outputs.total }}% - ${{ github.event.head_commit.message }}
+
+
+ ${{ steps.info.outputs.url }}
+
+ ${{ steps.info.outputs.sha10 }}: ${{ steps.info.outputs.branch }}
user-email: ned@nedbatchelder.com
- - name: Create redirection HTML file
+ - name: "Create redirection HTML file"
run: |
echo "<html><head>" > coverage-report-redirect.html
- echo "<meta http-equiv='refresh' content='0;url=${{ steps.url.outputs.url }}' />" >> coverage-report-redirect.html
+ echo "<meta http-equiv='refresh' content='0;url=${{ steps.info.outputs.url }}' />" >> coverage-report-redirect.html
echo "<body>Coverage report redirect..." >> coverage-report-redirect.html
- name: "Upload HTML redirect"
@@ -157,6 +186,6 @@ jobs:
name: coverage-report-redirect.html
path: coverage-report-redirect.html
- - name: Show link to report
+ - name: "Show link to report"
run: |
- echo "Coverage report: ${{ steps.url.outputs.url }}"
+ echo "Coverage report: ${{ steps.info.outputs.url }}"
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index cdcde451..0be0cca1 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -771,7 +771,7 @@ class CoverageScript(object):
self.coverage.load()
data = self.coverage.get_data()
print(info_header("data"))
- print("path: %s" % self.coverage.get_data().data_filename())
+ print("path: %s" % data.data_filename())
if data:
print("has_arcs: %r" % data.has_arcs())
summary = line_counts(data, fullpath=True)
diff --git a/igor.py b/igor.py
index d8d2069d..a4a460c0 100644
--- a/igor.py
+++ b/igor.py
@@ -20,7 +20,11 @@ import textwrap
import warnings
import zipfile
-import pytest
+try:
+ import pytest
+except ImportError:
+ # We want to be able to run this for some tasks that don't need pytest.
+ pytest = None
# Contants derived the same as in coverage/env.py. We can't import
# that file here, it would be evaluated too early and not get the
diff --git a/metacov.ini b/metacov.ini
index 53b9f409..b3dffc3e 100644
--- a/metacov.ini
+++ b/metacov.ini
@@ -77,7 +77,6 @@ partial_branches =
if .* env.JYTHON
if .* env.IRONPYTHON
-ignore_errors = true
precision = 2
[paths]
@@ -87,3 +86,7 @@ source =
*/coverage/trunk
*\coveragepy
/io
+ # GitHub Actions on Ubuntu uses /home/runner/work/coveragepy
+ # GitHub Actions on Mac uses /Users/runner/work/coveragepy
+ # GitHub Actions on Window uses D:\a\coveragepy\coveragepy
+ */coveragepy