From d689ccc154d686940889a2d63c603423d15e55d9 Mon Sep 17 00:00:00 2001 From: winebarrel Date: Mon, 4 Nov 2024 17:26:49 +0900 Subject: [PATCH] Add SwiftLint Analyse to CI --- .github/workflows/ci.yml | 11 ++++++++++- .gitignore | 1 + .swiftlint.yml | 3 +++ Makefile | 18 +++++++++++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4460964..346d0ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,12 @@ jobs: uses: actions/checkout@v4 - name: Switch Xcode run: sudo xcode-select -s /Applications/Xcode_16.app + - name: Install SwiftLint + env: + SWIFTLINT_VERSION: 0.57.0 + run: | + curl -sSfLO https://github.com/realm/SwiftLint/releases/download/${SWIFTLINT_VERSION}/portable_swiftlint.zip + unzip portable_swiftlint.zip swiftlint - name: Install the Apple certificate and provisioning profile env: BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} @@ -63,4 +69,7 @@ jobs: restore-keys: xcode-cache-deriveddata-${{ github.workflow }}- - name: Build and Analyse run: | - xcodebuild build analyze -scheme PagerCall -destination 'generic/platform=macOS' -allowProvisioningUpdates + xcodebuild build analyze -scheme PagerCall -destination 'generic/platform=macOS' -allowProvisioningUpdates -configuration Debug | tee build.log + - name: SwiftLint Analyse + run: | + ./swiftlint analyze --compiler-log-path build.log diff --git a/.gitignore b/.gitignore index fbc8c29..e3862fd 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ playground.xcworkspace .build/ build/ +build.log # CocoaPods # diff --git a/.swiftlint.yml b/.swiftlint.yml index 6a9869a..88538c2 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,3 +1,6 @@ disabled_rules: - line_length - nesting +analyzer_rules: + - unused_declaration + - unused_import diff --git a/Makefile b/Makefile index deffbde..88be73e 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,22 @@ -BUILD_DIR = ./build -APP_NAME = PagerCall -ARCHIVE_PATH = $(BUILD_DIR)/$(APP_NAME).xcarchive +BUILD_DIR = ./build +APP_NAME = PagerCall +ARCHIVE_PATH = $(BUILD_DIR)/$(APP_NAME).xcarchive +CONFIGURATION = Release +BUILD_LOG = ./build.log .PHONY: build build: clean xcodebuild build analyze archive \ -destination "generic/platform=macOS" \ -scheme $(APP_NAME) \ - -configuration Release \ - -archivePath $(ARCHIVE_PATH) + -configuration $(CONFIGURATION) \ + -archivePath $(ARCHIVE_PATH) \ + | tee $(BUILD_LOG) + +.PHONY: swiftlint-analyze +swiftlint-analyze: + $(MAKE) build CONFIGURATION=Debug + swiftlint analyze --compiler-log-path $(BUILD_LOG) .PHONY: clean clean: