From 4782e2f11d52e87cff85518126695898695712d8 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 20 Sep 2024 16:22:48 -0400 Subject: [PATCH] Add a swift-format check to run on PRs. Based off the swift-nio ones. --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78b7ff4ea..7c32fc73e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,6 +132,32 @@ jobs: - name: Check for API breaking changes run: swift package diagnose-api-breaking-changes origin/main + format-check: + name: swift-format Check + # Only on pull requests + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + container: + # Use use the latest Swift release and that's the version of swift-format + # people should use. + image: swift:latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Mark the workspace as safe + # https://github.com/actions/checkout/issues/766 + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: Run format check + run: | + set -eu + git ls-files -z '*.swift' | xargs -0 swift format format --parallel --in-place + GIT_PAGER='' git diff --exit-code '*.swift' + # Disabled as it produces multiple warnings at the moment. + # - name: Run format lint check + # run: | + # set -eu + # git ls-files -z '*.swift' | xargs -0 swift format lint --strict --parallel + sanitizer_testing: runs-on: ubuntu-latest strategy: