Skip to content

Commit 07eff71

Browse files
committed
Update GitHub Actions workflow
1 parent d6f2eab commit 07eff71

7 files changed

Lines changed: 108 additions & 24 deletions

File tree

.github/workflows/main.yml

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
pull_request:
99
workflow_dispatch:
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
skip:
1317
name: Pre-Check & Skip
@@ -27,46 +31,96 @@ jobs:
2731
runs-on: macos-latest
2832

2933
steps:
34+
35+
# 🚦 Prepare & Checkout
36+
3037
- name: Checkout Git
3138
uses: actions/checkout@v6
3239
with:
3340
submodules: recursive
3441

42+
- name: Set up Homebrew
43+
run: brew install mint xcbeautify
3544

36-
# ⚙️ Tools
37-
38-
- name: Install Homebrew
39-
uses: tecolicom/actions-use-homebrew-tools@v1
45+
- name: Cache Mint
46+
id: cache-mint
47+
uses: actions/cache@v5
4048
with:
41-
tools: xcbeautify swiftlint
42-
cache: yes
49+
path: ~/.mint
50+
key: ${{ runner.os }}-mint-${{ hashFiles('Mintfile') }}
51+
restore-keys: ${{ runner.os }}-mint-
52+
53+
# - name: Set up Mint
54+
# run: mint bootstrap
55+
56+
57+
# 💅 Lint
4358

59+
# - name: Run SwiftLint
60+
# run: mint run swiftlint lint --quiet --strict ./source
61+
#
62+
# - name: Run SwiftFormat
63+
# run: mint run swiftformat --lint ./source
4464

45-
# 📦 Cache
65+
66+
# 🐧 SPM
4667

4768
- name: Cache SPM
4869
id: cache-spm
49-
uses: actions/cache@v4
70+
uses: actions/cache@v5
5071
with:
51-
path: .build
52-
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift', 'Package.resolved') }}
72+
path: |
73+
dependency/Swift
74+
dependency/Xcode
75+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.swift', 'Package.resolved', 'Observatory.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}
5376
restore-keys: ${{ runner.os }}-spm-
5477

55-
56-
# 💅 Lint
57-
58-
- name: Run SwiftLint
59-
run: swiftlint lint --quiet --strict # --reporter github-actions-logging
78+
- name: Resolve Swift dependencies
79+
if: steps.cache-spm.outputs.cache-hit != 'true'
80+
run: swift package --scratch-path dependency/Swift resolve
6081

6182

62-
# 🧪 Resolve, Build, Test SPM
83+
# 🛠️ Xcode
6384

64-
- name: Resolve SPM
85+
- name: Resolve Xcode dependencies
6586
if: steps.cache-spm.outputs.cache-hit != 'true'
66-
run: swift package resolve
67-
68-
- name: Build SPM
69-
run: swift build --build-tests
70-
71-
- name: Test SPM
72-
run: swift test 2>&1 | xcbeautify
87+
run: |
88+
xcodebuild \
89+
-workspace "Observatory.xcworkspace" \
90+
-scheme "Observatory" \
91+
-resolvePackageDependencies \
92+
-clonedSourcePackagesDirPath dependency/Xcode
93+
94+
95+
# 🚧 Build
96+
97+
- name: Build Swift tests
98+
run: swift build --build-tests --scratch-path dependency/Swift
99+
100+
- name: Build Xcode tests
101+
run: |
102+
set -o pipefail && xcodebuild clean build-for-testing \
103+
-workspace "Observatory.xcworkspace" \
104+
-scheme "Observatory-Test" \
105+
-destination "platform=macOS,arch=$(uname -m)" \
106+
-disableAutomaticPackageResolution \
107+
-clonedSourcePackagesDirPath "dependency/Xcode" \
108+
| tee "build.log" | xcbeautify
109+
110+
111+
# 🧪 Test
112+
113+
- name: Test Swift
114+
run: set -o pipefail && swift test --scratch-path dependency/Swift 2>&1 | xcbeautify
115+
116+
- name: Test Xcode
117+
env:
118+
ACCESSIBILITY_CONTROL: 0
119+
run: |
120+
set -o pipefail && xcodebuild test \
121+
-workspace "Observatory.xcworkspace" \
122+
-scheme "Observatory-Test" \
123+
-destination "platform=macOS,arch=$(uname -m)" \
124+
-disableAutomaticPackageResolution \
125+
-clonedSourcePackagesDirPath "dependency/Xcode" \
126+
| xcbeautify

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818

1919
# SPM
2020
/.build
21+
/dependency/Swift
22+
/dependency/Xcode

Observatory.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
17FD0872935075E62744FA2B /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
7575
17FD0873935075E62744FA2B /* .swift-format */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".swift-format"; sourceTree = "<group>"; };
7676
17FD0874935075E62744FA2B /* .swiftformat */ = {isa = PBXFileReference; lastKnownFileType = file.swiftformat; path = .swiftformat; sourceTree = "<group>"; };
77+
17FD0875935075E62744FA2B /* main.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = main.yml; sourceTree = "<group>"; };
7778
17FD08D461EB26AE885B82AC /* Entrypoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entrypoint.swift; sourceTree = "<group>"; };
7879
17FD08E9489864D454E503B4 /* Test.Observer.Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Test.Observer.Event.swift; sourceTree = "<group>"; };
7980
17FD0916F82FAC336830F9E0 /* Observer.Notification.Handler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Observer.Notification.Handler.swift; sourceTree = "<group>"; };
@@ -191,6 +192,22 @@
191192
path = Demo;
192193
sourceTree = "<group>";
193194
};
195+
17FD075E9838C94D43A9D2A5 /* .github */ = {
196+
isa = PBXGroup;
197+
children = (
198+
17FD075F9838C94D43A9D2A5 /* workflows */,
199+
);
200+
path = .github;
201+
sourceTree = "<group>";
202+
};
203+
17FD075F9838C94D43A9D2A5 /* workflows */ = {
204+
isa = PBXGroup;
205+
children = (
206+
17FD0875935075E62744FA2B /* main.yml */,
207+
);
208+
path = workflows;
209+
sourceTree = "<group>";
210+
};
194211
17FD0865B2ECB4388EC47754 /* Testing */ = {
195212
isa = PBXGroup;
196213
children = (
@@ -337,6 +354,7 @@
337354
E6D764201CDDBA100071CCB0 = {
338355
isa = PBXGroup;
339356
children = (
357+
17FD075E9838C94D43A9D2A5 /* .github */,
340358
17FD030F7F2C5CA3191B2040 /* accessory */,
341359
E6D7642B1CDDBA100071CCB0 /* product */,
342360
17FD0BB4EDB0784084E6A631 /* source */,

source/Observatory/Test/Observer/Test.Observer.Event.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ internal class AppKitEventObserverSpec: Spec {
141141
internal class CarbonEventObserverSpec: Spec {
142142
override internal class func spec() {
143143
it("can observe events in active state") {
144+
try self.requireAccessibilityControl()
144145
let observer = EventObserver(active: true)
145146
let observation = Observation()
146147

source/Observatory/Test/Observer/Test.Observer.Hotkey.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Quick
77
internal class HotkeyObserverSpec: Spec {
88
override internal class func spec() {
99
it("can observe hotkeys in active state") {
10+
try self.requireAccessibilityControl()
1011
let observer: HotkeyObserver = HotkeyObserver(active: true)
1112
let modifier: CGEventFlags = [.maskCommand, .maskShift]
1213
let fooKey: CGKeyCode = CGKeyCode(KeyboardKey.one.rawValue)

source/Observatory/Test/Shortcut/Test.Shortcut.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal class ShortcutSpec: Spec {
4141
}
4242

4343
it("can add and remove observations") {
44+
try self.requireAccessibilityControl()
4445
let shortcut: Shortcut = Shortcut(KeyboardHotkey(key: .one, modifier: [.commandKey, .shiftKey]))
4546
let observation: Any?
4647
var callbacks: Int = 0
@@ -71,6 +72,7 @@ internal class ShortcutSpec: Spec {
7172
}
7273

7374
it("must post notifications when registered shortcut gets invoked") {
75+
try self.requireAccessibilityControl()
7476
let hotkey = KeyboardHotkey(key: .one, modifier: [.commandKey, .shiftKey])
7577
let shortcut = Shortcut(hotkey)
7678
let center: ShortcutCenter = .default

source/Observatory/Test/Test.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ import Carbon
22
import Foundation
33
import Nimble
44
import Quick
5+
import XCTest
56

67
internal class Spec: QuickSpec {
8+
internal class func requireAccessibilityControl() throws {
9+
if ProcessInfo.processInfo.environment["ACCESSIBILITY_CONTROL"] == "0" {
10+
throw XCTSkip("Skipping tests that require Accessibility Control.")
11+
}
12+
}
713

814
/// This was something cool and used in some other testing, can't remember… Leaving as a reminder.
915
private static func sendHotkeyEvent(identifier: EventHotKeyID) {

0 commit comments

Comments
 (0)