From 94a853d57506dd6934a7b03859e84592ab4e7e0a Mon Sep 17 00:00:00 2001 From: sotashimozono Date: Sun, 13 Sep 2026 13:42:06 +0000 Subject: [PATCH] Let the formatter float again, keeping the clean env that actually fixed it `JF_VERSION: '2.10.1'` was added when the check was still nondeterministic, on the theory that a pin was what made it reproducible. The 2026-07-25 diagnosis had already shown otherwise: the same commit resolved 2.3.2 on rosina and 2.10.1 on a laptop because `Pkg.add` was landing in the runner's shared depot, whose compat bounds capped the resolve. `Pkg.activate(; temp=true)` fixed that, and it stays. The pin rode along and has been standing debt in 27 callers since. A pin also rots in a way this fleet cannot see: the pinned version is what every repo is formatted against, so the longer it sits the larger the eventual reflow. It has now sat from 2.10.1 to 2.14.0. Measured before removing it, by resolving both versions in a temp env and running `format(dir; overwrite=false)` over a shallow clone of all 27 callers: 26 are clean under the pin today, and 13 of those reflow under 2.14.0. So this is not free, unlike the same change in QAtlasHub/.github where every caller was already at 2.14.0. The diff is redundant semicolons and nothing else. Classifying every removed line across the thirteen: 654 are a trailing `;` at end of statement (`sw = Sweeps(6);` to `sw = Sweeps(6)`), and 61 are a bare `;` alone on a line, an empty statement 2.10.1 emitted itself. Nothing falls outside those two, which is why the diffstats are not line-for-line. Largest is FibVUMPS at 97 files; eight of the thirteen are under ten lines. Order matters: this must merge before the reformats, or each reformat PR is red against the pin it is meant to move past. The thirteen are ComplexTimeEvolution, ComplexTimeExperiments, FibVUMPS, ITensorcMPS, ITensorModels, OnoResponseMPS, ParaLinearAlgebra, ParameterizedITensor, ParameterizedITensorMPS, ReducedEnvExperiments, SingleSiteDMRG, StructuredITensors and ThermalMPS. AdiabaticPumpExperiments is red under both and is a separate pre-existing failure. Also asserts that the loaded JuliaFormatter is the one the temp project holds. `using` falls back to the depot's default environment when the active project does not declare the package, which has silently formatted this fleet at 2.4.0 twice, once from a throwaway env and once from a named `@format` env. The failure message now names the resolved version and uses `overwrite=true` with a retry loop, since `overwrite=false` is the check rather than the fix and a single pass does not always converge. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/format-check.yml | 43 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/format-check.yml b/.github/workflows/format-check.yml index 7cfd48e..53466ae 100644 --- a/.github/workflows/format-check.yml +++ b/.github/workflows/format-check.yml @@ -3,20 +3,20 @@ name: Format Check # Reusable JuliaFormatter check. The pool follows the CALLER's visibility unless `runner` is # passed — private → rosina, public → ubuntu-latest. Canonical note: `autoregister.yml`. # -# TWO things here are load-bearing — do not "simplify" them away: +# `Pkg.activate(; temp=true)` is load-bearing — do not "simplify" it away. Installing into the +# runner's shared/default environment lets that depot's existing compat bounds cap the resolve: on +# rosina a floating spec silently resolved to JuliaFormatter 2.3.2 while a laptop resolved 2.10.1, +# and a leftover ITensorFormatter there once made the install fail outright. Same code, different +# verdict, which is the long-standing "format-check flake". It was never a flake, it was the +# shared env, and that is the half worth defending. # -# 1. `Pkg.activate(; temp=true)` — a CLEAN env. Installing into the runner's shared/default -# environment lets that depot's existing compat bounds cap the resolve: on rosina a floating -# `version="2"` silently resolved to **JuliaFormatter 2.3.2**, while a laptop resolved 2.10.1. -# Same code, different verdict → the long-standing "format-check flake". It was never a flake, -# it was version drift. -# 2. `JF_VERSION` is an EXACT pin, not a range. CI and your laptop must run the *same* formatter -# or the check is not reproducible. Bump it here, once, and reformat the fleet with that -# version — never let it float. +# The version floats, deliberately. When a new 2.x reflows files the answer is to adopt it and +# reformat, not to freeze the old one: a pin here becomes standing debt in every caller and rots +# while the ecosystem moves. Reproducibility comes from the clean env above, not from the pin. # -# Format locally with exactly this version: +# Format locally with the same floating spec, in a temp env, so you resolve what CI just did: # julia -e 'using Pkg; Pkg.activate(;temp=true); Pkg.add(PackageSpec(name="JuliaFormatter", -# version="2.10.1")); using JuliaFormatter; format(".")' +# version="2")); using JuliaFormatter; format(".")' on: workflow_call: inputs: @@ -26,9 +26,6 @@ on: type: string default: '' -env: - JF_VERSION: '2.10.1' - jobs: format-check: runs-on: ${{ inputs.runner != '' && fromJSON(inputs.runner) || (github.event.repository.private && fromJSON('["self-hosted","rosina"]') || 'ubuntu-latest') }} @@ -37,23 +34,27 @@ jobs: - uses: julia-actions/setup-julia@v2 with: version: '1' - - name: JuliaFormatter ${{ env.JF_VERSION }} check + - name: JuliaFormatter check shell: julia --color=yes {0} run: | using Pkg Pkg.activate(; temp = true) # clean env — no depot compat capping the resolve - Pkg.add(PackageSpec(name = "JuliaFormatter", version = ENV["JF_VERSION"])) + Pkg.add(PackageSpec(name = "JuliaFormatter", version = "2")) using JuliaFormatter v = pkgversion(JuliaFormatter) - @info "JuliaFormatter $v (pinned $(ENV["JF_VERSION"]))" - if string(v) != ENV["JF_VERSION"] - println(stderr, "❌ resolved JuliaFormatter $v, expected $(ENV["JF_VERSION"]) — the check would not be reproducible.") + # `using` falls back to the depot's default env when the active project does not declare + # the package, loading a different version and saying nothing, so ask the project itself. + declared = [p.version for (_, p) in Pkg.dependencies() if p.name == "JuliaFormatter"] + if declared != [v] + println(stderr, "❌ JuliaFormatter $v came from outside the temp project, which holds $declared.") exit(1) end + @info "JuliaFormatter $v" ok = format("."; verbose = true, overwrite = false) if !ok - println(stderr, "❌ Not formatted. Run locally with the SAME version:") - println(stderr, " julia -e 'using Pkg; Pkg.activate(;temp=true); Pkg.add(PackageSpec(name=\"JuliaFormatter\", version=\"$(ENV["JF_VERSION"])\")); using JuliaFormatter; format(\".\")'") + println(stderr, "❌ Not formatted, under JuliaFormatter $v. `overwrite=false` above is the check;") + println(stderr, " locally you want `true`, and one pass does not always converge. Run:") + println(stderr, " julia -e 'using Pkg; Pkg.activate(;temp=true); Pkg.add(PackageSpec(name=\"JuliaFormatter\", version=\"2\")); using JuliaFormatter; for _ in 1:5; format(\".\"; overwrite=true) && break end'") exit(1) end println("✅ All files properly formatted.")