Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SwiftLint Analyse to CI #63

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -56,11 +62,9 @@ jobs:
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Restore cache
uses: irgaly/xcode-cache@v1
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ github.sha }}
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ playground.xcworkspace

.build/
build/
build.log

# CocoaPods
#
Expand Down
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
disabled_rules:
- line_length
- nesting
analyzer_rules:
- unused_declaration
- unused_import
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion PagerCall/MouseHandlerView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// from https://github.com/orchetect/MenuBarExtraAccess/discussions/2#discussioncomment-5744323
import SwiftUI
import AppKit

class MouseHandlerView: NSView {
var onRightMouseDown: (() -> Void)?
Expand Down
2 changes: 1 addition & 1 deletion PagerCall/Notification.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SwiftUI
import AppKit
import UserNotifications

enum Notification {
Expand Down
3 changes: 2 additions & 1 deletion PagerCall/PagerCallApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import AsyncAlgorithms
import MenuBarExtraAccess
import SwiftUI
import UserNotifications

@main
struct PagerCallApp: App {
Expand All @@ -13,7 +12,9 @@ struct PagerCallApp: App {
@AppStorage("interval") private var interval = Constants.defaultInterval
@StateObject private var pagerDuty = PagerDuty()

// swiftlint:disable unused_declaration
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
// swiftlint:enable unused_declaration

private var popover: NSPopover = {
let pop = NSPopover()
Expand Down
9 changes: 0 additions & 9 deletions PagerCall/PagerDutyAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ struct PagerDutyAPI {

@AppStorage("userID") private var userID: String = ""

private struct UsersMeResp: Codable {
let user: User

struct User: Codable {
let id: String
let htmlUrl: String
}
}

private struct OncallsResp: Codable {
let oncalls: [Oncall]
struct Oncall: Codable {}
Expand Down
1 change: 0 additions & 1 deletion PagerCall/PagerDutyModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ enum Status: String {

@MainActor
class PagerDuty: ObservableObject {
private let endpoint = URL(string: "https://api.pagerduty.com/")!
private let api = PagerDutyAPI()

@Published var incidents: Incidents = []
Expand Down