Skip to content

Commit 8181469

Browse files
committed
Simplify version management and update for next release
As a general principle, it makes sense to update the internal version number as soon as we've completed a release so that `dashboard-dev` is clearly distinguished from `dashboard`. So having released v0.2.1, I'm updating the version to v0.2.2. When I created the `version.py` build script, I'd envisioned reading the version directly from the `pyproject.toml` file, but for "simplicity" (of implementation) I ended up creating a separate `VERSION` file with the base version string. While easy to write, this is harder to manage over time. Python 3.11 includes a built-in `tomllib` package, but as we're still depending on 3.9 I experimented with several alternatives -- `toml` can't parse our `pyproject.toml` and was difficult to debug; but `tomlkit` is recommended by Python documentation (for pre-3.11 and for *writing* toml files), and that works. So we now have `[project] version = "v0.2.2"` as our only source of version truth in the repo, and the `version.py` script is now able to read that and generate our live version information from that.
1 parent 64f6c43 commit 8181469

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

backend/VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/poetry.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = "openshift_perfscale_api"
33
requires-python = ">=3.9,<3.10"
44
dynamic = ["dependencies"]
5-
version = "0.1.1"
6-
description = "Python transformer of OpenShift performance and scale test results"
5+
version = "0.2.2"
6+
description = "Aggregator for Performance & Scale CPT data"
77
authors = [{name = "mleader", email = "mleader@redhat.com"}]
88

99
[tool.poetry]
@@ -35,6 +35,7 @@ trio = "^0.28.0"
3535
uvicorn = "^0.34.0"
3636
uvloop = "^0.21.0"
3737
vyper-config = "1.0.0"
38+
tomlkit = "^0.13.3"
3839

3940
[tool.poetry.group.dev.dependencies]
4041
black = "^24.4.2"

backend/scripts/version.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import sys
1313
from typing import Optional
1414

15+
import tomlkit
16+
1517

1618
def do(cmd: list[str]) -> list[str]:
1719
result = subprocess.run(cmd, text=True, capture_output=True)
@@ -32,7 +34,9 @@ def getone(cmd: list[str], if_none: Optional[str] = None) -> str:
3234
def main():
3335
top = Path(getone(["git", "rev-parse", "--show-toplevel"]))
3436
backend = top / "backend"
35-
version = (backend / "VERSION").read_text().strip()
37+
with (backend / "pyproject.toml").open() as tml:
38+
config = tomlkit.load(tml)
39+
version = config["project"]["version"]
3640
sha = getone(["git", "rev-parse", "--short", "HEAD"])
3741
branch = getone(["git", "branch", "--show-current"], if_none="CI")
3842
display = f"v{version}-{sha}"
@@ -53,8 +57,4 @@ def main():
5357

5458

5559
if __name__ == "__main__":
56-
try:
57-
sys.exit(main())
58-
except Exception as exc:
59-
print(f"Failed with {str(exc)!r}", file=sys.stderr)
60-
sys.exit(1)
60+
sys.exit(main())

0 commit comments

Comments
 (0)