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

create coverage actions #3483

Merged
merged 15 commits into from
Jun 21, 2024
Merged

create coverage actions #3483

merged 15 commits into from
Jun 21, 2024

Conversation

felixschurk
Copy link
Collaborator

@felixschurk felixschurk commented Jun 14, 2024

Closes #3413.

With this PR a coverage comment is automatically created and updated over the corresponding actions file and attached to the PR.

It is also possible to link the generated coverage report to some online viewer such as Coveralls, SonarCloud to get even more insight e.g. evolution over coverage, deeper insights which lines are covered etc.
I do think this makes sense in general, but only if we would then also look at the metrics. Otherwise, it is more dead code/dead connection and a simple comment is probably more helpful.

@felixschurk felixschurk self-assigned this Jun 14, 2024
@felixschurk
Copy link
Collaborator Author

It is also possible to link/trigger this workflow only after the successful run of e.g. the tests workflow.

Generally speaken, we could link / depend workflows that they might have a more particular order e.g. checks -> tests -> Coverage Report -> release-tests. Mainly an idea to have it a bit more structured.
I have not yet looked to deep into the workflows directly if that would make sense.

@felixschurk
Copy link
Collaborator Author

I have no clue, why all other tests are failing. As this PR has no changes in the source files nor build system.

@felixschurk felixschurk marked this pull request as ready for review June 14, 2024 09:55
@felixschurk felixschurk added the topic:devel Development-related issues (build, CI, testing, etc.) label Jun 14, 2024
@djmitche
Copy link
Collaborator

I pushed #3484 to see if the tests fail there, too.

@djmitche
Copy link
Collaborator

They did, so those failures are unrelated. I'll see if I can sort them out today.

Copy link
Collaborator

@ryneeverett ryneeverett left a comment

Choose a reason for hiding this comment

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

  • I like your suggestion of making this workflow run only after all others have passed.
  • It seems like this report is only going to show the current coverage but I think what we're really interested in seeing in the PR is the change in coverage. This is where I suspect using a third-party tool like Coveralls comes in handy because such a tool would store the historical data for this purpose. IMO, ideal would be to only make a comment if there is a significant decrease in coverage, but even just showing the change would be an improvement.

.github/workflows/coverage.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

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

I tend to agree, that this isn't especially helpful without a baseline. I think coveralls can do that, though -- and even post a comment only if some conditions apply? It would be nice to get alerts if PRs dramatically reduce the coverage rate or introduce a lot of new un-covered code!

.github/workflows/coverage.yml Outdated Show resolved Hide resolved
@felixschurk
Copy link
Collaborator Author

  • I like your suggestion of making this workflow run only after all others have passed.

    • It seems like this report is only going to show the current coverage but I think what we're really interested in seeing in the PR is the change in coverage. This is where I suspect using a third-party tool like Coveralls comes in handy because such a tool would store the historical data for this purpose. IMO, ideal would be to only make a comment if there is a significant decrease in coverage, but even just showing the change would be an improvement.

Yes, thats actually what the Coveralls Action would do.

I tend to agree, that this isn't especially helpful without a baseline. I think coveralls can do that, though -- and even post a comment only if some conditions apply? It would be nice to get alerts if PRs dramatically reduce the coverage rate or introduce a lot of new un-covered code!

So I would say we set it up with coveralls, as their action does both of the mentioned suggestions automatically.
The GitHub Coveralls Action, I can setup.

I already requested from the GothenBurgBitFactory Organization Access for adding the Repository to Coveralls, I just don't know who will get the notification for that one.

Copy link

Code Coverage

Package Line Rate Branch Rate Health
src 89% 53%
src.columns 88% 53%
src.commands 88% 47%
src.libshared.src 64% 43%
src.tc 70% 28%
test 96% 47%
Summary 84% (19366 / 22961) 49% (30269 / 62098)

@felixschurk
Copy link
Collaborator Author

Okay, I checked it a bit out with the running one action after another and it did not directly work as expected.

However, when we want to use the coveralls action (which would make sense) then it does need to run on pull requests to post the comment etc. thus linking it over the workflow_run I assume is not working.

However, what we could still do is to use then this action (the coverage one) to test is only on Ubuntu 22.04, and if this one is working, then test it on all other distros. Meaning in a bad case we would save the 8x4 minutes. But thats up for discussion, as we also currently do not hit any CI limits to my knowledge its not really required.

@djmitche
Copy link
Collaborator

I think that sounds fine. Most failures fail on every builder, so all but the first are a waste anyway.

@tbabej
Copy link
Sponsor Member

tbabej commented Jun 17, 2024

I already requested from the GothenBurgBitFactory Organization Access for adding the Repository to Coveralls, I just don't know who will get the notification for that one.

This should be approved now.

@felixschurk
Copy link
Collaborator Author

Integration with Coveralls is now setup and can be seen here. I assume we would need to also set up the comment function by inviting the coveralls bot see here the documentation.

On another note, I think it's quite interesting to see that over the last commits different tests fail, e.g. over a time-out from task. I tried to reproduce that locally somehow, however I am not able to do.
I am now wondering if that has to do as they now run "natively" under the GH Actions runner and not in a separate Container in the GH Actions runner.

@djmitche
Copy link
Collaborator

An example failure is task config failing with SIGABRT, which doesn't seem like it could time out -- it doesn't do anything lengthy.

As it seams that there is some inconsistency inbetween the runs, which
are non related to the proper test. Maybe a second invokation of ctest
on the failed runs helps to clean that up.
The exit code of the first one is "ignored".
As aparently the chaining of the workflows is not working, adding the
coverage as a condition into the normal tests workflow.
@felixschurk
Copy link
Collaborator Author

Alright, seams if I found a way to properly chain them.
I am a bit unsure why in previous commits the tests where "randomly" failing, but over the last two commits it was now stable - so I hope this will stay so.

With the current setup the tests first runs the coverage check, if this one is successful it will build on all the machines.

Further, the small badge is added to the README.
Coverage Status

@felixschurk felixschurk enabled auto-merge (squash) June 21, 2024 12:30
@felixschurk felixschurk merged commit c44229d into develop Jun 21, 2024
28 checks passed
@djmitche
Copy link
Collaborator

Nice work - thanks!

felixschurk added a commit that referenced this pull request Jun 21, 2024
@felixschurk
Copy link
Collaborator Author

Okay this was not intended to merge it without the review!
I thought I can set it to automatically squash and merge after the reviews, however seams to be not the case.

Sorry for that!

@felixschurk felixschurk deleted the add-coverage-actions branch June 21, 2024 12:34
@felixschurk
Copy link
Collaborator Author

Currently, the settings for Coveralls are set to:

80% Overall Coverage (currently 84%)
5% Coverage Decrease with New Code allowed

I have not yet set it up that Coveralls leaves a PR Comment about the change in coverage, however if wanted this could also be setup see the documentation.

@djmitche
Copy link
Collaborator

Hm, I'm seeing the SIGABRT in https://github.com/GothenburgBitFactory/taskwarrior/actions/runs/9613757645/job/26517145647?pr=3494

In wonder if that's due to the -j8 in the ctest invocation? I was about to make a PR to add -j8 for the build, so I can try that.

@felixschurk
Copy link
Collaborator Author

felixschurk commented Jun 21, 2024

You mean for the coverage invocation build?

There it should not be needed to add a -j 8 flag, as it uses Ninja which should do it automatically (using all available cores).

Now reading over the documentation from the runners I see they only have four cores - so maybe we should only add a -j 4 flag. :D

Ah and also the documentation of ctest would allow us to run it in maximum parallel when we just pass --parallel to it (either limited by number of processors or two, whatever is larger).

@djmitche
Copy link
Collaborator

I think I had already marked this as "Approved" - that's probably why it merged? Anyway, it's fine :)

@djmitche
Copy link
Collaborator

I didn't realize Ninja was parallelizing already. But, removing the parallelism from ctest did help the tests not fail. I'm not sure the tests are designed to run in parallel -- they might be using some shared resource?

@felixschurk
Copy link
Collaborator Author

Hm, I assumed as even the old test script before #3446 allowed at least for a flag to run the test suite in parallel that this should not be a problem.

What I think is confusing and does not really add up is that in all the distro tests, we do run the tests in parallel (j8) and there was never a spurious failure. So I am assuming that maybe here the GH Runner is playing some role and maybe there it's having some influence. But also no clue why a container, in a container should change there a lot.

@djmitche
Copy link
Collaborator

djmitche commented Jun 21, 2024

Could it be different versions of ctest?

I hate autocorrect

@djmitche
Copy link
Collaborator

One thought, is that it's possible the measurement of the number of processors is different in a container. I have forgotten most of what I ever knew about Docker. But perhaps the tasks weren't really running in parallel in the container?

@djmitche
Copy link
Collaborator

Huh, well, not running tests in parallel didn't help -- that PR failed anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:devel Development-related issues (build, CI, testing, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coverage data in GH Actions
4 participants