From 8b758972557130b5d5c6953f1f13bdec3f4b7dee Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 10:45:51 +1000 Subject: [PATCH 01/14] Add config file --- .swiftlint.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .swiftlint.yml diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 00000000..5f4d1fed --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,11 @@ +disabled_rules: + - file_length + - trailing_whitespace + - identifier_name + - type_body_length + - function_body_length + - type_name + - todo + - redundant_optional_initialization + +line_length: 100 From 0f29094ee3bfa883fe92ba4139eabe586841e95d Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 10:50:22 +1000 Subject: [PATCH 02/14] Update excluded rules --- .swiftlint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.swiftlint.yml b/.swiftlint.yml index 5f4d1fed..ef121a67 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -7,5 +7,7 @@ disabled_rules: - type_name - todo - redundant_optional_initialization + - cyclomatic_complexity + - force_try line_length: 100 From 45f6f48bf51290ff616c10cc802fba4dd616ec54 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 10:50:38 +1000 Subject: [PATCH 03/14] Attempt to run as a CI check --- .github/workflows/swiftlint.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/swiftlint.yaml diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml new file mode 100644 index 00000000..a10ad10c --- /dev/null +++ b/.github/workflows/swiftlint.yaml @@ -0,0 +1,22 @@ +on: + workflow_dispatch: + push: + branches: [main] + pull_request: + +name: SwiftLint + +on: + pull_request: + paths: + - '.github/workflows/swiftlint.yml' + - '.swiftlint.yml' + - '**/*.swift' + +jobs: + SwiftLint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: GitHub Action for SwiftLint + uses: norio-nomura/action-swiftlint@master \ No newline at end of file From 16550b38fc5b97b1b16c29573b539532c11b1da3 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 10:53:08 +1000 Subject: [PATCH 04/14] Fix YAML --- .github/workflows/swiftlint.yaml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index a10ad10c..ad432e59 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -1,11 +1,3 @@ -on: - workflow_dispatch: - push: - branches: [main] - pull_request: - -name: SwiftLint - on: pull_request: paths: @@ -13,6 +5,8 @@ on: - '.swiftlint.yml' - '**/*.swift' +name: SwiftLint + jobs: SwiftLint: runs-on: ubuntu-latest From 8770e1be08c0ad5fb62023326e244f2a2e5123b5 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:01:32 +1000 Subject: [PATCH 05/14] Scope to a useful subset of rules --- .swiftlint.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index ef121a67..b5cbf71e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,13 +1,19 @@ -disabled_rules: - - file_length - - trailing_whitespace - - identifier_name - - type_body_length - - function_body_length - - type_name - - todo - - redundant_optional_initialization - - cyclomatic_complexity - - force_try +only_rules: + - line_length + - vertical_whitespace + - redundant_discardable_let + - unused_closure_parameter + - mark + - implicit_getter + - trailing_comma + - orphaned_doc_comment + - control_statement + - multiple_closures_with_trailing_closure + - opening_brace + - empty_enum_arguments + - for_where + - redundant_string_enum_value + - colon + - syntactic_sugar line_length: 100 From 2ca258d4a18221a23f295cd44f8e4c93f928e7c0 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:02:18 +1000 Subject: [PATCH 06/14] Only lint files changed in the PR --- .github/workflows/swiftlint.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index ad432e59..e117f8d7 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -13,4 +13,6 @@ jobs: steps: - uses: actions/checkout@v1 - name: GitHub Action for SwiftLint - uses: norio-nomura/action-swiftlint@master \ No newline at end of file + uses: norio-nomura/action-swiftlint@master + env: + DIFF_BASE: ${{ github.base_ref }} \ No newline at end of file From a99acb566f654f0fa29359539ca1a52d9f495681 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:14:52 +1000 Subject: [PATCH 07/14] Make working dir as safe --- .github/workflows/swiftlint.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index e117f8d7..9f7ce1ab 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -11,7 +11,9 @@ jobs: SwiftLint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + with: + set-safe-directory: '*' - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master env: From f01b3b3d73a1d39d00b7c34f8e3927c08da3590f Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:20:57 +1000 Subject: [PATCH 08/14] Try mac runner to see if results change --- .github/workflows/swiftlint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 9f7ce1ab..1b5abab2 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -9,11 +9,11 @@ name: SwiftLint jobs: SwiftLint: - runs-on: ubuntu-latest + runs-on: macos-12 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: - set-safe-directory: '*' + set-safe-directory: '/github/workspace' - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master env: From e4fe66fe863d8cbd409599a0cea8295c3c9a6f0d Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:22:35 +1000 Subject: [PATCH 09/14] Back to linux --- .github/workflows/swiftlint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 1b5abab2..9a2e1904 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -9,7 +9,7 @@ name: SwiftLint jobs: SwiftLint: - runs-on: macos-12 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: From 363b65b80880cd01c25b3f8e25e182ed049f7598 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:26:37 +1000 Subject: [PATCH 10/14] Fetch base branch --- .github/workflows/swiftlint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 9a2e1904..e0f5cf41 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -14,6 +14,8 @@ jobs: - uses: actions/checkout@v3 with: set-safe-directory: '/github/workspace' + - name: Fetch PR's target branch + run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }} - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master env: From 4cbdaa79390e176f00bedefd22a00d70b8f0fa6b Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:30:04 +1000 Subject: [PATCH 11/14] Attempt to take ownership of the folder --- .github/workflows/swiftlint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index e0f5cf41..0aa652b3 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -16,6 +16,8 @@ jobs: set-safe-directory: '/github/workspace' - name: Fetch PR's target branch run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }} + - name: Fix permissions + run: sudo chown -R "$(whoami)" /github/workspace - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master env: From 18ff0234bc65cec0d5d10172c864d7a1de63ee72 Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:33:43 +1000 Subject: [PATCH 12/14] Force exclusion --- .github/workflows/swiftlint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 0aa652b3..85c6c81f 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -20,5 +20,7 @@ jobs: run: sudo chown -R "$(whoami)" /github/workspace - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master + with: + args: --force-exclude env: DIFF_BASE: ${{ github.base_ref }} \ No newline at end of file From c1596e16f2bda89c66635f6202f08aa2e7c38dcb Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:37:05 +1000 Subject: [PATCH 13/14] Remove permission fix --- .github/workflows/swiftlint.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 85c6c81f..5dc12515 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -16,8 +16,6 @@ jobs: set-safe-directory: '/github/workspace' - name: Fetch PR's target branch run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }} - - name: Fix permissions - run: sudo chown -R "$(whoami)" /github/workspace - name: GitHub Action for SwiftLint uses: norio-nomura/action-swiftlint@master with: From fadd6fac8317a85dbd72ca64d657023b82b0508b Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 4 May 2023 11:39:21 +1000 Subject: [PATCH 14/14] Give up on PR specific lint for now --- .github/workflows/swiftlint.yaml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/swiftlint.yaml b/.github/workflows/swiftlint.yaml index 5dc12515..8811ec2d 100644 --- a/.github/workflows/swiftlint.yaml +++ b/.github/workflows/swiftlint.yaml @@ -12,13 +12,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - set-safe-directory: '/github/workspace' - - name: Fetch PR's target branch - run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }} - name: GitHub Action for SwiftLint - uses: norio-nomura/action-swiftlint@master - with: - args: --force-exclude - env: - DIFF_BASE: ${{ github.base_ref }} \ No newline at end of file + uses: norio-nomura/action-swiftlint@master \ No newline at end of file