-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (148 loc) · 5.96 KB
/
Copy pathci.yml
File metadata and controls
164 lines (148 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: ci
# Runs on every PR (any base) and on every push to dev/main.
# Skips draft PRs to save macOS minutes.
on:
pull_request:
branches: [dev, main]
push:
branches: [dev, main]
# Cancel old runs if a new commit lands on the same branch.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-test:
name: Build & test
runs-on: macos-15
if: github.event.pull_request.draft == false || github.event_name == 'push'
env:
# Pin Xcode so build behavior is reproducible.
# Bump when you upgrade local Xcode and want CI to follow.
XCODE_VERSION: "26.0"
SCHEME: "Savely"
DESTINATION: "platform=iOS Simulator,name=iPhone 16 Pro"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Select Xcode ${{ env.XCODE_VERSION }}
run: |
# If the requested version isn't installed on the runner,
# this will fail loudly — pick a version that's available.
# See: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
sudo xcode-select -s "/Applications/Xcode_${XCODE_VERSION}.app" || \
sudo xcode-select -s "/Applications/Xcode.app"
xcodebuild -version
- name: Cache SPM packages
uses: actions/cache@v5
with:
path: |
~/Library/Developer/Xcode/DerivedData/**/SourcePackages
~/Library/Caches/org.swift.swiftpm
key: spm-${{ runner.os }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
spm-${{ runner.os }}-
- name: Install SwiftLint
run: |
brew install swiftlint
swiftlint version
- name: SwiftLint
# No --strict: warnings annotate inline but don't fail the build.
# Only error-severity violations (force_cast, force_try, custom errors)
# block the merge. The "ratchet" comment in .swiftlint.yml explains
# how to tighten this over time.
run: swiftlint lint --reporter github-actions-logging
- name: Generate placeholder secrets
# Both Config.plist (OpenAI) and GoogleService-Info.plist (Firebase)
# are gitignored locally, but the Xcode project lists them as
# required build inputs. xcodebuild fails on a fresh checkout if
# either is absent. CI never calls OpenAI or initializes Firebase
# (FirebaseApp.configure() runs from AppDelegate at app launch,
# and we skip the UI test bundle that would launch the app), so
# placeholders with the right shape are sufficient.
run: |
cat > Savely/Config.plist <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OPENAI_API_KEY</key>
<string>ci-placeholder-not-a-real-key</string>
</dict>
</plist>
PLIST
cat > Savely/GoogleService-Info.plist <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSy_ci_placeholder_not_a_real_key</string>
<key>GCM_SENDER_ID</key>
<string>000000000000</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>IvanLB.Savely</string>
<key>PROJECT_ID</key>
<string>savely-ci-placeholder</string>
<key>STORAGE_BUCKET</key>
<string>savely-ci-placeholder.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false/>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<key>IS_APPINVITE_ENABLED</key>
<true/>
<key>IS_GCM_ENABLED</key>
<true/>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:000000000000:ios:0000000000000000000000</string>
</dict>
</plist>
PLIST
- name: Resolve SPM packages
run: |
xcodebuild \
-project Savely.xcodeproj \
-scheme "$SCHEME" \
-resolvePackageDependencies
- name: Build
run: |
set -o pipefail
xcodebuild build \
-project Savely.xcodeproj \
-scheme "$SCHEME" \
-configuration Debug \
-destination "$DESTINATION" \
CODE_SIGNING_ALLOWED=NO \
| xcbeautify --renderer github-actions
- name: Test
# Skip the SavelyUITests bundle on CI. The Xcode template ships
# SavelyUITestsLaunchTests with XCTApplicationLaunchMetric, which
# runs the app launch ~8 times measuring performance — that takes
# ~5–10 min and flakes on shared runners (one slow iteration blows
# the std-dev threshold and the whole bundle fails). The template
# tests cover no real behavior.
#
# Compilation of SavelyUITests is still verified by the Build step,
# so we still catch breakages. When qa-tester writes real UI tests,
# remove the -skip-testing flag.
run: |
set -o pipefail
xcodebuild test \
-project Savely.xcodeproj \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-skip-testing:SavelyUITests \
-resultBundlePath build/TestResults.xcresult \
CODE_SIGNING_ALLOWED=NO \
| xcbeautify --renderer github-actions
- name: Upload xcresult on failure
if: failure()
uses: actions/upload-artifact@v7
with:
name: TestResults-${{ github.run_id }}
path: build/TestResults.xcresult
retention-days: 7