Skip to content

Commit 4782e2f

Browse files
committed
Add a swift-format check to run on PRs.
Based off the swift-nio ones.
1 parent ebc7251 commit 4782e2f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,32 @@ jobs:
132132
- name: Check for API breaking changes
133133
run: swift package diagnose-api-breaking-changes origin/main
134134

135+
format-check:
136+
name: swift-format Check
137+
# Only on pull requests
138+
if: github.event_name == 'pull_request'
139+
runs-on: ubuntu-latest
140+
container:
141+
# Use use the latest Swift release and that's the version of swift-format
142+
# people should use.
143+
image: swift:latest
144+
steps:
145+
- name: Checkout
146+
uses: actions/checkout@v4
147+
- name: Mark the workspace as safe
148+
# https://github.com/actions/checkout/issues/766
149+
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
150+
- name: Run format check
151+
run: |
152+
set -eu
153+
git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place
154+
GIT_PAGER='' git diff --exit-code '*.swift'
155+
# Disabled as it produces multiple warnings at the moment.
156+
# - name: Run format lint check
157+
# run: |
158+
# set -eu
159+
# git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel
160+
135161
sanitizer_testing:
136162
runs-on: ubuntu-latest
137163
strategy:

0 commit comments

Comments
 (0)