CI: check formatting on the PR, not at release time - #353
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Five releases in a row have reached
mainwithswift-format --strictfailing:ProjectPersistenceEvery 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 five —
swift buildpassing and a full test run passing say nothing whatever about formatting, and nothing on the PR path runsmake check. There is no signal until a release looks.The change
One step in the Linux workflow, before
swift buildso the cheap check fails first:That is the format half of
make check, verbatim.swift formatships with the toolchain in theswift:6.2container, 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:
[LineLength]violation injected: exit 1, reporting the offending lineI 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-placein seconds.