diff --git a/.circleci/config.yml b/.circleci/config.yml index 0cd170898b..fb7f28430c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -164,9 +164,6 @@ commands: install_mint: type: boolean default: false - install_swiftlint: - type: boolean - default: true steps: - install-bundle-dependencies: directory: << parameters.directory >> @@ -183,16 +180,10 @@ commands: steps: - install-brew-dependency: dependency_name: "mint" - - when: - condition: << parameters.install_swiftlint >> - steps: - - install-brew-dependency: - dependency_name: "swiftlint" - run: brew tap robotsandpencils/made - save_cache: key: homebrew-cache-{{ checksum "Brewfile.lock.json" }}-{{ arch }} paths: - - /usr/local/Cellar/swiftlint/ - /usr/local/Cellar/xcbeautify/ - /Users/$USER/Library/Caches/Homebrew/ @@ -490,8 +481,7 @@ jobs: steps: - checkout - - install-dependencies: - install_swiftlint: false + - install-dependencies - update-spm-installation-commit - run: name: SPM RevenueCatUI Tests @@ -519,8 +509,7 @@ jobs: steps: - checkout - - install-dependencies: - install_swiftlint: false + - install-dependencies - update-spm-installation-commit - run: name: SPM RevenueCatUI Release Build @@ -552,8 +541,7 @@ jobs: steps: - checkout - - install-dependencies: - install_swiftlint: false + - install-dependencies - update-spm-installation-commit - run: name: SPM RevenueCatUI Release Build @@ -632,8 +620,7 @@ jobs: steps: - checkout - - install-dependencies: - install_swiftlint: false + - install-dependencies - run: name: Run tests command: bundle exec fastlane test_ios @@ -660,8 +647,7 @@ jobs: steps: - checkout - - install-dependencies: - install_swiftlint: false + - install-dependencies - update-spm-installation-commit - run: name: Run tests @@ -693,8 +679,7 @@ jobs: steps: - checkout - set-maximum-duration - - install-dependencies: - install_swiftlint: false + - install-dependencies - update-spm-installation-commit - run: name: Run tests @@ -773,7 +758,6 @@ jobs: - install-dependencies: install_xcbeautify: false install_mint: true - install_swiftlint: false - install-xcbeautify-for-xcode14 - update-spm-installation-commit - install-runtime: @@ -807,7 +791,6 @@ jobs: - install-dependencies: install_xcbeautify: false install_mint: true - install_swiftlint: false - macos/install-rosetta - install-xcbeautify-for-xcode14 - update-spm-installation-commit @@ -1106,8 +1089,14 @@ jobs: - run: name: Run fastlane swiftlint lane command: | - bundle exec fastlane run swiftlint raise_if_swiftlint_error:true strict:true \ - reporter:junit output_file:fastlane/test_output/swiftlint/junit.xml + # FIXME This doesn't work because somehow swift package plugins run for every target/module/scheme? + # Only the last of those runs will save the output file, causing issues to be lost. + swift package plugin \ + --allow-writing-to-directory fastlane/test_output/swiftlint \ + swiftlint \ + --strict \ + --reporter junit \ + --output fastlane/test_output/swiftlint/junit.xml - store_test_results: path: fastlane/test_output - store_artifacts: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fc5c1a83c0..8f1fae57f0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,3 +9,7 @@ updates: directory: "/" # Location of package manifests schedule: interval: "daily" + - package-ecosystem: "swift" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/Brewfile b/Brewfile index c3b20fa243..76d974dd37 100644 --- a/Brewfile +++ b/Brewfile @@ -5,6 +5,5 @@ tap "homebrew/cask" tap "homebrew/core" tap "robotsandpencils/made" -brew "swiftlint" brew "xcbeautify" brew "xcodes" diff --git a/Brewfile.lock.json b/Brewfile.lock.json index b00410fc0f..38c75a0862 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -15,50 +15,6 @@ } }, "brew": { - "swiftlint": { - "version": "0.53.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b", - "sha256": "240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9", - "sha256": "7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26", - "sha256": "78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540", - "sha256": "abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a", - "sha256": "be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979", - "sha256": "13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979" - }, - "x86_64_linux": { - "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0", - "sha256": "fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0" - } - } - } - }, "xcbeautify": { "version": "1.0.0", "bottle": { diff --git a/Package.resolved b/Package.resolved index f64d2a1fed..e440552b79 100644 --- a/Package.resolved +++ b/Package.resolved @@ -35,6 +35,15 @@ "revision" : "26ed3a2b4a2df47917ca9b790a57f91285b923fb", "version" : "1.12.0" } + }, + { + "identity" : "swiftlintplugins", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SimplyDanny/SwiftLintPlugins", + "state" : { + "revision" : "7c80ce6f142164b0201871e580b021d1b2c69804", + "version" : "0.57.0" + } } ], "version" : 2 diff --git a/Package.swift b/Package.swift index 1726968ab2..1dbf9afe3c 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,8 @@ let shouldIncludeDocCPlugin = environmentVariables["INCLUDE_DOCC_PLUGIN"] == "tr var dependencies: [Package.Dependency] = [ .package(url: "git@github.com:Quick/Nimble.git", from: "10.0.0"), // SST requires iOS 13 starting from version 1.13.0 - .package(url: "git@github.com:pointfreeco/swift-snapshot-testing.git", .upToNextMinor(from: "1.12.0")) + .package(url: "git@github.com:pointfreeco/swift-snapshot-testing.git", .upToNextMinor(from: "1.12.0")), + .package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: "0.57.0") ] if shouldIncludeDocCPlugin { // Versions 1.4.0 and 1.4.1 are failing to compile, so we are pinning it to 1.3.0 for now diff --git a/RevenueCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RevenueCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index db942d7e03..1f4cffa610 100644 --- a/RevenueCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RevenueCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -44,6 +44,15 @@ "revision" : "26ed3a2b4a2df47917ca9b790a57f91285b923fb", "version" : "1.12.0" } + }, + { + "identity" : "swiftlintplugins", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SimplyDanny/SwiftLintPlugins", + "state" : { + "revision" : "7c80ce6f142164b0201871e580b021d1b2c69804", + "version" : "0.57.0" + } } ], "version" : 2 diff --git a/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved index db942d7e03..1f4cffa610 100644 --- a/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RevenueCat.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -44,6 +44,15 @@ "revision" : "26ed3a2b4a2df47917ca9b790a57f91285b923fb", "version" : "1.12.0" } + }, + { + "identity" : "swiftlintplugins", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SimplyDanny/SwiftLintPlugins", + "state" : { + "revision" : "7c80ce6f142164b0201871e580b021d1b2c69804", + "version" : "0.57.0" + } } ], "version" : 2 diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh index 9366ae62d4..b1ea870a3c 100755 --- a/scripts/pre-commit.sh +++ b/scripts/pre-commit.sh @@ -1,13 +1,7 @@ #!/bin/bash # Figure out where swiftlint is -HOMEBREW_BINARY_DESTINATION="/opt/homebrew/bin" -SWIFT_LINT="${HOMEBREW_BINARY_DESTINATION}/swiftlint" - -if ! test -d $HOMEBREW_BINARY_DESTINATION; then - # X86_64 macs have this destination - SWIFT_LINT="/usr/local/bin/swiftlint" -fi +SWIFT_LINT="swift package plugin swiftlint" # Start timer START_DATE=$(date +"%s") @@ -57,18 +51,13 @@ verify_no_included_apikeys() { done } -if [[ -e "${SWIFT_LINT}" ]]; then - echo "SwiftLint version: $(${SWIFT_LINT} version)" - # Run only if not merging - if ! git rev-parse -q --verify MERGE_HEAD; then - # Run for just staged files - while IFS= read -r -d '' file; do - run_swiftlint "${file}" - done < <(git diff --cached --name-only -z) - fi -else - echo "${SWIFT_LINT} is not installed. Please install it via: fastlane setup_dev" - exit -1 +echo "SwiftLint version: $(${SWIFT_LINT} --version | head -n 1)" +# Run only if not merging +if ! git rev-parse -q --verify MERGE_HEAD; then + # Run for just staged files + while IFS= read -r -d '' file; do + run_swiftlint "${file}" + done < <(git diff --cached --name-only -z) fi END_DATE=$(date +"%s") diff --git a/scripts/swiftlint.sh b/scripts/swiftlint.sh index e9467be24f..e822f13760 100755 --- a/scripts/swiftlint.sh +++ b/scripts/swiftlint.sh @@ -1,31 +1,3 @@ #!/usr/bin/env bash -# Arm64 macs have this destination. -HOMEBREW_BINARY_DESTINATION="/opt/homebrew/bin" -if ! test -d $HOMEBREW_BINARY_DESTINATION; then - # X86_64 macs have this destination - HOMEBREW_BINARY_DESTINATION="/usr/local/bin" -fi - -echo "Adding homebrew bin folder to PATH (${HOMEBREW_BINARY_DESTINATION})" -PATH="${HOMEBREW_BINARY_DESTINATION}:${PATH}" - -if which swiftlint >/dev/null; then - script_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - source_path="${script_path}/../" - swiftlint_path="$(which swiftlint)" - - echo "linter path:" - echo $swiftlint_path - - lint_command="${swiftlint_path} lint" - echo "linter command: ${lint_command}" - - pushd "${source_path}" - # Run swiftlint but filter out "Linting ..." to clean up output - $lint_command 2>&1 | grep -v 'Linting ' - popd -else - echo "Warning: SwiftLint not installed in ${HOMEBREW_BINARY_DESTINATION}, download from https://github.com/realm/SwiftLint" -fi - +xcrun --sdk macosx swift package plugin swiftlint lint --quiet