tj-actions / coverage-badge-py

:octocat: Github action to generate coverage badge without uploading results to a 3rd party.
MIT License
56 stars 19 forks source link

[BUG] <AttributeError: 'Numbers' object has no attribute 'display_covered'> #163

Open Yegor-V opened 4 months ago

Yegor-V commented 4 months ago

Is there an existing issue for this?

Does this issue exist in the latest version?

Describe the bug?

The GitHub pipeline started to fail with error AttributeError: 'Numbers' object has no attribute 'display_covered'

To Reproduce

  1. Setup GitHub action that runs tests with coverage
  2. Add the "coverage badge" step after:
    - name: Coverage Badge
      uses: tj-actions/coverage-badge-py@v2
  3. Action fails with error AttributeError: 'Numbers' object has no attribute 'display_covered'

What OS are you seeing the problem on?

ubuntu-latest or ubuntu-22.04

Expected behavior?

The action run without error

Relevant log output

Run tj-actions/coverage-badge-py@v2
Run pip install -U coverage-badge

Collecting coverage-badge
  Downloading coverage_badge-1.1.0-py2.py3-none-any.whl.metadata (3.2 kB)
Requirement already satisfied: coverage in /opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages (from coverage-badge) (7.5.0)
Downloading coverage_badge-1.1.0-py2.py3-none-any.whl (6.4 kB)
Installing collected packages: coverage-badge
Successfully installed coverage-badge-1.1.0

Notice:  A new release of pip is available: 23.0.1 -> 24.0
Notice:  To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.19/x64/bin/coverage-badge", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage_badge/__main__.py", line 171, in main
    total = get_total()
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage_badge/__main__.py", line 76, in get_total
    return coverage.results.Numbers(precision=cov.config.precision).display_covered(total)
AttributeError: 'Numbers' object has no attribute 'display_covered'
Error: Process completed with exit code 1.

Has all relevant logs been included?

Anything else?

No response

Code of Conduct

mcw92 commented 4 months ago

I am encountering the very same problem in our repo when using this action in our test workflow like this:

            - name: Coverage Badge
              uses: tj-actions/coverage-badge-py@v2

I see the following error message:

Run tj-actions/coverage-badge-py@v2
Run pip install -U coverage-badge
Collecting coverage-badge
  Downloading coverage_badge-1.1.0-py2.py3-none-any.whl.metadata (3.2 kB)
Requirement already satisfied: coverage in /opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages (from coverage-badge) (7.5.0)
Downloading coverage_badge-1.1.0-py2.py3-none-any.whl (6.4 kB)
Installing collected packages: coverage-badge
Successfully installed coverage-badge-1.1.0
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.19/x64/bin/coverage-badge", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage_badge/__main__.py", line 171, in main
    total = get_total()
  File "/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/coverage_badge/__main__.py", line 76, in get_total
    return coverage.results.Numbers(precision=cov.config.precision).display_covered(total)
AttributeError: 'Numbers' object has no attribute 'display_covered'
Error: Process completed with exit code 1.

This is the link to one of my workflow runs that failed because of this: https://github.com/Helmholtz-AI-Energy/propulate/actions/runs/8815977738/job/24199070502?pr=116 Yesterday in the evening, I did not have any problems and the workflow ran through without any errors.