Open
Conversation
Runs swiftformat --lint in a Linux container on every PR using the same BuildTools pin (SwiftFormat 0.56.1) and flags as the local Scripts/swiftformat.sh, so CI stays in sync with `swift run swiftformat` on a developer machine. Fails the check on any violation without rewriting files — contributors fix formatting themselves and push, rather than having CI commit back over their branch. BuildTools/.build is cached by Package.resolved hash to keep subsequent runs fast.
Adds a concurrency group so rapid successive pushes to a PR branch don't stack up multiple Lint runs — the in-progress run is cancelled as soon as a newer commit arrives.
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.
Adds a
Lintworkflow that runsswiftformat --linton every pull request.What it does
ubuntu-latestinside the officialswift:6.0container — no macOS minutes consumed.BuildTools/Package.swiftso the CI version is always the same pin developers use locally (currently0.56.1). No separate config to drift.--headerand--excludeflags asScripts/swiftformat.sh, so whatever passes locally passes in CI.--lintmode: reports violations and exits non-zero without rewriting any files. The PR check goes red; the contributor runsswiftformatlocally and pushes the fix themselves. CI never commits back over a contributor's branch.BuildTools/.buildis cached byPackage.resolvedhash — first run compiles SwiftFormat (~2–3 min), subsequent runs are <30s.Why not auto-fix and commit back
GITHUB_TOKENcan't push to fork PRs, so any auto-fix path requires a PAT with push rights — a real security footgun for a lint job.git blameand commit authorship get muddied by bot commits.Enabling as a required check
The workflow only reports status. To actually block merges on lint failures, the check needs to be marked Required in branch protection (Settings → Branches →
dev→ "Require status checks to pass before merging" → addLint / SwiftFormat). GitHub only lets you require checks it has seen run at least once, so this should be done after the first successful run on this PR.