diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..9c484561a --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,29 @@ +name: Format + +on: + push: + branches: + - '*' + +concurrency: + group: format-${{ github.ref }} + cancel-in-progress: true + +jobs: + swift_format: + name: swift-format + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + - name: Select Xcode 16 + run: sudo xcode-select -s /Applications/Xcode_16.app + - name: Install swift-format + run: brew install swift-format + - name: Format + run: make format + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "style: run swift-format" + branch: "main" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index 13b29b8bc..32f62a840 100644 --- a/Makefile +++ b/Makefile @@ -107,10 +107,14 @@ build-examples: done format: - @swiftformat . + find . \ + -path '*/Documentation.docc' -prune -o \ + -name '*.swift' \ + -not -path '*/.*' -print0 \ + | xargs -0 swift format --ignore-unparsable-files --in-place .PHONY: test-library test-linux build-example format define udid_for $(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }') -endef \ No newline at end of file +endef