Skip to content

Commit a580658

Browse files
committed
ci: fix Swift Format workflow
- Add swift-format installation step with caching - Switch to ubuntu-latest with Swift 6.0 container - Add concurrency control to cancel in-progress runs - Match working RFC package configuration
1 parent cb0cb2c commit a580658

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

.github/workflows/swift-format.yml

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
name: Swift Format
2+
23
on:
34
push:
4-
branches: [main]
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
511

612
jobs:
7-
format:
8-
runs-on: macos-26
13+
swift_format:
14+
name: swift-format
15+
runs-on: ubuntu-latest
16+
container: swift:6.0
17+
permissions:
18+
contents: write
919
steps:
1020
- uses: actions/checkout@v5
11-
- name: Format code
12-
run: swift-format format --recursive --in-place Sources Tests
13-
- name: Commit changes
14-
uses: stefanzweifel/git-auto-commit-action@v7
21+
22+
- name: Cache swift-format
23+
id: cache-swift-format
24+
uses: actions/cache@v4
25+
with:
26+
path: /usr/local/bin/swift-format
27+
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
28+
29+
- name: Install swift-format
30+
if: steps.cache-swift-format.outputs.cache-hit != 'true'
31+
run: |
32+
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
33+
cd swift-format
34+
swift build -c release
35+
cp .build/release/swift-format /usr/local/bin/
36+
cd ..
37+
rm -rf swift-format
38+
39+
- name: Format
40+
run: swift-format format --ignore-unparsable-files --recursive --in-place Sources Tests
41+
42+
- uses: stefanzweifel/git-auto-commit-action@v7
1543
with:
16-
commit_message: "Run swift-format"
44+
commit_message: Run swift-format
45+
branch: 'main'

0 commit comments

Comments
 (0)