Skip to content

Commit a2ae43f

Browse files
authored
feat: add ci for testing Core and check the build-ability (#128)
* feat: add ci * fix: 最新のSwiftLintで検出される問題を修正 * feat: SwiftLintのバージョン表示を追加 * fix: update macOS version for updating Xcode version * fix: remove SYMROOT setting * feat: use Xcode 16.3 * fix: avoid signing * fix yaml
1 parent dc86318 commit a2ae43f

4 files changed

Lines changed: 72 additions & 4 deletions

File tree

.github/workflows/swift.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Swift Build and Test
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
macos-build:
8+
name: Build and Test on macOS
9+
runs-on: macos-15
10+
steps:
11+
- name: Select Xcode 16.3
12+
run: |
13+
XCODE_PATH=$(ls -d /Applications/Xcode_16.3*.app | head -n 1)
14+
echo "Using Xcode at $XCODE_PATH"
15+
sudo xcode-select -s "$XCODE_PATH/Contents/Developer"
16+
xcodebuild -version
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: true
20+
- name: Build
21+
run: swift build --package-path Core
22+
- name: Test
23+
run: swift test --package-path Core
24+
25+
xcodebuild-test:
26+
name: Xcodebuild test on macOS
27+
runs-on: macos-15
28+
steps:
29+
- name: Select Xcode 16.3
30+
run: |
31+
XCODE_PATH=$(ls -d /Applications/Xcode_16.3*.app | head -n 1)
32+
echo "Using Xcode at $XCODE_PATH"
33+
sudo xcode-select -s "$XCODE_PATH/Contents/Developer"
34+
xcodebuild -version
35+
- uses: actions/checkout@v4
36+
with:
37+
submodules: true
38+
- name: Verify xcodebuild installation
39+
run: xcodebuild -version
40+
- name: List available schemes
41+
run: xcodebuild -project azooKeyMac.xcodeproj -list
42+
- name: Test building azooKeyMac (Release configuration)
43+
run: |
44+
xcodebuild \
45+
-project azooKeyMac.xcodeproj \
46+
-scheme azooKeyMac \
47+
-configuration Release \
48+
-destination 'generic/platform=macOS' \
49+
CODE_SIGNING_ALLOWED=NO \
50+
CODE_SIGNING_REQUIRED=NO \
51+
CODE_SIGN_IDENTITY=""
52+
53+
swiftlint:
54+
name: SwiftLint
55+
runs-on: macos-15
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
submodules: true
60+
- name: Install SwiftLint
61+
run: |
62+
brew update
63+
brew install swiftlint
64+
- name: Check SwiftLint version
65+
run: swiftlint version
66+
- name: Run SwiftLint
67+
run: |
68+
swiftlint --fix --format
69+
swiftlint --quiet --strict
70+

azooKeyMac.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@
420420
SDKROOT = macosx;
421421
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
422422
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
423-
SYMROOT = build;
424423
};
425424
name = Debug;
426425
};
@@ -478,7 +477,6 @@
478477
SDKROOT = macosx;
479478
SWIFT_COMPILATION_MODE = wholemodule;
480479
SWIFT_OPTIMIZATION_LEVEL = "-O";
481-
SYMROOT = build;
482480
};
483481
name = Release;
484482
};

azooKeyMac/Extensions/KeychainHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ enum KeychainHelper {
3333
let status = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)
3434

3535
if status == errSecSuccess, let data = dataTypeRef as? Data {
36-
return String(decoding: data, as: UTF8.self)
36+
return String(bytes: data, encoding: .utf8)
3737
}
3838

3939
return nil

azooKeyMac/InputController/OpenAIClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ enum OpenAIClient {
271271
}
272272

273273
guard httpResponse.statusCode == 200 else {
274-
let responseBody = String(decoding: data, as: UTF8.self)
274+
let responseBody = String(bytes: data, encoding: .utf8) ?? "Body is not encoded in UTF-8"
275275
throw OpenAIError.invalidResponseStatus(code: httpResponse.statusCode, body: responseBody)
276276
}
277277

0 commit comments

Comments
 (0)