-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Infra: add tests #2545
Infra: add tests #2545
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Hugo! Minor comments.
A
.github/workflows/test.yml
Outdated
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10"] | ||
os: [macos-latest, ubuntu-latest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test on multiple OSes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably just do Ubuntu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to either only test on one platform, or test on Ubuntu, macOS and Windows. I'd prefer the latter, since these checks only run when we make build system changes and we may as well make sure things aren't broken on a specific platform (though it seems relatively unlikely).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's add Windows.
Will this also enable the fairly large comments by codecov on all PRs? (& if it will, please can we make sure it doesn't!) A |
Based on recent failed attempts to re-enable the comments on PRs in https://github.com/python/bedevere (e.g. python/bedevere#432), I think not! Comments are disabled globally for https://github.com/python (see https://app.codecov.io/account/gh/python/yaml). If they start showing up here, we can easily explicitly disable with a config file in this repo. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, @hugovk ! This obviously was a lot of work, but good to have. Most of my comments were fairly minor and as suggestions, though I did have a few requests. Thanks!
.github/workflows/test.yml
Outdated
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10"] | ||
os: [macos-latest, ubuntu-latest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to either only test on one platform, or test on Ubuntu, macOS and Windows. I'd prefer the latter, since these checks only run when we make build system changes and we may as well make sure things aren't broken on a specific platform (though it seems relatively unlikely).
tox.ini
Outdated
commands = | ||
make test | ||
allowlist_externals = make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why relay on make
, another automation tool (and one that will not work cross-platform, so the tests cannot be run locally through tox on Windows), instead of just calling pytest
directly? It will still automatically pick up the same args so long as they are properly configured in the pytest.ini
as they should be, rather than stuck in a Makefile. This just all seems rather odd, at least to me...
Also, this means that like we already are in the build job, the dependencies are installed twice—once in the outer env, which are not used, and once in the inner env via make venv
, which are (AFAIK).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to handle installing requirements, avoid repeating the pytest command, and make sure the make
command is tested. But good point about Windows! Will change it.
Requirements are only installed once in this workflow, currently via make test
-> make venv
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to handle installing requirements, avoid repeating the pytest command, and make sure the make command is tested. But good point about Windows! Will change it.
Gotcha. The other benefit to changing it is that it makes it easier to add additional arguments to control the output of the CI job, which should be -v --cov-report term
at least per the discussion above.
Ideally we'd fully replace make
with drop-in equivalent tox
tasks, but that's an issue for another day.
Requirements are only installed once in this workflow, currently via make test -> make venv.
Ah, that's only in the build job—I got mixed up, sorry.
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Added:
Removed:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor change and one tiny textual tweak, otherwise LGTM—thanks @hugovk !
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
Thanks Hugo! A |
As suggested earlier, let's test our infra code at
pep_sphinx_extensions/
.I mainly aimed at testing standalone functions, and skipped the harder to test things involving Sphinx. I think this is fine, it's more important to test the more logic-based things than the whole rendering process by Sphinx and distutils. And we can extract bits of logic to make them easier to test. Still, 55% coverage isn't bad.
Bugs
I found some bugs :)
pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
had an f-string missing thef
prefixpep_sphinx_extensions/pep_zero_generator/author.py
had anAttributeError: can't set attribute
onname_parts.surname = f"\\{name_parts.surname}"
Same file, I couldn't reach
raise ValueError("Name is empty!")
because that happens whenname_parts == [""]
(with length 1) notnum_parts == 0
Maybe bugs
And some bits I didn't figure out how to hit, could be a bug, redundant code, or neither:
pep_sphinx_extensions/pep_zero_generator/writer.py
:pep_sphinx_extensions/pep_zero_generator/parser.py
:To test locally
Coverage is visible at
htmlcov/index.html
CI
This runs on GitHub Actions, but only when there's changes in
pep_sphinx_extensions/**
,.github/workflows/test.yml
, ortox.ini
, and sends coverage to Codecov (for example).No need to run for normal PEP PRs.