From 094f04fef50020fff5bd2b3b3b86f97c10f52d7d Mon Sep 17 00:00:00 2001 From: mtfishman Date: Tue, 21 Apr 2026 15:16:58 -0400 Subject: [PATCH] VersionCheck: compare against base branch, not registered version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous check pulled the latest registered version from ITensorRegistry and asserted current > registered. This had a design gap: between a substantive PR merging (with a version bump) and the new version actually being registered, any number of further substantive PRs would pass without bumping the version, because "registered" was still the older value. Switch to comparing the current branch's Project.toml version against the same file on the PR's base branch. That answers the question reviewers actually have ("did this PR move the version forward relative to main"), removes the registration-timing dependency, and matches how related ecosystems (e.g. JuliaRegistries) intuit the check. Implementation: - Add a "Fetch base branch" step (the default actions/checkout@v4 is shallow on PR head only, so the base branch isn't otherwise available) that does git fetch --depth=1 origin "$GITHUB_BASE_REF". - Drop julia-actions/julia-buildpkg from this workflow — the new check only needs TOML (stdlib), not registry resolution. - Use TOML.parse + VersionNumber + a real if/error rather than @assert, so the failure produces a clean Julia error message rather than an AssertionError. The error spells out the base ref and both versions. - Skip gracefully when the base Project.toml is missing (initial-commit edge case) or when neither file has a version field. Error if only the PR removed the version field (regression). The localregistry input becomes unused but is kept (with an updated description) for backward compatibility with existing callers in ITensorPkgSkeleton-generated workflows. Tracked in ITensorDevelopmentPlans/Projects/ITensorActions/fixes_and_improvements. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/VersionCheck.yml | 60 +++++++++++++++++++----------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/.github/workflows/VersionCheck.yml b/.github/workflows/VersionCheck.yml index e08d132..9c04522 100644 --- a/.github/workflows/VersionCheck.yml +++ b/.github/workflows/VersionCheck.yml @@ -9,7 +9,7 @@ on: required: false type: string localregistry: - description: "Add local registries hosted on GitHub. Specified by providing the url (https/ssh) to the repositories as a newline (\n) seperated list. User is responsible for setting up the necessary SSH-Keys to access the repositories if necessary." + description: "Unused. Kept for backward compatibility with existing callers." default: "" required: false type: string @@ -31,36 +31,54 @@ jobs: echo "PR classified as non-substantive (only .github/**, .pre-commit-config.yaml, .gitignore, LICENSE)." echo "No version bump is required. Reporting success without running the real check." - - uses: julia-actions/setup-julia@v2 + - name: "Fetch base branch" if: steps.classify.outputs.substantive == 'true' - with: - version: ${{ inputs.julia-version }} + run: git fetch --depth=1 origin "${{ github.base_ref }}" - - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/setup-julia@v2 if: steps.classify.outputs.substantive == 'true' with: - localregistry: "${{ inputs.localregistry }}" + version: ${{ inputs.julia-version }} - - name: Check the Project version + - name: "Check version was bumped" if: steps.classify.outputs.substantive == 'true' shell: julia --color=yes {0} run: | - using Pkg - Pkg.activate(".") + using TOML - function find_pkg_info(uuid) - for registry in Pkg.Registry.reachable_registries() - if haskey(registry.pkgs, uuid) - return registry.pkgs[uuid] - end - end - error("Package not found in any registry") + base_ref = ENV["GITHUB_BASE_REF"] + base_project_text = try + read(`git show "origin/$base_ref:Project.toml"`, String) + catch err + println("Could not read Project.toml on origin/$base_ref ($err); skipping check.") + exit(0) end + base_project = TOML.parse(base_project_text) + current_project = TOML.parse(read("Project.toml", String)) - uuid = Pkg.project().uuid - pkg_info = find_pkg_info(uuid) + if !haskey(base_project, "version") + println("Base branch Project.toml has no version field; skipping check.") + exit(0) + end + if !haskey(current_project, "version") + error( + "Project.toml on this branch has no version field, but the base " * + "branch ($base_ref) does. Restore the version field and bump it." + ) + end - registered_version = maximum(keys(Registry.registry_info(pkg_info).version_info)) - current_version = Pkg.project().version + base_version = VersionNumber(base_project["version"]) + current_version = VersionNumber(current_project["version"]) - @assert registered_version < current_version "Current version is not greater than the registered version" + if current_version > base_version + println( + "OK: Project.toml version bumped from $base_version " * + "(origin/$base_ref) to $current_version (PR head)." + ) + else + error( + "Project.toml version was not bumped. Current version $current_version " * + "is not greater than the version $base_version on the base branch " * + "($base_ref). Bump the version in Project.toml." + ) + end