-
-
Notifications
You must be signed in to change notification settings - Fork 67
228 lines (196 loc) · 7.48 KB
/
Copy pathci.yml
File metadata and controls
228 lines (196 loc) · 7.48 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
name: CI/CD Pipeline
on:
push:
branches: [ "main", "develop" ]
paths-ignore:
- 'README.md'
- 'Scripts/**'
- '.github/assets/**'
- 'LICENSE'
- '.gitignore'
- '**/*.md'
pull_request:
branches: [ "main" ]
paths-ignore:
- 'README.md'
- 'Scripts/**'
- '.github/assets/**'
- 'LICENSE'
- '.gitignore'
- '**/*.md'
workflow_dispatch:
env:
XCODE_VERSION: '26.2'
SCHEME: 'Petrichor'
PROJECT: 'Petrichor.xcodeproj'
jobs:
# Job 1: Code Quality & Linting
lint:
name: Swift Lint & Format Check
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
- name: Cache SwiftLint
uses: actions/cache@v4
with:
path: ~/Library/Caches/Homebrew/swiftlint*
key: ${{ runner.os }}-swiftlint-0.54.0
restore-keys: |
${{ runner.os }}-swiftlint-
- name: Install SwiftLint
run: |
if ! command -v swiftlint &> /dev/null; then
brew install swiftlint
else
echo "SwiftLint already installed: $(swiftlint version)"
fi
- name: Run SwiftLint
run: |
# Create default config if not exists
if [ ! -f .swiftlint.yml ]; then
echo "warning: .swiftlint.yml not found, using default configuration"
fi
# Ensure Xcode is properly selected for SourceKit
export DEVELOPER_DIR="/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer"
# Run SwiftLint with GitHub Actions reporter
# Try with SourceKit first, fall back to without if it fails
if ! swiftlint lint --reporter github-actions-logging; then
echo "::warning::SwiftLint with SourceKit failed, running without analyzer rules"
swiftlint lint --reporter github-actions-logging --disable-source-kit || true
fi
continue-on-error: true
- name: SwiftLint Report
if: always()
run: |
# Generate HTML report for artifacts
swiftlint lint --reporter html > swiftlint-report.html || true
# Also generate JSON for potential future processing
swiftlint lint --reporter json > swiftlint-report.json || true
- name: Upload Lint Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: lint-reports
path: |
swiftlint-report.html
swiftlint-report.json
retention-days: 5
# Job 2: Build and Analyze
build-analyze:
name: Build & Static Analysis
runs-on: macos-26
needs: lint
strategy:
matrix:
configuration: [Debug, Release]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
- name: Cache Swift Package Manager
uses: actions/cache@v4
with:
path: |
~/Library/Developer/Xcode/DerivedData/**/SourcePackages/checkouts
~/Library/Developer/Xcode/DerivedData/**/SourcePackages/repositories
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Cache Derived Data
uses: actions/cache@v4
with:
path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-derived-data-${{ matrix.configuration }}-${{ hashFiles('**/*.swift') }}
restore-keys: |
${{ runner.os }}-derived-data-${{ matrix.configuration }}-
${{ runner.os }}-derived-data-
- name: Create Secrets Config
run: |
echo "// CI placeholder - scrobbling disabled" > Configuration/Secrets.xcconfig
echo "LASTFM_API_KEY = " >> Configuration/Secrets.xcconfig
echo "LASTFM_SHARED_SECRET = " >> Configuration/Secrets.xcconfig
- name: Resolve Dependencies
run: |
echo "Resolving Swift Package Manager dependencies..."
xcodebuild -resolvePackageDependencies \
-project "${{ env.PROJECT }}" \
-scheme "${{ env.SCHEME }}" \
-clonedSourcePackagesDirPath ~/Library/Developer/Xcode/DerivedData/SPM
- name: Install xcpretty
run: |
if ! gem list xcpretty -i > /dev/null 2>&1; then
gem install xcpretty
fi
- name: Build and Analyze
run: |
set -o pipefail
# Create reports directory
mkdir -p build/reports
# Build and analyze
xcodebuild clean build analyze \
-project "${{ env.PROJECT }}" \
-scheme "${{ env.SCHEME }}" \
-configuration ${{ matrix.configuration }} \
-destination 'platform=macOS' \
-derivedDataPath ~/Library/Developer/Xcode/DerivedData \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_REQUIRED=YES \
ONLY_ACTIVE_ARCH=NO \
COMPILER_INDEX_STORE_ENABLE=YES \
| xcpretty --color --report junit --output build/reports/junit-${{ matrix.configuration }}.xml
# Save exit code
BUILD_STATUS=${PIPESTATUS[0]}
# Check for analyzer warnings
if [ -d ~/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex/*.build ]; then
echo "Checking for analyzer warnings..."
find ~/Library/Developer/Xcode/DerivedData/Build/Intermediates.noindex -name "*.plist" -exec plutil -p {} \; | grep -i warning || true
fi
exit $BUILD_STATUS
- name: Parse Analyzer Results
if: always()
run: |
# Find and parse static analyzer results
echo "Searching for analyzer results..."
find ~/Library/Developer/Xcode/DerivedData -name "StaticAnalyzer" -type d | while read -r dir; do
echo "Found analyzer results in: $dir"
find "$dir" -name "*.plist" -exec echo "Analyzer issue found: " {} \;
done
- name: Upload Build Reports
uses: actions/upload-artifact@v4
if: always()
with:
name: build-reports-${{ matrix.configuration }}
path: build/reports/
retention-days: 5
- name: Upload Build Logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-logs-${{ matrix.configuration }}
path: |
~/Library/Logs/DiagnosticReports/*.crash
~/Library/Developer/Xcode/DerivedData/**/Logs/Build/*.xcactivitylog
retention-days: 5
if-no-files-found: ignore
# Summary job to check all required jobs passed
ci-summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [lint, build-analyze]
if: always()
steps:
- name: Check Job Status
run: |
if [ "${{ needs.lint.result }}" != "success" ] || \
[ "${{ needs.build-analyze.result }}" != "success" ]; then
echo "One or more required jobs failed"
echo "Lint: ${{ needs.lint.result }}"
echo "Build & Analyze: ${{ needs.build-analyze.result }}"
exit 1
else
echo "All required jobs passed successfully! ✅"
fi