From fb32f71765b1f853e476a6e559c3747a40e5bb2e Mon Sep 17 00:00:00 2001 From: Bryant Finney Date: Sun, 8 Sep 2024 19:01:35 -0400 Subject: [PATCH] ci: fix caching and documentation builds at some point, I'll want to replace the shell tasks with Python ones Signed-off-by: Bryant Finney --- .github/workflows/push-poetry.yaml | 18 +++++++++++---- pyproject.toml | 37 +++++++++++------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/push-poetry.yaml b/.github/workflows/push-poetry.yaml index 9d1283e..6ec162b 100644 --- a/.github/workflows/push-poetry.yaml +++ b/.github/workflows/push-poetry.yaml @@ -105,9 +105,10 @@ jobs: path: docs - uses: ./.github/actions/poetry - with: - artifacts: "" - command: setup-versioning + with: { artifacts: "", command: setup-versioning } + + - uses: ./.github/actions/poetry + with: { artifacts: "", command: dynamic-versioning } - uses: ./.github/actions/poetry with: @@ -192,7 +193,6 @@ jobs: - uses: actions/setup-python@v5 with: - architecture: ${{ matrix.python-architecture || 'x64' }} python-version: 3.x - uses: ./.github/actions/poetry @@ -218,6 +218,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - uses: ./.github/actions/poetry + with: { artifacts: "", command: setup-versioning, groups: build } + + - uses: ./.github/actions/poetry + with: { artifacts: "", command: dynamic-versioning, groups: build } + - uses: PyO3/maturin-action@v1 with: command: sdist diff --git a/pyproject.toml b/pyproject.toml index 9eb80f6..dad9e46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,7 @@ name = "dicom-echo" description = "A lightweight, cross-platform, blazingly fast implementation of the C-ECHO DICOM procedure. 🔥" readme = "README.md" license = { file = "LICENSE.md" } -authors = [ - { name = "Bryant Finney", email = "bryant.finney@outlook.com" }, -] +authors = [ { name = "Bryant Finney", email = "bryant.finney@outlook.com" } ] requires-python = ">=3.8.1,<4" classifiers = [ "Development Status :: 2 - Pre-Alpha", @@ -83,9 +81,7 @@ mdformat-frontmatter = "^2.0.8" mdformat-footnote = "^0.1.1" [tool.poetry.group.test.dependencies] -coverage = { extras = [ - "toml", -], version = ">=6.4,<8.0" } +coverage = { extras = [ "toml" ], version = ">=6.4,<8.0" } pytest = ">=7.4.4,<9.0.0" pytest-clarity = "^1.0.1" pytest-cov = ">=3,<6" @@ -119,15 +115,8 @@ python-source = "src" [tool.ruff] line-length = 120 -src = [ - "echoscu", - "src", - "tests", -] - -extend-include = [ - "*.ipynb", -] +src = [ "echoscu", "src", "tests" ] +extend-include = [ "*.ipynb" ] fix = true show-fixes = true output-format = "full" @@ -679,13 +668,16 @@ post_publish = "maturin-upload" [tool.poe.tasks] _version.cmd = "poetry version --short" -_missing_cargo.shell = "command -v cargo >/dev/null || echo cargo not found" + +[tool.poe.tasks.which-cargo] +expr = "shutil.which('cargo') or ''" +imports = [ "shutil" ] [tool.poe.tasks.cargo] help = "Invoke cargo commands after applying `poetry-dynamic-versioning` substitutions" -shell = """test -n "$CARGO_MISSING" || cargo $cmd""" -args = [ { name = "cmd", positional = true } ] -uses = { CARGO_MISSING = "_missing_cargo" } +expr = "subprocess.check_output([${CARGO}, *sys.argv[1:]], encoding='utf-8') if ${CARGO} else ''" +imports = [ "subprocess", "sys" ] +uses = { CARGO = "which-cargo" } [tool.poe.tasks.check-for-prerelease] capture_stdout = "check-for-prerelease.out" @@ -700,7 +692,7 @@ help = "Generate this package's docs" uses = { PACKAGE_VERSION = "_version" } [[tool.poe.tasks.docs.sequence]] -ref = "cargo doc -- --target-dir ./docs" +ref = "cargo doc --target-dir docs" [[tool.poe.tasks.docs.sequence]] ref = "docs-serve --output-directory ./docs" @@ -723,7 +715,6 @@ cmd = """ typer typing unittest - unittest.mock --docformat google --footer "$PACKAGE_VERSION" --mermaid @@ -808,13 +799,13 @@ cmd = "maturin build --out dist --sdist" [tool.poe.tasks.maturin-develop] help = "Install the crate as a module in the poetry-managed virtualenv" shell = """ - if [ -n "$CARGO_MISSING" ]; then + if [ -z "${CARGO}" ]; then poetry pth else maturin develop fi """ -uses = { CARGO_MISSING = "_missing_cargo" } +uses = { CARGO = "which-cargo" } [tool.poe.tasks.maturin-upload] help = "Invoke maturin upload to publish this package to a PyPI registry"