Skip to content

ci: check the wheel's version and upload the distributions publish.yml releases - #63

Merged
mahdi-shafiei merged 2 commits into
mainfrom
ci/build-artifact-and-version-check
Oct 28, 2026
Merged

mahdi-shafiei merged 2 commits into
mainfrom
ci/build-artifact-and-version-check

Conversation

@mahdi-shafiei

@mahdi-shafiei mahdi-shafiei commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The two Build changes a repository needs before its publish.yml can release what the shared gates built. txpert-nnx and state-nnx are the first callers.

The import check compares __version__ with the installed metadata.

  • It reads the distribution name from pyproject.toml, because it can differ from the import name (avitai-txpert-nnx and txpert_nnx).
  • It fails when the package's __version__ differs from importlib.metadata.version of that distribution.
  • A package that declares no __version__ passes on its metadata version alone. artifex, avitai-knowledge, image-reconstruction and ai-for-science-hub declare none.
  • The check now runs isolated (-I). Before, it ran python -c from the repository root, so a flat-layout package would have imported from the source tree instead of the wheel.

The first Python leg uploads dist/ as python-package-distributions.

  • This is the name both nnx repos' publish.yml download.
  • The upload comes after the import check, so a release never carries distributions that failed it.
  • Only one leg uploads, because an artifact name must be unique within a run. An empty dist/ is an error.

Tests. They run the check's own step under the runner's shell (bash --noprofile --norc -eo pipefail) against a fake installed wheel, in five cases:

  • a matching version;
  • a contradicting version;
  • no version declared;
  • a listed module that doesn't import;
  • a source tree in the project root that would shadow the wheel.

Each new test failed before its step existed. As a control, removing -I makes the shadowing test fail with fakepkg.__version__ is 9.9, but fake-dist 1.0 is installed. actionlint 1.7.12 with shellcheck passes, and a planted SC2086 is caught.

Blast radius.

  • No caller calls python-gates yet, and substrax's own publish.yml builds in its own run, so the artifact name doesn't collide.
  • On origin/main of each repository, every stack package that declares a version matches its pyproject.toml: seven read it from __init__.py through hatchling, curifex's static 0.1.0 matches, and four read the installed metadata. Adopting the check turns no repository red.

The clean-install check imported each module with `python -c` from the
repository root, so a flat-layout package would import from the source
tree rather than the wheel, and it never compared the declared version
with the one the wheel installs.

The check now runs isolated (-I), imports the listed modules, reads the
distribution name from pyproject.toml (it may differ from the import
name) and fails when the package's __version__ differs from
importlib.metadata.version of that distribution. A package that declares
no __version__ has only the metadata version and passes.

The install and the check are separate steps, and the tests run the
check's step under the runner's shell against a fake installed wheel:
a matching, a contradicting and an absent version, a module that does
not import, and a source tree that would shadow the wheel.
A repository's publish.yml releases the distributions its CI built,
downloading the artifact `python-package-distributions`, and the shared
gates' Build job uploaded nothing. The first Python leg now uploads
`dist/` under that name, after the import check, so a release carries
only distributions every check passed. One leg uploads because an
artifact name is unique within a run; no files is an error.
@mahdi-shafiei
mahdi-shafiei marked this pull request as ready for review October 28, 2026 20:50
@mahdi-shafiei
mahdi-shafiei merged commit 91380ad into main Oct 28, 2026
12 checks passed
@mahdi-shafiei
mahdi-shafiei deleted the ci/build-artifact-and-version-check branch October 28, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant