Skip to content

Commit c4adb9b

Browse files
authored
Add SwiftFormat lint check on pull requests (#599)
* Add SwiftFormat lint check on pull requests 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. * Cancel in-flight lint runs when a newer push lands 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.
1 parent 7d71ccf commit c4adb9b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Lint
2+
run-name: Lint (${{ github.head_ref || github.ref_name }})
3+
4+
on:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: lint-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
swiftformat:
17+
name: SwiftFormat
18+
runs-on: ubuntu-latest
19+
container: swift:6.0
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v5
23+
24+
- name: Cache SwiftFormat build
25+
uses: actions/cache@v4
26+
with:
27+
path: BuildTools/.build
28+
key: ${{ runner.os }}-swiftformat-${{ hashFiles('BuildTools/Package.resolved', 'BuildTools/Package.swift') }}
29+
restore-keys: |
30+
${{ runner.os }}-swiftformat-
31+
32+
- name: SwiftFormat --lint
33+
run: |
34+
swift run -c release --package-path BuildTools swiftformat . \
35+
--lint \
36+
--header "LoopFollow\n{file}" \
37+
--exclude Pods,Generated,R.generated.swift,fastlane/swift,Dependencies,dexcom-share-client-swift

0 commit comments

Comments
 (0)