From cc79bf0eebaddf030859f1b6cf3ec1277c5d53aa Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Thu, 4 Jan 2024 10:33:42 -0600 Subject: [PATCH] chore: add swiftlint GH action --- .git-blame-ignore-revs | 2 ++ .github/workflows/swiftlint.yml | 46 +++++++++++++++++++++++++++++++++ .swiftlint.yml | 25 +++++++++++++++--- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 .git-blame-ignore-revs create mode 100644 .github/workflows/swiftlint.yml diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..3481d1a2de --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Resolve SwiftLint errors and warnings +659e8615da059eea5b6a4ce1b77120eae293ebec \ No newline at end of file diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml new file mode 100644 index 0000000000..51c2dd2262 --- /dev/null +++ b/.github/workflows/swiftlint.yml @@ -0,0 +1,46 @@ +name: SwiftLint +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-swiftlint: + runs-on: ubuntu-latest + container: + image: ghcr.io/realm/swiftlint:0.54.0 + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3 + with: + persist-credentials: false + + - name: SwiftLint + run: | + swiftlint --reporter github-actions-logging + + confirm-pass: + runs-on: ubuntu-latest + name: Confirm Passing SwiftLint + if: ${{ !cancelled() }} + needs: [ run-swiftlint ] + env: + EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }} + steps: + - run: exit $EXIT_CODE diff --git a/.swiftlint.yml b/.swiftlint.yml index a21fcd02f6..376e4579ae 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,10 +1,22 @@ # Do not specify an `included` section at this top-level file. Specify the # `--config` option pointing to this file, and the `--path` option to the files # you wish to lint +included: + - Amplify + - AmplifyPlugins excluded: - Pods - .build + - AmplifyAsyncTesting + - AmplifyFunctionalTests + - AmplifyTestApp + - AmplifyTestCommon + - AmplifyTests + - AmplifyPlugins/Core/AWSPluginsCoreTests + - AmplifyPlugins/Core/AWSPluginsTestCommon + - AmplifyPlugins/Notifications/Push/Tests + - AmplifyPlugins/*/Tests analyzer_rules: - unused_import @@ -18,10 +30,11 @@ closing_brace: error colon: severity: error comma: error -empty_count: warning +empty_count: + severity: warning empty_enum_arguments: error function_body_length: - warning: 100 + warning: 150 error: 150 identifier_name: excluded: @@ -29,9 +42,13 @@ identifier_name: - of - or line_length: - warning: 120 + ignores_urls: true + ignores_function_declarations: true + ignores_comments: true + warning: 160 error: 160 -opening_brace: error +opening_brace: + severity: error return_arrow_whitespace: error statement_position: severity: error