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

Generate coverage results and upload to codecov #33355

Closed
tobiasdiez opened this issue Feb 15, 2022 · 47 comments
Closed

Generate coverage results and upload to codecov #33355

tobiasdiez opened this issue Feb 15, 2022 · 47 comments

Comments

@tobiasdiez
Copy link
Contributor

Use coverage.py to generate coverage results for the sage source code based on the test execution. In contrast to sage's naïve coverage tool, this not only looks for the existence of doctests for a method but actually measures which lines are actually executed by the tests.

These coverage results are then uploaded to codecov, where one can inspect the results. See https://codecov.io/gh/sagemath/sagetrac-mirror/tree/ec045eb0168b937e35375e803979975df4aa6564/src/sage for the current coverage. Codecov also displays the coverage of changed files, so that one can easily check if changes are indeed covered by tests. An example would be https://codecov.io/gh/sagemath/sagetrac-mirror/commit/ec045eb0168b937e35375e803979975df4aa6564 but there are of course no changes in python files in this ticket, so it shows nothing interesting. For a more interesting example from a different project see eg https://app.codecov.io/gh/JabRef/jabref/commit/2494509f2d75426bd7369b358880e7ffed2a47b4. The idea would be to add the link to such a report as a new badge in the trac ticket (after this ticket here is merged).

Run: https://github.com/sagemath/sagetrac-mirror/actions/workflows/build.yml?query=branch%3Apublic/build/codecov

CC: @mkoeppe

Component: build

Author: Tobias Diez

Branch: ec045eb

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/33355

@tobiasdiez tobiasdiez added this to the sage-9.6 milestone Feb 15, 2022
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 15, 2022

Changed commit from 3c315dd to 7ff3baa

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 15, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

7ff3baaTry with editable install

@tobiasdiez

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

4c7c162Try sourcing sage-env

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Changed commit from 7ff3baa to 4c7c162

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

6a93454No source cmd?!

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Changed commit from 4c7c162 to 6a93454

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

97970d1Try sage-env-config

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Changed commit from 6a93454 to 97970d1

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 17, 2022

comment:6

Use sage -sh -c "...." to run a shell command .... in the Sage environment.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 17, 2022

comment:7

Or use sage -python -m coverage ...

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

af9b442Try with sage -python

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Changed commit from 97970d1 to af9b442

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Changed commit from af9b442 to 1c53f6f

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 17, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

1c53f6fIgnore coverage warnings

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 18, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

3bf2fdcInstall git

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 18, 2022

Changed commit from 1c53f6f to 3bf2fdc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 18, 2022

Changed commit from 3bf2fdc to e4bca51

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 18, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

e4bca51Try without sudo

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from e4bca51 to 5523e44

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

5523e44Have to manually combine coverage results

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

8b25060Force 2 threads

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from 5523e44 to 8b25060

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

cc8e027Fix indent

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from 8b25060 to cc8e027

@tobiasdiez
Copy link
Contributor Author

comment:15

Replying to @mkoeppe:

Or use sage -python -m coverage ...

Thanks that worked well! (Why is this command actually necessary? I thought its the job of sage-conf to handle all environment variables)

I just noticed that elementary things like git and sudo are missing in the standard docker image. Would it make sense to add these tools?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Branch pushed to git repo; I updated commit sha1. New commits:

ec045ebTry to find coverage file

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Feb 19, 2022

Changed commit from cc8e027 to ec045eb

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 19, 2022

comment:17

Replying to @tobiasdiez:

Replying to @mkoeppe:

Or use sage -python -m coverage ...

Thanks that worked well! (Why is this command actually necessary? I thought its the job of sage-conf to handle all environment variables)

This is a goal that has not been achieved yet. What sage-env does is still needed for some things in the Sage library. See for example #31296.

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 19, 2022

comment:18

Replying to @tobiasdiez:

Replying to @mkoeppe:

Or use sage -python -m coverage ...

Thanks that worked well! (Why is this command actually necessary? I thought its the job of sage-conf to handle all environment variables)

I just noticed that elementary things like git and sudo are missing in the standard docker image. Would it make sense to add these tools?

I added git to -recommended, see #33296, #33277, but we're not building the image yet. We could replace -standard but -recommended. Probably best after #33062.

You don't need sudo, you are running as root.

@tobiasdiez
Copy link
Contributor Author

comment:19

Replying to @mkoeppe:

You don't need sudo, you are running as root.

It's more for convenience and coherence - normally github actions don't run as sudo.

@tobiasdiez

This comment has been minimized.

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 2, 2022

comment:21

I am getting
"There was a problem getting the source code from your provider. Unable to show line by line coverage. "

https://app.codecov.io/gh/sagemath/sagetrac-mirror/blob/ec045eb0168b937e35375e803979975df4aa6564/src/sage/categories/chain_complexes.py

@tobiasdiez
Copy link
Contributor Author

comment:22

The link is working for me. Maybe a temporary issues on their side?

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 2, 2022

comment:23

Working now for me too

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 2, 2022

comment:24

Looking great, thanks for this work!

@mkoeppe
Copy link
Contributor

mkoeppe commented Mar 2, 2022

Reviewer: Matthias Koeppe

@tobiasdiez
Copy link
Contributor Author

comment:25

Thanks for the review!

@vbraun
Copy link
Member

vbraun commented Mar 8, 2022

Changed branch from public/build/codecov to ec045eb

@fchapoton
Copy link
Contributor

comment:27

currently not working in the "Build and Test" badge, shouting :

Run ./venv/bin/python3 -m coverage combine src/.coverage/
  ./venv/bin/python3 -m coverage combine src/.coverage/
  ./venv/bin/python3 -m coverage xml
  find . -name *coverage*
  shell: sh -e {0}
Couldn't combine from non-existent path 'src/.coverage/'
Error: Process completed with exit code 1.

@fchapoton
Copy link
Contributor

Changed commit from ec045eb to none

@tobiasdiez
Copy link
Contributor Author

comment:28

Which ticket shows this behavior? It is still working correctly in the latest beta: https://github.com/sagemath/sagetrac-mirror/runs/5710760370?check_suite_focus=true

@fchapoton
Copy link
Contributor

comment:29

see #33629 for example

@tobiasdiez
Copy link
Contributor Author

comment:30

Okay, was actually an issue with pyright. Fixed in #33631.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 5, 2022

comment:31

Can we get the badge now?

@fchapoton
Copy link
Contributor

comment:32

the badge "Build & Test" is still broken by problems about coverage

for example, see

https://github.com/sagemath/sagetrac-mirror/runs/6117339523?check_suite_focus=true

shouting

Run ./venv/bin/python3 -m coverage combine src/.coverage/
6
/__w/sagetrac-mirror/sagetrac-mirror/venv/bin/python3: No module named coverage
7
Error: Process completed with exit code 1.

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 22, 2022

comment:33

I've opened #33747 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants