Skip to content

Commit 9fb3e7e

Browse files
authored
Merge pull request #88 from oemof/revision/replace-coveralls
Replace coveralls by GH workflow
2 parents 4eaf644 + ac89f9f commit 9fb3e7e

4 files changed

Lines changed: 95 additions & 13 deletions

File tree

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source = src
55
branch = true
66
source =
77
src
8-
tests
8+
relative_files = true
99
parallel = true
1010

1111
[report]

.github/workflows/coverage.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Additional copyright: Joachim Jablon, kieferro (MIT license)
2+
name: Post coverage comment
3+
4+
on:
5+
workflow_run:
6+
workflows: ["tox pytests"]
7+
types:
8+
- completed
9+
10+
jobs:
11+
test:
12+
name: Run tests & display coverage
13+
runs-on: ubuntu-latest
14+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
15+
permissions:
16+
# Gives the action the necessary permissions for publishing new
17+
# comments in pull requests.
18+
pull-requests: write
19+
# Gives the action the necessary permissions for editing existing
20+
# comments (to avoid publishing multiple comments in the same PR)
21+
contents: write
22+
# Gives the action the necessary permissions for looking up the
23+
# workflow that launched this workflow, and download the related
24+
# artifact that contains the comment to be published
25+
actions: read
26+
steps:
27+
# DO NOT run actions/checkout here, for security reasons
28+
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
29+
- name: Post comment
30+
uses: py-cov-action/python-coverage-comment-action@v3
31+
with:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
34+
# Update those if you changed the default values:
35+
# COMMENT_ARTIFACT_NAME: python-coverage-comment-action
36+
# COMMENT_FILENAME: python-coverage-comment-action.txt

.github/workflows/tox_pytests.yml

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Additional copyright: Joachim Jablon, kieferro (MIT license)
12
name: tox pytests
23

34
on:
@@ -27,15 +28,64 @@ jobs:
2728
- name: Install dependencies
2829
run: |
2930
python -m pip install --upgrade pip
30-
python -m pip install tox tox-gh-actions coverage coveralls
31+
python -m pip install tox tox-gh-actions coverage
3132
- name: Test with tox
3233
run: tox
34+
env:
35+
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
36+
# The file name prefix must be ".coverage." for "coverage combine"
37+
# enabled by "MERGE_COVERAGE_FILES: true" to work. A "subprocess"
38+
# error with the message "No data to combine" will be triggered if
39+
# this prefix is not used.
3340

3441
- name: Check test coverage
35-
run: coverage report -m --fail-under=${{ matrix.vcs == 'bzr' && 84 || 85 }}
36-
37-
- name: Report to coveralls
38-
run: coveralls
42+
run: coverage report -m --fail-under=85
3943
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
COVERALLS_SERVICE_NAME: github
44+
COVERAGE_FILE: ".coverage.${{ matrix.python-version }}"
45+
46+
- name: Store coverage file
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: coverage-${{ matrix.python-version }}
50+
path: .coverage.${{ matrix.python-version }}
51+
# By default hidden files/folders (i.e. starting with .) are ignored.
52+
# You may prefer (for security reasons) not setting this and instead
53+
# set COVERAGE_FILE above to not start with a `.`, but you cannot
54+
# use "MERGE_COVERAGE_FILES: true" later on and need to manually
55+
# combine the coverage file using "pipx run coverage combine"
56+
include-hidden-files: true
57+
58+
coverage:
59+
name: Coverage
60+
runs-on: ubuntu-latest
61+
needs: pytest
62+
permissions:
63+
pull-requests: write
64+
contents: write
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
# This is optional since by default it's to true. The git
69+
# operations in python-coverage-comment-action utilize the token
70+
# stored by actions/checkout.
71+
persist-credentials: true
72+
73+
- uses: actions/download-artifact@v4
74+
id: download
75+
with:
76+
pattern: coverage-*
77+
merge-multiple: true
78+
79+
- name: Coverage comment
80+
id: coverage_comment
81+
uses: py-cov-action/python-coverage-comment-action@v3
82+
with:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
MERGE_COVERAGE_FILES: true
85+
86+
- name: Store Pull Request comment to be posted
87+
uses: actions/upload-artifact@v4
88+
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
89+
with:
90+
name: python-coverage-comment-action
91+
path: python-coverage-comment-action.txt

README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Overview
1010
* - docs
1111
- |docs|
1212
* - tests
13-
- | |tox-pytest| |tox-checks| |coveralls|
13+
- | |tox-pytest| |tox-checks|
1414
* - package
1515
- | |version| |wheel| |supported-versions| |supported-implementations| |commits-since| |packaging|
1616

@@ -28,10 +28,6 @@ Overview
2828
:target: https://oemof-demand.readthedocs.io/
2929
:alt: Documentation Status
3030

31-
.. |coveralls| image:: https://coveralls.io/repos/oemof/oemof-demand/badge.svg?branch=dev&service=github
32-
:alt: Coverage Status
33-
:target: https://coveralls.io/github/oemof/oemof-demand?branch=dev
34-
3531
.. |version| image:: https://img.shields.io/pypi/v/oemof-demand.svg
3632
:alt: PyPI Package latest release
3733
:target: https://pypi.org/project/oemof-demand

0 commit comments

Comments
 (0)