From 0f26a2798076e69e699e4b18601d0cb5ab04e885 Mon Sep 17 00:00:00 2001 From: ecgang Date: Sun, 5 Jul 2026 04:36:59 -0700 Subject: [PATCH] Add SwiftLint as an advisory CI-only lint job (no Xcode plugin dependency) (#1361) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add SwiftLint as an advisory CI-only lint job (no Xcode plugin dependency) * Harden the advisory lint job and exclude build dirs from local runs The lint job runs a third-party container image, so drop its token to read-only, stop actions/checkout from persisting credentials into the workspace the container can read, and pin the image by digest as well as tag (tags are mutable). Also add an excluded: list to .swiftlint.yml so local swiftlint runs don't drown in .build/DerivedData artifacts — CI checkouts are fresh, so this only affects working trees. Co-Authored-By: Claude Fable 5 --------- Co-authored-by: jack Co-authored-by: Claude Fable 5 --- .github/workflows/swift-tests.yml | 24 ++++++++++++++++++++++ .swiftlint.yml | 33 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .swiftlint.yml diff --git a/.github/workflows/swift-tests.yml b/.github/workflows/swift-tests.yml index 7e8c5b06..c1a8194e 100644 --- a/.github/workflows/swift-tests.yml +++ b/.github/workflows/swift-tests.yml @@ -145,3 +145,27 @@ jobs: ARCHS=arm64 \ CODE_SIGNING_ALLOWED=NO \ build + + # Advisory only: SwiftLint reports style violations without ever failing the + # build. Runs in a pinned container (no Xcode plugin, no pbxproj changes) so + # it can never break the documented xcodebuild path or block a merge. + lint: + name: SwiftLint (advisory) + runs-on: ubuntu-latest + timeout-minutes: 15 + # This job runs a third-party container image, so give it the least + # privilege we can: a read-only token, and no credentials left in the + # checkout for the container to find. + permissions: + contents: read + container: + # Tag for readability, digest for immutability (tags can be repointed). + # Bump both together, deliberately — never a floating tag. + image: ghcr.io/realm/swiftlint:0.65.0@sha256:a482729f4b58741875af1566f23397f3f6db300372756fc31606d0a4527fab9e + continue-on-error: true + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + - name: Run SwiftLint + run: swiftlint lint --reporter github-actions-logging diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 00000000..e35a75d0 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,33 @@ +# Build artifacts and generated sources; keeps local `swiftlint` runs clean +# (CI checkouts are fresh, so this only matters in a working tree). +excluded: + - .build + - .swiftpm + - .DerivedData + - DerivedData + - build + - localPackages/*/.build + +disabled_rules: + - line_length + - type_name + - identifier_name + - statement_position + - implicit_optional_initialization + - force_try + - vertical_whitespace + - for_where + - control_statement + - void_function_in_ternary + - redundant_discardable_let # SwiftUI breaks without it + # To be enabled as we fix the issues + - trailing_whitespace + - cyclomatic_complexity + - function_body_length + - function_parameter_count + - type_body_length + - file_length + - large_tuple + - force_cast + - multiple_closures_with_trailing_closure + - nesting