Skip to content

Commit 00daa3e

Browse files
committed
Format source code and run git diff instead of listing first
The diff yields more insightful results than `swift-format lint`
1 parent a3f634e commit 00daa3e

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/pull_request.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,46 @@ jobs:
3737
uses: actions/checkout@v4
3838
with:
3939
persist-credentials: false
40+
- name: Mark the workspace as safe
41+
# https://github.com/actions/checkout/issues/766
42+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
4043
- name: Check out related PRs
4144
run: |
4245
apt-get update && apt-get install -y curl
4346
curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/cross-pr-checkout.swift > /tmp/cross-pr-checkout.swift
4447
swift /tmp/cross-pr-checkout.swift "${{ github.repository }}" "${{ github.event.number }}"
4548
- name: Build
46-
run: swift build --configuration release
49+
run: |
50+
swift build --configuration release
51+
- name: Add local swift-format to PATH
52+
run: |
53+
# Add the locally built version of swift-format to PATH so it gets picked up by check-swift-format.sh
54+
echo "PATH=$(pwd)/.build/release:$PATH" >> "$GITHUB_ENV"
55+
- name: Download check format script
56+
run: |
57+
curl https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-swift-format.sh > /tmp/check-swift-format.sh
58+
chmod +x /tmp/check-swift-format.sh
4759
- name: Format swift-format
48-
run: .build/release/swift-format lint --parallel --recursive --strict .
60+
run: |
61+
cd "$GITHUB_WORKSPACE"
62+
/tmp/check-swift-format.sh
4963
- name: Checkout swift-syntax
5064
uses: actions/checkout@v4
5165
with:
5266
repository: swiftlang/swift-syntax
5367
persist-credentials: false
5468
path: swift-syntax
5569
- name: Format swift-syntax
56-
run: .build/release/swift-format lint --parallel --recursive --strict swift-syntax
70+
run: |
71+
cd "$GITHUB_WORKSPACE/swift-syntax"
72+
/tmp/check-swift-format.sh
5773
- name: Checkout sourcekit-lsp
5874
uses: actions/checkout@v4
5975
with:
6076
repository: swiftlang/sourcekit-lsp
6177
persist-credentials: false
6278
path: sourcekit-lsp
6379
- name: Format sourcekit-lsp
64-
run: .build/release/swift-format lint --parallel --recursive --strict sourcekit-lsp
80+
run: |
81+
cd "$GITHUB_WORKSPACE/sourcekit-lsp"
82+
/tmp/check-swift-format.sh

0 commit comments

Comments
 (0)