Skip to content

CI: check formatting on the PR, not at release time - #353

Merged
scgopi merged 1 commit into
mainfrom
fix/ci-run-format-check
Sep 13, 2026
Merged

scgopi merged 1 commit into
mainfrom
fix/ci-run-format-check

Conversation

@scgopi

@scgopi scgopi commented Sep 13, 2026

Copy link
Copy Markdown
Owner

The problem

Five releases in a row have reached main with swift-format --strict failing:

PR Violations
#320 3
ProjectPersistence 3
#350 5
#351 1
#352 1

Every one was a line the formatter wraps on its own. Every one was found while cutting a release, and fixed there as a separate commit before the version bump.

The reason it keeps happening is not carelessness. Branch gates and Linux CI were green on all fiveswift build passing and a full test run passing say nothing whatever about formatting, and nothing on the PR path runs make check. There is no signal until a release looks.

The change

One step in the Linux workflow, before swift build so the cheap check fails first:

- name: swift-format --strict
  run: swift format lint --recursive --strict --configuration .swift-format
    GraphcodeKit graphcode graphcode-cli graphcoded

That is the format half of make check, verbatim. swift format ships with the toolchain in the swift:6.2 container, so this adds no dependency and no install step.

The swiftlint half is deliberately left out: swiftlint is not in that image, and none of the five failures were lint — adding it would mean a new dependency for no demonstrated benefit.

Verified in both directions

A check that cannot fail is worse than no check, so I tested the real exit code rather than assuming:

  • With a [LineLength] violation injected: exit 1, reporting the offending line
  • Clean: exit 0

I also confirmed the YAML folds to exactly the intended single-line command, and reverted the injected violation so only the workflow file is changed here.

What this moves

Each of those five cost a release cycle: a red gate discovered mid-cut, a formatter run, a separate commit, a push, and a re-gate. This moves that to a failed check on the PR, where the author can fix it with swift format format --in-place in seconds.

Five releases in a row reached main with `swift-format --strict` failing —
#320, #350, #351, #352 and one in ProjectPersistence. Every one was a line the
formatter wraps on its own, and every one was found while cutting a release,
because nothing on the PR path looked. A green `swift build` and a green test
run say nothing about formatting.

Runs before `swift build` so the cheap check fails first. `swift format` ships
with the toolchain in this container, so no new dependency. This is the format
half of `make check`; the swiftlint half stays out because swiftlint is not in
this image, and none of the five failures were lint.

Verified both directions against the real command: exit 1 with a [LineLength]
violation present, exit 0 clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016n4hSXVu6wLR4RCfnt6PPG
@scgopi
scgopi merged commit fa604ca into main Sep 13, 2026
1 check passed
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