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

Re-add support for Coverage reports through codecov.io #3618

Merged
merged 3 commits into from
Mar 3, 2020

Conversation

dev-zero
Copy link
Contributor

@dev-zero dev-zero commented Dec 9, 2019

No description provided.

@dev-zero dev-zero force-pushed the feature/codecov-integration branch 5 times, most recently from 3c2364a to 550072f Compare December 9, 2019 16:43
Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @dev-zero!

I have made a suggested change via a PR to your branch to only run the actions on push to the master and develop branches, as well as always for PRs.

.github/workflows/tests.sh Outdated Show resolved Hide resolved
@CasperWA
Copy link
Contributor

CasperWA commented Dec 9, 2019

Info: I added the secret CODECOV_TOKEN.

CasperWA
CasperWA previously approved these changes Dec 9, 2019
Copy link
Contributor

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Good for me, and mergeable when tests succeed.

@CasperWA CasperWA requested review from ltalirz and sphuber December 9, 2019 17:50
@giovannipizzi giovannipizzi dismissed CasperWA’s stale review December 9, 2019 18:03

We're discussing whether this is the right moment to merge this (also this would only show a 9% coverage from the pytests only

@dev-zero dev-zero force-pushed the feature/codecov-integration branch from cbb076b to dd870fc Compare December 10, 2019 08:34
@CasperWA
Copy link
Contributor

@dev-zero will you create an issue in codecov/codecov-action for the failure or maybe reopen codecov/codecov-action#22 ?

.github/workflows/tests.sh Outdated Show resolved Hide resolved
@CasperWA
Copy link
Contributor

It seems we need to update to codecov-action v1.0.5 according to this issue.

@dev-zero dev-zero force-pushed the feature/codecov-integration branch from 38c8ec5 to b4ac7e5 Compare December 12, 2019 09:44
@dev-zero
Copy link
Contributor Author

@CasperWA https://community.codecov.io/t/whitelist-github-action-servers-to-upload-without-a-token/491/5 ... Travis doesn't need a token because Codecov/Coveralls can verify the request via an API, but for GHA there's no API yet

@dev-zero dev-zero force-pushed the feature/codecov-integration branch from b4ac7e5 to 6ff1d69 Compare December 13, 2019 14:39
@dev-zero
Copy link
Contributor Author

dev-zero commented Dec 13, 2019

Short summary: Coverage through codecov or coveralls is not possible until GitHub releases an API to query GitHub Actions such that codecov/coveralls can verify the uploader. Supposed to happen in Q1 2020. The secret token is for obvious reasons not available in a PR, only in builds initiated by direct commits on the repo (currently restricted to develop and master).

We have two options for now: disable coverage upload for pull requests or not fail the CI when uploading to coverage report fails.

@ltalirz
Copy link
Member

ltalirz commented Dec 14, 2019

We have two options for now: disable coverage upload for pull requests or not fail the CI when uploading to coverage report fails.

I think it doesn't really matter.
If you go for the second option, then things might start to "magically" work at some point, so perhaps that's an argument for the second option, if there is an easy way to implement it.

@CasperWA CasperWA force-pushed the feature/codecov-integration branch 2 times, most recently from edf6b5b to 2aed43e Compare February 6, 2020 10:56
@codecov-io
Copy link

codecov-io commented Feb 6, 2020

Codecov Report

Merging #3618 into develop will decrease coverage by 1.67%.
The diff coverage is 73.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #3618      +/-   ##
==========================================
- Coverage    70.87%   69.2%   -1.68%     
==========================================
  Files          458     458              
  Lines        33545   33766     +221     
==========================================
- Hits         23775   23367     -408     
- Misses        9770   10399     +629
Flag Coverage Δ
#django 69.2% <73.76%> (+3.79%) ⬆️
#sqlalchemy ?
Impacted Files Coverage Δ
aiida/orm/nodes/process/workflow/workchain.py 91.66% <ø> (-0.65%) ⬇️
aiida/common/datastructures.py 96.55% <ø> (ø) ⬆️
aiida/backends/djsite/manager.py 79.31% <ø> (ø) ⬆️
aiida/backends/sqlalchemy/manager.py 0% <ø> (-76%) ⬇️
aiida/backends/djsite/db/models.py 77.19% <ø> (ø) ⬆️
aiida/engine/processes/workchains/context.py 50% <ø> (ø) ⬆️
aiida/orm/nodes/process/process.py 85.2% <ø> (-0.09%) ⬇️
aiida/cmdline/utils/multi_line_input.py 80.48% <0%> (ø) ⬆️
aiida/manage/configuration/setup.py 71.42% <100%> (ø) ⬆️
aiida/backends/djsite/db/migrations/__init__.py 68.83% <100%> (+68.83%) ⬆️
... and 138 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb8fc99...54049f7. Read the comment docs.

@CasperWA
Copy link
Contributor

CasperWA commented Feb 6, 2020

Testing this in the branch feature/codecov-integration-PR-3618, this is the uploaded coverage report.

As seen in the codecov bot comment here, the total coverage is 70.87 % - it doesn't seem to catch a lot of the database migration files/tests.

Furthermore, anything that isn't in the realm of pytest, i.e. .ci/test_daemon.py, as well as .ci/test_plugin_testcase.py, will not be covered (I believe).

@ltalirz
Copy link
Member

ltalirz commented Feb 6, 2020

Yeah, 0% coverage for both the the django migrations and the sqlalchemy migrations. I wonder why...

Furthermore, anything that isn't in the realm of pytest, i.e. .ci/test_daemon.py, as well as .ci/test_plugin_testcase.py, will not be covered (I believe).

Right, there one should be able to run it with something like coverage run ...

@ltalirz
Copy link
Member

ltalirz commented Feb 25, 2020

It would be great if we could move forward with this.
Does anyone have an idea why coverage would suddenly stop noticing migration-related tests?

@giovannipizzi
Copy link
Member

I think it's just because we are asking coverage to omit the whole folder (together with some more) in the .coveragerc:

omit = aiida/test*.py,aiida/*/test*.py,aiida/*/*/test*.py,aiida/*/*/*/test*.py,aiida/*/*/*/*/test*.py,aiida/*/*/*/*/*/test*.py,aiida/*/migrations/*.py,aiida/*/migrations/versions/*.py

I'm not sure anymore why this was introduced in the first place (in any case, it was introduced when migrations were untested).

Maybe we don't need to omit anything? You might want to just push a commit removing the omit line and check how things change.

@ltalirz
Copy link
Member

ltalirz commented Mar 3, 2020

Great, thanks a lot - will look into this now

@ltalirz ltalirz force-pushed the feature/codecov-integration branch from 54049f7 to 8e03e15 Compare March 3, 2020 13:14
@ltalirz
Copy link
Member

ltalirz commented Mar 3, 2020

Removing the omissions specified in .coveragerc brings back coverage on migrations.
Test coverage now reported at 77%.

To me, this PR is good to merge - does anybody still want to give another look?
One question to me is whether we really need the coverage output in the travis logs (it's about 500 lines)...
Anyhow, perhaps it's useful to keep at least until codecov starts working on PRs.
Another point is that we could try and remove the .coveragerc file entirely.

Finally, Casper is right that there are still two tests that don't report coverage:
.ci/test_daemon.py, as well as .ci/test_plugin_testcase.py

I'll have a look into moving the daemon test to pytest (in a separate PR) - that should not be a big deal.
The plugin testcase is explicitly testing a unittest test runner, and so there is not much point in moving it - we could still run it via coverage run ... but then we need to make sure to enable the same options. Doable as well, but not very important.

@ltalirz ltalirz self-requested a review March 3, 2020 13:23
ltalirz
ltalirz previously approved these changes Mar 3, 2020
@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

Removing the omissions specified in .coveragerc brings back coverage on migrations.
Test coverage now reported at 77%.

Good catch on this @giovannipizzi and @ltalirz !

Finally, Casper is right that there are still two tests that don't report coverage:
.ci/test_daemon.py, as well as .ci/test_plugin_testcase.py

I'll have a look into moving the daemon test to pytest (in a separate PR) - that should not be a big deal.
The plugin testcase is explicitly testing a unittest test runner, and so there is not much point in moving it - we could still run it via coverage run ... but then we need to make sure to enable the same options. Doable as well, but not very important.

If it's easily done, it wouldn't hurt? But if it doesn't change the coverage, there is no reason to do this.

@sphuber
Copy link
Contributor

sphuber commented Mar 3, 2020

If it's easily done, it wouldn't hurt? But if it doesn't change the coverage, there is no reason to do this.

It should increase the coverage because for example the BaseRestartWorkChain class is only tested in test_daemon.py. This goes for quite some other classes like ArithmeticAddCalculation and TemplatereplacerCalculation although they are less critical since they mostly exist for testing and demonstration purposes.

@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

If it's easily done, it wouldn't hurt? But if it doesn't change the coverage, there is no reason to do this.

It should increase the coverage because for example the BaseRestartWorkChain class is only tested in test_daemon.py. This goes for quite some other classes like ArithmeticAddCalculation and TemplatereplacerCalculation although they are less critical since they mostly exist for testing and demonstration purposes.

All right - I'll look into doing this - unless anyone else is already on top of it? (@ltalirz, @dev-zero ...)

@ltalirz
Copy link
Member

ltalirz commented Mar 3, 2020

@sphuber Not sure whether what I wrote was clear - I meant I will move the test_daemon to pytest (since this one matters), while the test_plugin_testcase can also be run via coverage (but is not very important).

@CasperWA If you prefer to do it instead, go ahead!
I'd still suggest to do it in a separate PR.

@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

@CasperWA If you prefer to do it instead, go ahead!
I'd still suggest to do it in a separate PR.

Ah right! Yeah, sure, okay. I've already started some work on it now, so I'll continue, but can surely make a new PR for it. I'll just squash our contributions into 3 separate commits and then you're free to re-approve and merge.

@CasperWA CasperWA force-pushed the feature/codecov-integration branch from 8e03e15 to 42d0cd5 Compare March 3, 2020 14:11
@CasperWA CasperWA requested a review from ltalirz March 3, 2020 14:34
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks @CasperWA !

@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

To note: Since codecov still does not support token-less uploads of coverage reports via GitHub Actions CI, the coverage will only be updated for a PR when it is merged (unless it's coming from an aiidateam branch already).

@ltalirz
Copy link
Member

ltalirz commented Mar 3, 2020

Yes, that's ok. I let you merge - not sure whether you preferred not to squash here...

@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

Yes, that's ok. I let you merge - not sure whether you preferred not to squash here...

I already squashed (what I intended to squash), but for multiple contributions we usually keep a commit per contributor, right? (Calling @sphuber).

@sphuber
Copy link
Contributor

sphuber commented Mar 3, 2020

Yes, that's ok. I let you merge - not sure whether you preferred not to squash here...

I already squashed, but for multiple contributions we usually keep a commit per contributor, right? (Calling @sphuber).

If the contributions are significant, yes, I typically keep them. Sometimes, if an additional commit is really small though, one can opt to use Co-Authored-By: John Doe <email@address> for the contributors at the end of the commit message of the squashed commit.

Edit: to clarify, if you deem these commits worthwhile as being separate, by all means keep them and just rebase-merge 👍 fire away

@CasperWA CasperWA merged commit 8156bb1 into aiidateam:develop Mar 3, 2020
@CasperWA
Copy link
Contributor

CasperWA commented Mar 3, 2020

I went through them, and they all add the right amount of sugar - so they all stay 😃

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

Successfully merging this pull request may close these issues.

6 participants