generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 18
199 lines (190 loc) · 7.54 KB
/
build-and-test.yml
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
#
# This source file is part of the Stanford Spezi open source project
#
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md)
#
# SPDX-License-Identifier: MIT
#
name: Build and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
buildandtest_ios:
name: Build and Test Swift Package iOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
artifactname: SpeziLLM-iOS.xcresult
resultBundle: SpeziLLM-iOS.xcresult
- buildConfig: Release
artifactname: SpeziLLM-iOS-Release.xcresult
resultBundle: SpeziLLM-iOS-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziLLM-Package
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
buildandtest_visionos:
name: Build and Test Swift Package visionOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
artifactname: SpeziLLM-visionOS.xcresult
resultBundle: SpeziLLM-visionOS.xcresult
- buildConfig: Release
artifactname: SpeziLLM-visionOS-Release.xcresult
resultBundle: SpeziLLM-visionOS-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziLLM-Package
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
buildandtest_macos:
name: Build and Test Swift Package macOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
artifactname: SpeziLLM-macOS.xcresult
resultBundle: SpeziLLM-macOS.xcresult
- buildConfig: Release
artifactname: SpeziLLM-macOS-Release.xcresult
resultBundle: SpeziLLM-macOS-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
scheme: SpeziLLM-Package
destination: 'platform=macOS,arch=arm64'
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
buildandtestuitests_ios:
name: Build and Test UI Tests iOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
resultBundle: TestApp-iOS.xcresult
artifactname: TestApp-iOS.xcresult
- buildConfig: Release
resultBundle: TestApp-iOS-Release.xcresult
artifactname: TestApp-iOS-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
buildandtestuitests_ipad:
name: Build and Test UI Tests iPadOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
resultBundle: TestApp-iPad.xcresult
artifactname: TestApp-iPad.xcresult
- buildConfig: Release
resultBundle: TestApp-iPad-Release.xcresult
artifactname: TestApp-iPad-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=iOS Simulator,name=iPad Air 11-inch (M2)'
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
buildandtestuitests_visionos:
name: Build and Test UI Tests visionOS
uses: StanfordSpezi/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2
strategy:
matrix:
include:
- buildConfig: Debug
resultBundle: TestApp-visionOS.xcresult
artifactname: TestApp-visionOS.xcresult
- buildConfig: Release
resultBundle: TestApp-visionOS-Release.xcresult
artifactname: TestApp-visionOS-Release.xcresult
with:
runsonlabels: '["macOS", "self-hosted"]'
path: 'Tests/UITests'
scheme: TestApp
destination: 'platform=visionOS Simulator,name=Apple Vision Pro'
buildConfig: ${{ matrix.buildConfig }}
resultBundle: ${{ matrix.resultBundle }}
artifactname: ${{ matrix.artifactname }}
uploadcoveragereport:
name: Upload Coverage Report
needs: [buildandtest_ios, buildandtest_visionos, buildandtest_macos, buildandtestuitests_ios, buildandtestuitests_ipad, buildandtestuitests_visionos]
uses: StanfordSpezi/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
with:
coveragereports: 'SpeziLLM-iOS.xcresult SpeziLLM-visionOS.xcresult SpeziLLM-macOS.xcresult TestApp-iOS.xcresult TestApp-iPad.xcresult TestApp-visionOS.xcresult'
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
buildandtest_fognode:
name: Build and Test Fog Node
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Docker Compose
uses: docker/setup-buildx-action@v2
- name: Build and Start Docker Services
run: |
cd FogNode
docker compose -f docker-compose.dev.yml up --build -d
- name: Wait for Services to Start
run: |
cd FogNode
MAX_WAIT=30
WAIT_TIME=0
while [ "$(docker compose -f docker-compose.dev.yml ps --filter "status=running" | grep -c "Up")" -lt 4 ]; do
if [ $WAIT_TIME -ge $MAX_WAIT ]; then
echo "Timeout: Not all services are up after $MAX_WAIT seconds."
docker compose -f docker-compose.dev.yml ps
exit 1
fi
echo "Waiting for services to start... ($WAIT_TIME seconds elapsed)"
docker logs fognode-auth-service-1
sleep 1
WAIT_TIME=$((WAIT_TIME + 1))
done
echo "All services are up and running!"
- name: Verify Container Status
run: |
cd FogNode
# Check for problematic containers
EXITED_COUNT=$(docker compose -f docker-compose.dev.yml ps --filter "status=exited" -q | wc -l)
RESTARTING_COUNT=$(docker compose -f docker-compose.dev.yml ps --filter "status=restarting" -q | wc -l)
DEAD_COUNT=$(docker compose -f docker-compose.dev.yml ps --filter "status=dead" -q | wc -l)
# Log current counts for visibility
echo "Exited Containers: $EXITED_COUNT"
echo "Restarting Containers: $RESTARTING_COUNT"
echo "Dead Containers: $DEAD_COUNT"
# Fail if any problematic containers are detected
if [ "$EXITED_COUNT" -gt 0 ] || [ "$RESTARTING_COUNT" -gt 0 ] || [ "$DEAD_COUNT" -gt 0 ]; then
echo "Error: One or more containers are in a problematic state (exited, restarting, or dead)."
docker compose -f docker-compose.dev.yml logs
exit 1
fi
echo "All containers are running as expected."
- name: Stop and Remove Containers
if: always()
run: |
cd FogNode
docker compose -f docker-compose.dev.yml down --remove-orphans