-
Notifications
You must be signed in to change notification settings - Fork 431
258 lines (223 loc) · 9.34 KB
/
ci.yml
File metadata and controls
258 lines (223 loc) · 9.34 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: CI
permissions:
contents: read
pull-requests: write
on:
pull_request:
push:
branches:
- main
env:
DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer
FASTLANE_SKIP_UPDATE_CHECK: true
FASTLANE_XCODE_LIST_TIMEOUT: 80
FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 80
HOMEBREW_NO_INSTALL_CLEANUP: TRUE
BUNDLE_PATH: vendor/bundle
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
with:
ruby-version: "3.1"
bundler-cache: true
- name: YamlLint
run: yamllint --strict --format github .
- name: RuboCop
run: bundle exec rubocop --format github
- name: SwiftLint
run: |
docker run --rm -v `pwd`:`pwd` -w `pwd` \
ghcr.io/realm/swiftlint:0.54.0 \
swiftlint lint --strict --config .swiftlint.yml --reporter github-actions-logging
- name: SwiftFormat
run: |
docker run --rm -v `pwd`:`pwd` -w `pwd` \
ghcr.io/nicklockwood/swiftformat:0.53.1 \
--lint --config .swiftformat .
check-swiftlint-disables:
needs: lint
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Fetch all history for proper git diff
- name: Scan for `swiftlint:disable` in PR diff
id: scan
continue-on-error: false
run: |
git fetch origin main:refs/remotes/origin/main
DISABLE_LINES=$(git diff origin/main -- '*.swift' | grep -E '^\+.*// swiftlint:disable' || true)
echo "disable_lines<<EOF" >> $GITHUB_OUTPUT
echo "$DISABLE_LINES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Comment on PR if `swiftlint:disable` is found
if: steps.scan.outputs.disable_lines != '' && github.event.pull_request.head.repo.full_name == github.repository
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: swiftlint-disable-check
message: |
⚠️ **SwiftLint disabled in this PR**
The following added lines contain `// swiftlint:disable`. Please verify this is necessary.
check-unused-strings:
needs: lint
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0 # Fetch all history for comparison with main branch
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v5.3.0
with:
python-version: '3.x'
- name: Detect unused L10n strings
id: detect
continue-on-error: true
run: |
OUTPUT=$(python3 Tools/detect_unused_strings.py 2>&1 || true)
echo "output<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Check if any unused strings were found
if echo "$OUTPUT" | grep -q "Total unused:"; then
COUNT=$(echo "$OUTPUT" | grep "Total unused:" | grep -oE '[0-9]+')
echo "has_unused=true" >> $GITHUB_OUTPUT
echo "count=$COUNT" >> $GITHUB_OUTPUT
else
echo "has_unused=false" >> $GITHUB_OUTPUT
echo "count=0" >> $GITHUB_OUTPUT
fi
- name: Comment on PR if unused strings are found
if: |
steps.detect.outputs.has_unused == 'true' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: unused-strings-check
message: |
⚠️ **Unused L10n strings detected**
Found **${{ steps.detect.outputs.count }}** unused localization strings in the codebase.
<details>
<summary>Click to see details</summary>
```
${{ steps.detect.outputs.output }}
```
</details>
To clean up these strings, manually remove them from the `Localizable.strings` files
and regenerate `Strings.swift` using SwiftGen.
test:
needs: check-swiftlint-disables
runs-on: macos-15
timeout-minutes: 45
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
name: "Cache: Pods"
id: cache_pods
with:
path: |
Pods
Tools/MaterialDesignIcons.ttf
Tools/MaterialDesignIcons.json
key: >-
${{ runner.os }}-pods-${{ env.DEVELOPER_DIR }}-
${{ hashFiles('**/Gemfile.lock', '**/Podfile.lock', 'Tools/BuildMaterialDesignIconsFont.sh') }}
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
name: "Cache: Gems"
id: cache_gems
with:
path: vendor/bundle
key: >-
${{ runner.os }}-gems-${{ env.ImageVersion }}-${{ env.DEVELOPER_DIR }}-${{ hashFiles('**/Gemfile.lock') }}
- name: Install Brews
# right now, we don't need anything from brew for tests, so save some time
if: ${{ false }}
run: brew bundle
- name: Install Gems
if: steps.cache_gems.outputs.cache-hit != 'true'
run: bundle install --jobs 4 --retry 3
- name: Install Pods Release
if: steps.cache_pods.outputs.cache-hit != 'true'
run: bundle exec pod install --repo-update
- name: Run tests
run: bundle exec fastlane test
- uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
name: "Upload Code Coverage"
with:
xcode: true
xcode_archive_path: fastlane/test_output/Tests-Unit.xcresult
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
name: "Upload Test Logs"
if: ${{ always() }}
with:
name: test-logs
path: |
~/Library/Logs/DiagnosticReports
~/Library/Developer/Xcode/DerivedData/HomeAssistant-*/Logs/Test
~/Library/Logs/scan
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
name: "Upload Simulator App"
with:
name: ios-simulator
path: ~/Library/Developer/Xcode/DerivedData/HomeAssistant-*/Build/Products/Debug-iphonesimulator/*.app
size:
needs: check-swiftlint-disables
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == 'home-assistant/iOS'
runs-on: macos-15
timeout-minutes: 45
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4.6.2
name: "Cache: Pods"
id: cache_pods
with:
path: |
Pods
Tools/MaterialDesignIcons.ttf
Tools/MaterialDesignIcons.json
key: >-
${{ runner.os }}-pods-${{ env.DEVELOPER_DIR }}-
${{ hashFiles('**/Gemfile.lock', '**/Podfile.lock', 'Tools/BuildMaterialDesignIconsFont.sh') }}
- uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
name: "Cache: Gems"
id: cache_gems
with:
path: vendor/bundle
key: >-
${{ runner.os }}-gems-${{ env.ImageVersion }}-${{ env.DEVELOPER_DIR }}-${{ hashFiles('**/Gemfile.lock') }}
- name: Install Brews
# right now, we don't need anything from brew for sizing, so save some time
if: ${{ false }}
run: brew bundle
- name: Install Gems
if: steps.cache_gems.outputs.cache-hit != 'true'
run: bundle install --jobs 4 --retry 3
- name: Install Pods Release
if: steps.cache_pods.outputs.cache-hit != 'true'
run: bundle exec pod install --repo-update
- name: Build app
run: bundle exec fastlane ios size
env:
P12_KEY_DISTRIBUTION: ${{ secrets.P12_KEY_DISTRIBUTION }}
P12_VALUE_DISTRIBUTION: ${{ secrets.P12_VALUE_DISTRIBUTION }}
P12_KEY_MAC_DEVELOPER_ID: ${{ secrets.P12_KEY_MAC_DEVELOPER_ID }}
P12_KEY_MAC_DEVELOPER_INSTALLER: ${{ secrets.P12_KEY_MAC_DEVELOPER_INSTALLER }}
P12_VALUE_MAC_DEVELOPER_ID: ${{ secrets.P12_VALUE_MAC_DEVELOPER_ID }}
P12_VALUE_MAC_DEVELOPER_INSTALLER: ${{ secrets.P12_VALUE_MAC_DEVELOPER_INSTALLER }}
EMERGE_API_TOKEN: ${{ secrets.EMERGE_API_TOKEN }}
EMERGE_REPO_NAME: ${{ github.repository }}
EMERGE_PR_NUMBER: ${{ github.event.number }}
EMERGE_SHA: ${{ github.event.pull_request.head.sha }}
EMERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
HOMEASSISTANT_APP_STORE_CONNECT_PASSWORD: ${{ secrets.HOMEASSISTANT_APP_STORE_CONNECT_PASSWORD }}
HOMEASSISTANT_APPLE_ID: ${{ secrets.HOMEASSISTANT_APPLE_ID }}
HOMEASSISTANT_FASTLANE_SESSION: ${{ secrets.HOMEASSISTANT_FASTLANE_SESSION }}