Skip to content

Commit c559ee9

Browse files
committed
refactor: use Ubuntu without container for swift-format
- Switch from Docker container to native Ubuntu runner - Use swift-actions/setup-swift for Swift installation - Cache built swift-format binary for faster subsequent runs - Eliminates detached HEAD warnings from container environment - Maintains Ubuntu speed advantage over macOS runners
1 parent e7ade02 commit c559ee9

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

.github/workflows/swift-format.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,36 @@ concurrency:
1212
jobs:
1313
swift_format:
1414
name: swift-format
15-
runs-on: macos-latest
15+
runs-on: ubuntu-latest
1616
permissions:
1717
contents: write
1818
steps:
1919
- uses: actions/checkout@v5
2020

21-
- name: Install swift-format
22-
run: brew install swift-format
21+
- uses: swift-actions/setup-swift@v2
22+
with:
23+
swift-version: '6.0'
24+
25+
- name: Cache swift-format
26+
id: cache-swift-format
27+
uses: actions/cache@v4
28+
with:
29+
path: .build/swift-format
30+
key: ${{ runner.os }}-swift-format-${{ hashFiles('.github/workflows/swift-format.yml') }}
31+
32+
- name: Build swift-format
33+
if: steps.cache-swift-format.outputs.cache-hit != 'true'
34+
run: |
35+
git clone --depth 1 --branch main https://github.com/apple/swift-format.git
36+
cd swift-format
37+
swift build -c release
38+
mkdir -p ../.build
39+
cp .build/release/swift-format ../.build/swift-format
40+
cd ..
41+
rm -rf swift-format
2342
2443
- name: Format
25-
run: swift-format format --ignore-unparsable-files --recursive --in-place Sources Tests
44+
run: .build/swift-format format --ignore-unparsable-files --recursive --in-place Sources Tests
2645

2746
- uses: stefanzweifel/git-auto-commit-action@v7
2847
with:

0 commit comments

Comments
 (0)