Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test badge #415

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CodeCov
on:
workflow_run:
workflows: [Tests]
types: [completed]

jobs:
coverage_report:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the pipeline fails, will the badge reflect update the status?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the pipeline fails (aka any of the tests fail) the coverage_report workflow won't be run and if the branch being tested happens to be the master branch, then the badge will be updated as failing

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage docopt yarg requests

- name: Calculate coverage
run: coverage run --source=pipreqs -m unittest discover

- name: Create XML report
run: coverage xml

alan-barzilay marked this conversation as resolved.
Show resolved Hide resolved
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.xml
fail_ci_if_error: true
alan-barzilay marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 1 addition & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests and Codecov
name: Tests
on:
push:
pull_request:
Expand Down Expand Up @@ -28,27 +28,3 @@ jobs:

- name: Test with tox
run: tox

alan-barzilay marked this conversation as resolved.
Show resolved Hide resolved
coverage_report:
needs: run_tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage docopt yarg requests

- name: Calculate coverage
run: coverage run --source=pipreqs -m unittest discover

- name: Create XML report
run: coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.xml
fail_ci_if_error: true
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
``pipreqs`` - Generate requirements.txt file for any project based on imports
=============================================================================

.. image:: https://img.shields.io/travis/bndr/pipreqs.svg
:target: https://travis-ci.org/bndr/pipreqs

.. image:: https://github.com/bndr/pipreqs/actions/workflows/tests.yml/badge.svg?branch=master
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set the tracking to tests performed on the master branch, a broken test in the next branch or in a random PR doesnt seem to be very informative or relevant to users since unless they manually instal pipreqs they will get the master branch through pypi

:target: https://github.com/bndr/pipreqs/actions/workflows/tests.yml

.. image:: https://img.shields.io/pypi/v/pipreqs.svg
:target: https://pypi.python.org/pypi/pipreqs
Expand Down
Loading