-
Notifications
You must be signed in to change notification settings - Fork 101
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
Modernizing gitlint's build and test tooling: discussion #378
Comments
I like having a separate job for building the artifacts (sdist and wheel) but I haven't gotten reusable bits for this :( Still managing such setups manually. Note that publishing from the default branch will require version numbers that are unique for each commit push. This means that instead of hardcoding the version, you'd need a mechanism for generating them from Git. I normally use the setuptools-scm plugin for this but there's others.
It is common to use
You'll need to keep two package definitions and just invoke
Today, probably all the available tools are compatible with this, including
-1 on this — such requirements don't belong in the distribution package metadata that is consumable by the end-users. Can you imagine your typical non-contributor user running
If you'll go GHA-way, you'll probably end up using my action https://github.com/marketplace/actions/pypi-publish, not really needing this.
As I mentioned above, you can use setuptools-scm or dunamai (probably). Not sure how non-setuptools ecosytems do this, but there's probably plugins for this too.
I haven't seen Anthony's video, but I also have bad experience with Poetry, including the contribution attempts. I feel like the rest of the PyPA has a similar opinion.
Yes, that's correct.
Yes, I'm seeing a lot of projects migrating to Hatch recently. And it's now hosted under the PyPA umbrella. I haven't looked too deep into it, but since many people I respect like it, I'm inclined to blindly trust their judgement. I don't know the state of their SCM integration (which is important for the points above) but I saw the maintainer of
|
Nice to ask, but keep in mind that "single" is more of an ideal and that the more people you ask the more solutions you will get suggested. Still, much better than not asking. After a decade of building python packages, my personal take is:
And last bit: avoid trying to change/fix too many things at one, progress here is done with small increments, or you endup moving too much at once and likely fail under the burden. |
Hatch maintainer here! Let me know if I can help |
Regarding setuptools, a few benefits of switching to Hatchling:
|
Yesterday I managed to migrate the first (minor) project to pure |
Why |
I think that that this sections needs cleaning, especially as newer versions of setuptools-scm no longer need archive. I just did not had time to clean it. |
Have you tried hatch-vcs? Example: https://github.com/psf/black/blob/main/pyproject.toml |
The same question about |
Yeah it's automatic. That |
Thanks for all your inputs - definitely insightful. Really appreciated! I’m going to give hatch a shot, I’ve implemented the basic setup in #384. I really like hatch 🫶, the end result is very elegant IMO. I’ll leave the PR open for a few days to gather input before merging it. I haven’t implemented the CI deployment too Test PyPi on every commit yet, but I can see a few ways to do that (potentially using https://github.com/ofek/hatch-vcs) - I’ll do that next. |
Ok, I’ve finally come around to implementing hatch-vcs in #410, works well! I’ll merge that PR soon. One thing I ran into is that when trying to publish is that PyPI does not accept PEP440 local versions # This is not accepted, since it contains a local version (the + and everthing after)
0.19.0.dev52+ga8eb527
# This does work
0.19.0.dev52 In practice, I believe this means I’ll have to explicitly tag every commit I wish to publish to (test)pypi. This makes me reconsider the idea of publishing on every commit, since it would basically mean having to (auto)tag every commit on Why I wanted to do this in the first place:
Based on this, I’m now thinking to not auto-publish on every commit but to just create a pipeline that does tagging and publishing on demand. This could then still be put on a cron job that auto-publishes every so often (2 weeks?). Appreciate if anyone has additional thoughts on this! |
GHA workflow scheduled release, not cron running under someone's desk. It even has cron syntax! |
Yes! That's what I meant :) |
@jorisroovers Sorry, I had to ask,... you never know what people really do these days. |
in iniconfig i use https://github.com/pytest-dev/iniconfig/blob/main/.github/workflows/deploy.yml#L43 to ensure test-pypi uploads |
alternatively a version scheme that leaves out the local node on master/main could be added as well |
Yes, I was thinking about this but doubted a bit whether that was a clean solution and whether any breaking scenarios exist. Also would need to have a look at how to override the Might explore this now though, thanks for the suggestion 🙏 |
If the preexisting version schemes don't fit a new one can be added upstream or as plugin |
This was a great tip, thanks @RonnyPfannschmidt! I ended up using it to implement the publish-release workflow that now gets triggered automatically on every commit to main. After the gitlint and gitlint-core are published to test.pypi.org, we also automatically run integration tests (test-release workflow) on the newly published packages. Both the publish-release and test-release workflows can also be triggered manually. After working out a few issues (e.g. PYPI mirror replication delay), this has been running smoothly now for the last few commits. I think I’ll switch to publishing to the regular PyPI (i.e. pypi.org, not test.pypi.org) in the near future. This outcome is exactly what I wanted, very happy with the end result here! Thanks everyone for your input (and keep any suggestions coming)! 🫶 |
Ok, that’s in effect now 🙂 Topic switch: hatch environment dependencies and dependabot @ofek, something I’d like to have is dependabot support for dependencies in hatch environments, e.g. Lines 83 to 92 in 7b0c255
I’ve read dependabot/dependabot-core#3290, but AFAICT, that only pertains to top-level I also had a quick glance at hatch-requirements-txt with the idea of splitting the test dependencies back out in a Is this something you think will eventually be supported, or are there workarounds available? Thanks! |
This release was primarily focussed on modernizing gitlint's build and test tooling (details: #378). General Python 3.6 no longer supported (EOL since 2021-12-23) (#379) This is the last release to support the sh library (used under-the-hood to execute git commands) by setting GITLINT_USE_SH_LIB=1. This is already disabled by default since v0.18.0. Features Allow for a single commit in the --commits cmd-line param (#412) Gitlint now separates FILE_ENCODING (always UTF-8) from TERMINAL_ENCODING (terminal dependent), this should improve issues with unicode. Use gitlint --debug to inspect these values. (#424) Bugfixes ignore-by-author-name crashes without --staged (#445) Various documentation fixes (#401, #433) - Thanks scop Development Adopted hatch for project management (#384). This significantly improves the developer workflow, please read the updated CONTRIBUTING page. Adopted ruff for linting, replacing pylint (#404) Gitlint now publishes dev builds on every commit to main (#429) Gitlint now publishes a latest_dev docker image on every commit to main (#451) (#452) Dependencies updated Many improvements to the CI/CD worfklows Improve unit test coverage (#453) Integration test fixes on windows (#392, #397) Devcontainer improvements (#428) Removal of Dockerfile.dev (#390) Fix most integration tests on Windows Fix Windows unit tests (#383) Introduce a gate/check GHA job (#375) Full Release details in CHANGELOG.md.
This release was primarily focussed on modernizing gitlint's build and test tooling (details: #378). General Python 3.6 no longer supported (EOL since 2021-12-23) (#379) This is the last release to support the sh library (used under-the-hood to execute git commands) by setting GITLINT_USE_SH_LIB=1. This is already disabled by default since v0.18.0. Features Allow for a single commit in the --commits cmd-line param (#412) Gitlint now separates FILE_ENCODING (always UTF-8) from TERMINAL_ENCODING (terminal dependent), this should improve issues with unicode. Use gitlint --debug to inspect these values. (#424) Bugfixes ignore-by-author-name crashes without --staged (#445) Various documentation fixes (#401, #433) - Thanks scop Development Adopted hatch for project management (#384). This significantly improves the developer workflow, please read the updated CONTRIBUTING page. Adopted ruff for linting, replacing pylint (#404) Gitlint now publishes dev builds on every commit to main (#429) Gitlint now publishes a latest_dev docker image on every commit to main (#451) (#452) Dependencies updated Many improvements to the CI/CD worfklows Improve unit test coverage (#453) Integration test fixes on windows (#392, #397) Devcontainer improvements (#428) Removal of Dockerfile.dev (#390) Fix most integration tests on Windows Fix Windows unit tests (#383) Introduce a gate/check GHA job (#375) Full Release details in CHANGELOG.md.
Ok, I've created pypa/hatch#775 for my question on dependabot and hatch environment dependencies. I'm closing this issue then. For reference, the entire new development process is documented at Thanks everyone for your input, was invaluable 🫶 |
I like constructing an expected version variable at the beginning of my workflows. Merges to the main branch expect @jorisroovers I've also made some comments in your older PRs since I've missed some of those. |
@webknjaz Thanks for all the comments and PR 🙏 Let me work through them over the next week or so! |
Bunch of new issues were created from this:
Closing this particular issue again now, we can track progress in the others. Thanks! |
Thanks for all the work on this, it clearly looks far better now. While the lack of tox is a red flag for me, mainly because it makes harder to contribute to the project) I love the direction. I am happy that my mk tool was able to stop the executable in the root and expose it as a test command. Still, even with this no venv management involved and no way to only run linting, no way to run tests with a specific version of python. Extra kudos for using mkdocs! |
Still on my wish list. I've spend a bit of time getting this to work with hatch, but I was using asdf for managing python installations which was causing some issues. I've switched to rtx more recently, would have to retry again with that.
Have been for years 💙 - that far predates this issue :) I'm planning to adopt Material for Mkdocs and modernize the docs as part of the current release cycle though! |
I’d like to get some input on best-practices around python build/test/project management/CI tooling. I want to streamline the gitlint developer and release experience to:
./run_tests.sh
)Background
Test running
pytest
,pylint
,black
,coverage
, andradon
, as well as a build (python setup.py sdist bdist_wheel
) test.run_tests.sh
also has some other utility functions likeclean
and some outdated python and docker environment management related code that is not used anymore.run_tests.sh
entirely and move to a python tool or script.tox
), so it becomes easier to run these tools against multiple python environments locally. Currently we use a test matrix in CI, perhaps this can be (partially) handled by the testing tool instead (so it’s independent of GHA).Builds
gitlint
(root dir) andgitlint-core
(gitlint-core dir), whatever tool/script we use should be able to support multiple python packages in a single repo / root dir.setup.py
towards declarative config andpyproject.toml
specifically. The build system should be PEP517 compliant.requirements*.txt
files in favor of usingextra_requires
fortest
,docs
, etc.publish
command for publishing toPyPI
is a nice to have.main
(seems to be the norm in my experience). Sample version string:0.19.dev-abc123
. I know some build systems or plugins help with this type of version management - that would be a nice to have. Currently we maintain gitlints version manually in 2 files: setup.py and gitlint-core/gitlint/__init__.py (also used to display the version in the UI).Candidates
poetry
and like it, but they’ve also done some weird things - I know opinions are divided on it. I think @asottile put it very eloquently in his video. So I think poetry is out as well.I’m planning to work on this in the next few weeks and would appreciate input on it. 🙏
Final Note: There’s many roads that lead to Rome, I think it’s likely there won’t be any consensus on this, in which case I’ll make a judgement call and just try something :-)
CC: @sigmavirus24, @asottile, @webknjaz, @ssbarnea, @andersk
The text was updated successfully, but these errors were encountered: