From f0639eec4fcb51fcd7feb93beedf9f5c8a301120 Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Fri, 31 May 2024 12:34:10 -0500 Subject: [PATCH 1/7] chore: add swiftformat GH action --- .github/workflows/swiftformat.yml | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/swiftformat.yml diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml new file mode 100644 index 0000000000..b68d7dfd69 --- /dev/null +++ b/.github/workflows/swiftformat.yml @@ -0,0 +1,46 @@ +name: SwiftFormat +on: + workflow_dispatch: + workflow_call: + inputs: + identifier: + required: true + type: string + + push: + branches-ignore: + - main + - v1 + - release + - release-v1 + +permissions: + contents: read + +concurrency: + group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref_name != 'main'}} + +jobs: + run-swiftformat: + runs-on: macos-latest + container: + image: ghcr.io/nicklockwood/swiftformat:0.53.10 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3 + with: + persist-credentials: false + + - name: SwiftFormat + run: | + swiftformat --lint . --reporter github-actions-log + + confirm-pass: + runs-on: macos-latest + name: Confirm Passing SwiftFormat + if: ${{ !cancelled() }} + needs: [ run-swiftformat ] + env: + EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }} + steps: + - run: exit $EXIT_CODE From bbfe338edce45bf532e01342c835710002b901f5 Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Fri, 31 May 2024 12:41:47 -0500 Subject: [PATCH 2/7] remove swift format container image --- .github/workflows/swiftformat.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml index b68d7dfd69..afd0782696 100644 --- a/.github/workflows/swiftformat.yml +++ b/.github/workflows/swiftformat.yml @@ -24,8 +24,6 @@ concurrency: jobs: run-swiftformat: runs-on: macos-latest - container: - image: ghcr.io/nicklockwood/swiftformat:0.53.10 steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3 with: From 60359d6a72a28ccb90130909250ec209c26f434c Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Fri, 31 May 2024 12:46:35 -0500 Subject: [PATCH 3/7] chore: disable error code with swift format linting --- .github/workflows/swiftformat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml index afd0782696..a338a3ad43 100644 --- a/.github/workflows/swiftformat.yml +++ b/.github/workflows/swiftformat.yml @@ -31,7 +31,7 @@ jobs: - name: SwiftFormat run: | - swiftformat --lint . --reporter github-actions-log + swiftformat --lint --lenient . --reporter github-actions-log confirm-pass: runs-on: macos-latest From 7f57b1ae476e866e0e6eed299ea7c466d181e3dd Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Tue, 4 Jun 2024 11:13:44 -0500 Subject: [PATCH 4/7] update to fail workflow on warning --- .github/workflows/swiftformat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml index a338a3ad43..afd0782696 100644 --- a/.github/workflows/swiftformat.yml +++ b/.github/workflows/swiftformat.yml @@ -31,7 +31,7 @@ jobs: - name: SwiftFormat run: | - swiftformat --lint --lenient . --reporter github-actions-log + swiftformat --lint . --reporter github-actions-log confirm-pass: runs-on: macos-latest From d9a812624d370cb166cb2d181225127c7a6fc3eb Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Tue, 13 Aug 2024 15:22:41 -0500 Subject: [PATCH 5/7] pin to specific version --- .github/workflows/swiftformat.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml index afd0782696..59f289e5fd 100644 --- a/.github/workflows/swiftformat.yml +++ b/.github/workflows/swiftformat.yml @@ -23,7 +23,9 @@ concurrency: jobs: run-swiftformat: - runs-on: macos-latest + runs-on: ubuntu-latest + container: + image: ghcr.io/nicklockwood/swiftformat:0.54.3 steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3 with: From 4b6d9450a4b757d7e513fd342b7b2d21f7f4a89d Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Tue, 13 Aug 2024 15:27:17 -0500 Subject: [PATCH 6/7] specify swift version --- .github/workflows/swiftformat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swiftformat.yml b/.github/workflows/swiftformat.yml index 59f289e5fd..863b75891d 100644 --- a/.github/workflows/swiftformat.yml +++ b/.github/workflows/swiftformat.yml @@ -33,7 +33,7 @@ jobs: - name: SwiftFormat run: | - swiftformat --lint . --reporter github-actions-log + swiftformat --lint . --reporter github-actions-log --swiftversion 5.9 confirm-pass: runs-on: macos-latest From 8e96777303621e69d96ac2842fe9dc0e5be1c1bd Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Thu, 24 Oct 2024 14:16:45 -0500 Subject: [PATCH 7/7] update swift format config --- .swiftformat | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.swiftformat b/.swiftformat index e42c8b27c6..b6234c1f6a 100644 --- a/.swiftformat +++ b/.swiftformat @@ -65,12 +65,17 @@ --enable void --empty void ---disable wrapArguments - --closingparen same-line - --wraparguments after-first +--enable wrapArguments + --closingparen balanced + --wraparguments before-first --wrapcollections before-first + --wrapconditions preserve # standalone rules +--disable preferKeyPath +--disable conditionalAssignment +--disable wrapMultilineConditionalAssignment +--disable wrapMultilineStatementBraces --disable andOperator --disable anyObjectProtocol --disable blankLinesAroundMark