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