Skip to content

Commit 3b2ceba

Browse files
authored
chore: add swiftlint GH action (#3455)
* chore: add swiftlint GH action * chore: add xcodeproj with swiftlint build phase * chore: update git-blame-ignore-revs
1 parent 659e861 commit 3b2ceba

File tree

4 files changed

+437
-4
lines changed

4 files changed

+437
-4
lines changed

.git-blame-ignore-revs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Resolve SwiftLint errors and warnings
2+
# https://github.com/aws-amplify/amplify-swift/pull/3451
3+
659e8615da059eea5b6a4ce1b77120eae293ebec

.github/workflows/swiftlint.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: SwiftLint
2+
on:
3+
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
identifier:
7+
required: true
8+
type: string
9+
10+
push:
11+
branches-ignore:
12+
- main
13+
- v1
14+
- release
15+
- release-v1
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
22+
cancel-in-progress: ${{ github.ref_name != 'main'}}
23+
24+
jobs:
25+
run-swiftlint:
26+
runs-on: ubuntu-latest
27+
container:
28+
image: ghcr.io/realm/swiftlint:0.54.0
29+
steps:
30+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
31+
with:
32+
persist-credentials: false
33+
34+
- name: SwiftLint
35+
run: |
36+
swiftlint --reporter github-actions-logging
37+
38+
confirm-pass:
39+
runs-on: ubuntu-latest
40+
name: Confirm Passing SwiftLint
41+
if: ${{ !cancelled() }}
42+
needs: [ run-swiftlint ]
43+
env:
44+
EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
45+
steps:
46+
- run: exit $EXIT_CODE

.swiftlint.yml

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
# Do not specify an `included` section at this top-level file. Specify the
22
# `--config` option pointing to this file, and the `--path` option to the files
33
# you wish to lint
4+
included:
5+
- Amplify
6+
- AmplifyPlugins
47

58
excluded:
69
- Pods
710
- .build
11+
- AmplifyAsyncTesting
12+
- AmplifyFunctionalTests
13+
- AmplifyTestApp
14+
- AmplifyTestCommon
15+
- AmplifyTests
16+
- AmplifyPlugins/Core/AWSPluginsCoreTests
17+
- AmplifyPlugins/Core/AWSPluginsTestCommon
18+
- AmplifyPlugins/Notifications/Push/Tests
19+
- AmplifyPlugins/*/Tests
820

921
analyzer_rules:
1022
- unused_import
@@ -18,22 +30,29 @@ closing_brace: error
1830
colon:
1931
severity: error
2032
comma: error
21-
empty_count: warning
33+
empty_count:
34+
severity: warning
2235
empty_enum_arguments: error
2336
function_body_length:
24-
warning: 100
37+
warning: 150
2538
error: 150
2639
identifier_name:
2740
excluded:
2841
- id
2942
- of
3043
- or
3144
line_length:
32-
warning: 120
45+
ignores_urls: true
46+
ignores_function_declarations: true
47+
ignores_comments: true
48+
warning: 160
3349
error: 160
34-
opening_brace: error
50+
opening_brace:
51+
severity: error
3552
return_arrow_whitespace: error
3653
statement_position:
3754
severity: error
3855
todo: warning
3956
trailing_semicolon: error
57+
non_optional_string_data_conversion:
58+
severity: error

0 commit comments

Comments
 (0)