Refresh packaging and testing story
Description
Updating the packaging to make use of poetry
and update the CI and packaging configuration to make better use of modern GitLab features. Add some tests or at least the foundation for said.
Further details
There is a desire (https://gitlab.developers.cam.ac.uk/uis/devops/admin/-/issues/295) to up our game when it comes to packaging Python scripts. From the discussions on related issues we'd like to cover the following:
- Use poetry for packaging.
- Use tox as a task runner which allows test suite and linting to be run.
- Use pytest for a test harness.
- Use black and isort for automated linting/formatting.
- Use pre-commit to allow re-formatting files pre-commit.
- Run tests over a matrix of Python versions.
- Support test reporting via xunit XML files and report back to GitLab.
- Support test coverage reporting and report back to GitLab.
- Automatically build and tag images with the version number of the script.
- Automatically build packages and publish to PyPI/GitLab's package registry.
Task list
- Add a poetry-based packaging
- Add a basic pytest cofiguration
- Add a tox configuration which runs pytest, coverage, and pre-commit in test mode.
- Pytest should output test results in xunit form.
- Add a pre-commit configuration which runs black, isort, line-ending checks, etc.
- Use the existing pre-commit GitLab CI template.
- Add GitLab CI configuration (with an eye to moving to common template to):
- Build wheels and upload to the package registry
- Tag images with the tool version
Acceptance criteria
- All tasks completed.
Links/references
Gathers together discussion from: