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

[10121] Fix random PyPy CI failures. Improve GHA CI speed. Improve coverage reporting. #1543

Merged
merged 14 commits into from
Apr 5, 2021

Conversation

adiroiban
Copy link
Member

@adiroiban adiroiban commented Mar 9, 2021

Scope and purpose

We got random failures on pypy (both 3.6 and 3.7 versions)

Also pypy jobs with coverage are very slow...30minutes.

See what can be done to speed up the CI.

Changes

PYPY coverage

Coverage was disabled for most of the PyPy..
The tests are much faster now without coverage 4m vs 30m
We still run coverage on PYPY, but only for compat and a few other test that are exercising the PYPY specific code.

In this way we can monitor if we continue to see random CI failures at the end of the test run on PY.

These are the tests required to get the extra coverage on pypy

  • twisted.test.test_compat
  • twisted.test.test_defer
  • twisted.internet.test.test_socket
  • twisted.trial.test.test_tests

Linux / MacOS general CI speedup

All tests are now executed in parallel, including pypy.

To gain more speed, I have removed tox --notests as it was just wasting time.
We can later show the dependencies using the python-info action.

PR are waiting to be reviewed to also get parallel jobs on Windows.

Coverage reporting

I have updated coverage XML generation and codecov.io reporting to make the check red on failures.
Only coveralls failures are ignored for now.
In this way it should be easier to observer coverage issues.

I tried to fix the coveralls report for trunk merges.
I did some work in #1574 but there is no way to test this unless merged in trunk.

Contributor Checklist:

@adiroiban adiroiban force-pushed the 10121-pypy-no-coverage branch 3 times, most recently from 9ffbc37 to 03e42c1 Compare March 9, 2021 15:40
@wsanchez
Copy link
Member

codecov/project shows a slight drop. I'm getting a 403 error when I try to view it on Codecov, but it would be good to know where the dropped lines are.

@adiroiban adiroiban force-pushed the 10121-pypy-no-coverage branch 2 times, most recently from bc18121 to e542130 Compare March 18, 2021 23:20
@adiroiban adiroiban changed the title [10121] Disable coverage reporting for PyPy. [10121] Fix random PyPy CI failures. Mar 24, 2021
@adiroiban adiroiban force-pushed the 10121-pypy-no-coverage branch 4 times, most recently from bbec8bc to 9300a7d Compare March 24, 2021 18:47
@adiroiban adiroiban changed the title [10121] Fix random PyPy CI failures. [10121] Fix random PyPy CI failures and improve GHA CI speed. Mar 31, 2021
@@ -12,4 +19,12 @@ coverage:
default:
target: 100%

comment: off
# We don't want to receive general PR comments about coverage.
Copy link
Member Author

Choose a reason for hiding this comment

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

These are already the defaults, but I have added them here to make it explicit and help undestand how the whole codecov.io process works

require_ci_to_pass: yes
notify:
after_n_builds: 7
wait_for_ci: yes
Copy link
Member Author

Choose a reason for hiding this comment

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

Here I am trying to see if I can configure codecov.io to wait a bit more before sending the coverage reports so that we don't have transient red checks

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the existing behavior is bad, necessarily, it's just confusing for people who (like me) assume that a check is complete once it shows either a check or X.

Copy link
Member

Choose a reason for hiding this comment

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

In my experience these two options don't actually work. I never got to the bottom of why and codecov.io declined to assist.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will try to find some time and report this issue via the internal / paid support codecov channel.

It is true that codecov are not helping too much with open source projects... so we are on a free ride here.

But I see if I can reproduce it for my private project and try to get help via that project.

@adiroiban adiroiban changed the title [10121] Fix random PyPy CI failures and improve GHA CI speed. [10121] Fix random PyPy CI failures. Improve GHA CI speed. Improve coverage reporting. Mar 31, 2021
@adiroiban
Copy link
Member Author

I have no idea why codecov/project is red ... maybe it will need time to be updated -
i have checked the page https://app.codecov.io/gh/twisted/twisted/compare/1543/changes and the PR has no missing coverage (when compared to trunk)

This is ready for review. See PR description

@adiroiban adiroiban requested a review from a team March 31, 2021 11:09
run: |
# sub-process coverage are generated in separate files so we combine them
# to get an unified coverage for the local run.
# The XML is generate to be used with 3rd party tools like diff-cover.
python -m coverage combine
python -m coverage xml -o coverage.xml -i
python -m coverage report
python -m coverage report --skip-covered
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -36,6 +36,8 @@ jobs:
# As of 9 March 2021 GHA VM have 2 CPUs - Azure Standard_DS2_v2
# Trial distributed jobs enabled to speed up the CI jobs.
trial-args: ['-j 4']
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be removed as you removed the reference to it above?

@adiroiban adiroiban requested a review from twm April 1, 2021 09:10
@adiroiban
Copy link
Member Author

adiroiban commented Apr 1, 2021

@twm thanks for the review. I have updated the GHA config. Let me know if you see any issues with it.

I see the codecov.io check is still sent before all checks are done

The codecov.io docs say that cryptography project is a good example
https://docs.codecov.io/docs/merging-reports
https://github.com/pyca/cryptography/blob/main/codecov.yml


The codecov/project is now red ...but I guess that after some time codecov.io is preocessing the reports and will update it.

The codecov page looks green https://app.codecov.io/gh/twisted/twisted/compare/1543/changes

I happened with my previous comment. By the time I left the comment the check was red for a5326cc and now it's green

My plan is to rewrite the coverage reporting in a separate PR, so that we collect all GHA coverage in a separate job and combine ourselves and then send a single coverage.xml for the whole GHA builds... I will test in in a separate branch ... but might need moving one Windows and MacOS job to GitHub

@wiml
Copy link
Contributor

wiml commented Apr 1, 2021

The codecov/project is now red

It looks like the change is due to a now-untested branch in TestDecoratorMixin.test_decorateTestSuiteReferences(), near lines 1167–1169, which skips a test if sys.getrefcount is not available … I'd guess that PyPy is the only tested target that doesn't have getrefcount. Maybe add twisted.trial.test.test_tests (or all of twisted.trial) to the mypy suite?

@adiroiban
Copy link
Member Author

It looks like the change is due to a now-untested branch in TestDecoratorMixin.test_decorateTestSuiteReferences(),

Thanks. You are my hero :)

Updated pypy coverage only take 3 minutes..

7 minutes is the total run time for GitHub Actions tests.

We still have Azure tests which take 14m.

So with the changes from this PR GHA should be ok and we should look at Azure speedup next

Copy link
Contributor

@wiml wiml left a comment

Choose a reason for hiding this comment

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

LGTM, although I'm not terribly familiar with codecov.io+GHA interactions.

# Future test runs will not trigger the error and the error handling
# code branch is not called, and if no other tests is touching that
# branch we are left with overall reduced code coverage.
threshold: 0.02%
Copy link
Member

Choose a reason for hiding this comment

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

This setting may be required if coverage is a required check but the reasoning here is invalid. The threshold value allows an ongoing slip in coverage. Build N of trunk can have (0.02 × M) greater coverage than build (N+M) of trunk and this configuration tells codecov.io that this is fine.

So this setting should be considered a temporary fix while the real problem is being addressed - non-deterministic coverage in the test suite.

Copy link
Member

Choose a reason for hiding this comment

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

There are various cases where coverage can be reduced. Even just deleting lines that have been covered causes this. It's just a result of not having '100%' coverage (after including consideration of coverage ignores). I don't know if there's a way to deal with that separately from the commented situation.

Copy link
Member

Choose a reason for hiding this comment

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

What are the odds, that is the case in my next review. twisted/towncrier#334 They deleted a line that is useless and the coverage dropped by 0.01%.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks wiml for the review. Just monitoring future PR and checking for overall project coverage regression can help with future fixed for this issue.

Thanks exarkun for the headup. I forgot to file the followup ticket.

Thanks altendky for the code delete info. I was hoping that codeco.io is smart and will not trigger such an error.
I have reported this issue
https://community.codecov.io/t/project-coverage-decrease-on-deleted-line/2726


I agree that this should be a temporary change.
I have added to link to the ticket in the comment.

If coverage/project will continue to be red, people will most probably ignore it by default.
With that, I think that is a higher probability of seeing an overall decrease in coverage.

We had the project red for some time, and I am not aware of any secondary tickets or actions to fix the overall project coverage.


Regarding 0.02 x M.
We have 100% patch coverage , so is not that easy to find a series of PR with 100% patch coverage but witch will always decreased the overall project by 0.02 due to different tests.

I am monitoring overall coverage changes as there is a gang of usual suspect tests.

For example

image

With this swinging line

image

There is also this swinging test helpers to prevent a flaky test failure

image

Copy link
Member

@altendky altendky left a comment

Choose a reason for hiding this comment

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

To gain more speed, I have removed tox --notests as it was just wasting time.

I guess that should be brought back in #1577 after this PR is merged?

# Future test runs will not trigger the error and the error handling
# code branch is not called, and if no other tests is touching that
# branch we are left with overall reduced code coverage.
threshold: 0.02%
Copy link
Member

Choose a reason for hiding this comment

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

There are various cases where coverage can be reduced. Even just deleting lines that have been covered causes this. It's just a result of not having '100%' coverage (after including consideration of coverage ignores). I don't know if there's a way to deal with that separately from the commented situation.

@adiroiban adiroiban merged commit b3cf4b5 into trunk Apr 5, 2021
@adiroiban adiroiban deleted the 10121-pypy-no-coverage branch April 5, 2021 20:23
@adiroiban
Copy link
Member Author

I guess that should be brought back in #1577 after this PR is merged?

@altendky yep... looking forward for that PR. It would be nice to see a separate timing for deps install vs actual test run. Thanks

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.

None yet

6 participants