add ci/cd pipelines and bump-my-version

I've been on a bit of a learning curve with python automated versioning, but I think this solution is a nice compromise of simplicity, automation, and manual control over the CI/CD pipeline on the public repo at least. This MR closes #77 (closed) .

Key points

  • The current pipeline consists of three jobs: build,test, and deploy. test is run on every push to the repo which verifies the minimum cases that:

    1. The package can be built in a fresh virtual environment
    2. The package passes unit tests under imsi/tests/
  • If the pipelines are successful, the deploy job will build and upload the project with the updated version to PyPI if a version is tagged.

  • deploy will (1) run on tagged pushes here, and (2) publish it on PyPI (Test PyPI for now until we are ready for the real deal). Note that this will require us to bump the version on the internal repos before pushing to this subtree. It will also require us to do some account management for PyPI and associated tokens

  • This MR configures the project to use bump-my-version to help us automatically bump versions. I like it for these reasons:

    1. It allows us to exert manual control over the version since it is essentially a CLI
    2. It can be installed as a python package locally which allows us to develop/do dry-runs
    3. It does not use commit parsing which should allow us to handle the git history a bit more cleanly between this subtree and the internal repos.
  • bump-my-version supports pre-releases which I think we should practice using. Specifically the dev, rc and final pre-releases. When a patch, minor, or major version is bumped, the default behaviour is to start at *-dev0 . This number can then be bumped with e.g.

    bump-my-version bump pre_n --tag --commit -vv --dry-run

    What the bump looks like is:

    (cicd) [rna001@hpcr6-in2 imsi]$ bump-my-version show-bump
    0.3.11-dev0 ── bump ─┬─ major ─ 1.0.0-dev0
                         ├─ minor ─ 0.4.0-dev0
                         ├─ patch ─ 0.3.12-dev0
                         ├─ pre_l ─ 0.3.11-rc0
                         ╰─ pre_n ─ 0.3.11-dev1

    So basically, we can just choose major, minor, patch, pre_l, or pre_n . pre_l bumps from dev -> rc -> final , pre_n bumps from one of the pre-release bumps to the next number so we can develop indefinitely, e.g. -dev0 -> -dev1 ... or *-rc0 -> *-rc1 and so on...

Deploy frequency/rules

The pipeline will publish the version when a version is tagged and pushed to this repo.

git tag -a v"whatever"
git push --tags

Changes

Using bump-my-version, two files are updated: __init__.py/__version__ and pyproject.toml developers should not update the version manually!

# pyproject.toml
...
[tool.bumpversion]
current_version = ...

The project version is grabbed dynamically by providing

# pyproject.toml

...
[project]
name = "imsi"
dynamic = ["version"]
...
[tool.setuptools.dynamic]
version = { attr = "imsi.__version__" }

Manual Usage

Bump My Version - Bump My Version has good docs, especially with the CLI. But a good place to start is this command:

bump-my-version bump patch --tag --commit --dry-run -vv

Which will give you a print out of everything that is going to be changed before it happens.

To do after merging and testing on cccma/imsi @ main branch.

  • Update pytests so that they don't need to rely on internal repository to test imsi
  • Add tokens for cccma group level PyPI and set it to UV_PUBLISH_TOKEN variable that we store in the group CI/CD variables
  • Add tokens for writing to git with a gitlab token in the CI/CD pipeline
  • Update the index used in uv publish to the real deal when it's time (will require PyPI account + token for the project stored as the value of UV_PUBLISH_TOKEN -- don't forget to mask).
  • Initialize the version from the correct target branch and run the pipeline!
Edited by nannau

Merge request reports

Loading