Skip to content

Commit

Permalink
Revert Generate coverage reports using only GitHub Actions (#455)
Browse files Browse the repository at this point in the history
* Revert "Generate coverage reports using only GitHub Actions, without codecov.io (#447)"

This reverts commit 9554985.

* Add news fragment
  • Loading branch information
hynek authored Dec 19, 2022
1 parent 24f65a0 commit 3418975
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
* @twisted/twisted-contributors
80 changes: 0 additions & 80 deletions .github/scripts/pr_comment.js

This file was deleted.

85 changes: 1 addition & 84 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
tags: [ "**" ]
pull_request:

permissions:
contents: read

defaults:
run:
shell: bash
Expand Down Expand Up @@ -99,18 +96,8 @@ jobs:

- run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl

- name: Store coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
# It is important to keep the unique names for the coverage files
# so that when uploaded to the same artifact, they don't overlap.
path: .coverage*

- name: Codecov
run: |
ls -al .coverage*
coverage combine
codecov -n "GitHub Actions - ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }}"
Expand Down Expand Up @@ -150,18 +137,8 @@ jobs:

- run: nox --python ${{ matrix.python.action }} -e ${{ matrix.task.nox }} -- --use-wheel dist/*.whl

- name: Store coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
# It is important to keep the unique names for the coverage files
# so that when uploaded to the same artifact, they don't overlap.
path: .coverage*

- name: Codecov
run: |
ls -al .coverage*
coverage combine
codecov -n "GitHub Actions - ${{ matrix.task.name}} - ${{ matrix.os.name }} ${{ matrix.python.name }}"
check:
Expand Down Expand Up @@ -255,65 +232,6 @@ jobs:
password: ${{ secrets.PYPI_TOKEN }}
verbose: true

coverage-report:
name: Coverage report
runs-on: ubuntu-latest
permissions:
# Even we send a comment to a PR, we use the issues API.
# Issues and PR share the same comment API.
issues: write
needs:
# We are waiting only for test jobs.
- test-linux
- test-windows
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade coverage[toml] diff_cover
- name: Download coverage reports
uses: actions/download-artifact@v3
with:
name: coverage
path: .

- name: Combine coverage
run: coverage combine

- name: Report coverage
run: |
coverage xml
coverage report --no-skip-covered --show-missing
# Wrap output in markdown verbatim text.
echo '```' > coverage-report.txt
coverage report --show-missing >> coverage-report.txt
echo '```' >> coverage-report.txt
diff-cover --markdown-report diff-cover.md --compare-branch origin/trunk coverage.xml
cat diff-cover.md >> coverage-report.txt
# Use the generic JS script to call our custom script
# for sending a comment to a PR.
- name: Send coverage comment to PR
uses: actions/github-script@v3
env:
COMMENT_MARKER: "<!--- automatic-coverage-report -->"
COMMENT_BODY: coverage-report.txt
with:
script: |
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/scripts/pr_comment.js`)
// Only pass top level objects as GHA does dependecy injection.
await script({github, context, process})
- name: Enforce diff coverage
run: |
diff-cover --fail-under=100 --compare-branch origin/trunk coverage.xml
# This is a meta-job to simplify PR CI enforcement configuration in GitHub.
# Inside the GitHub config UI you only configure this job as required.
# All the extra requirements are defined "as code" as part of the `needs`
Expand All @@ -332,9 +250,8 @@ jobs:
- test-windows
- check
- pypi-publish
- coverage-report
steps:
- name: Require all successes
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
uses: re-actors/alls-green@3a2de129f0713010a71314c74e33c0e3ef90e696
with:
jobs: ${{ toJSON(needs) }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dist/
venv/
htmlcov/
.coverage
coverage.xml
*~
*.lock
apidocs/
Expand Down
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def tests(session: nox.Session) -> None:
session.run("coverage", "run", "--module", "twisted.trial", *posargs)

if os.environ.get("CI") != "true":
# When running the test locally, show the coverage report.
session.notify("coverage_report")
else:
session.run("coverage", "combine")


@nox.session
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ branch = true
source = ["towncrier"]

[tool.coverage.paths]
source = [
"src",
"*.nox/*/site-packages",
# required until coverage 6.6.0 is used: https://github.com/nedbat/coveragepy/issues/991
"*.nox\\*\\*\\site-packages"
]
source = ["src", ".nox/*/site-packages"]

[tool.coverage.report]
show_missing = true
Expand All @@ -107,4 +102,5 @@ exclude_lines = [
]
omit = [
"src/towncrier/__main__.py",
"src/towncrier/test/*",
]
File renamed without changes.

0 comments on commit 3418975

Please sign in to comment.