-
Notifications
You must be signed in to change notification settings - Fork 1.8k
204 lines (194 loc) · 7.41 KB
/
Copy path_spm.yml
File metadata and controls
204 lines (194 loc) · 7.41 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
name: _spm
permissions:
contents: read
on:
workflow_call:
inputs:
# The target scheme to be tested.
target:
type: string
required: true
# The platforms to build on. Defaults to all.
# To target specific platforms, pass a comma or space separated string of
# platforms.
#
# Examples:
# - build/test only for macOS: `macOS`
# - build/test only for macOS and tvOS: `macOS, tvOS`
platforms:
type: string
required: false
default: "iOS, tvOS, macOS, watchOS, catalyst, visionOS"
# By default, all platforms will be tested (see matrix in `spm` job).
# To build instead of test, pass a comma or space separated string of
# platforms.
#
# Platform options: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
#
# Note: Build-only platforms must be represented in the `platforms` input
# (which defaults to all platforms) in order to take effect.
#
# Examples:
# - build only for macOS: `macOS`
# - build only for macOS and tvOS: `macOS, tvOS`
# - build only for all platforms: `all`
buildonly_platforms:
type: string
required: false
default: ""
# A command to execute before testing.
#
# This is useful for additional set up, like starting an emulator or
# downloading test data.
#
# Example: `FirebaseFunctions/Backend/start.sh synchronous`
setup_command:
type: string
required: false
default: ""
# Whether the job is scheduled. Defaults to false.
is_nightly:
type: boolean
required: false
default: false
# Custom environment variables to inject into the jobs.
# Expected to be a JSON-formatted string.
# Example: '{"FIREBASE_APP_CHECK_BRANCH": "nc/target-split"}'
env_vars:
type: string
required: false
default: "{}"
outputs:
cache_key:
description: "The cache key for the Swift package resolution."
value: ${{ jobs.spm-package-resolved.outputs.cache_key }}
jobs:
spm-package-resolved:
env:
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
runs-on: macos-26
outputs:
cache_key: ${{ steps.generate_cache_key.outputs.cache_key }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Set Custom Environment Variables
run: |
python3 -c '
import os, json
try:
env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}"))
if not isinstance(env_vars, dict):
raise ValueError("env_vars must be a JSON object")
with open(os.environ["GITHUB_ENV"], "a") as f:
for k, v in env_vars.items():
f.write(f"{k}={v}\n")
except json.JSONDecodeError:
print("Warning: env_vars is not valid JSON. Skipping.")
except Exception as e:
print(f"Error setting env vars: {e}")
'
env:
CUSTOM_ENV_VARS: ${{ inputs.env_vars }}
- name: Xcode
run: sudo xcode-select -s /Applications/Xcode_26.4.app/Contents/Developer
- name: Generate Swift Package.resolved
id: swift_package_resolve
run: swift package resolve
- name: Generate cache key
id: generate_cache_key
run: |
cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}"
echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT"
- uses: actions/cache/save@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
id: cache
with:
path: .build
key: ${{ steps.generate_cache_key.outputs.cache_key }}
spm:
# Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
needs: [spm-package-resolved]
env:
FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }}
strategy:
fail-fast: false
matrix:
os: [macos-15, macos-26]
xcode: [Xcode_26.2, Xcode_26.4]
platform: [iOS, tvOS, macOS, watchOS, catalyst, visionOS]
exclude:
- os: macos-15
xcode: Xcode_26.4
- os: macos-26
xcode: Xcode_26.2
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Set Custom Environment Variables
run: |
python3 -c '
import os, json
try:
env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}"))
if not isinstance(env_vars, dict):
raise ValueError("env_vars must be a JSON object")
with open(os.environ["GITHUB_ENV"], "a") as f:
for k, v in env_vars.items():
f.write(f"{k}={v}\n")
except json.JSONDecodeError:
print("Warning: env_vars is not valid JSON. Skipping.")
except Exception as e:
print(f"Error setting env vars: {e}")
'
env:
CUSTOM_ENV_VARS: ${{ inputs.env_vars }}
- uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: .build
key: ${{needs.spm-package-resolved.outputs.cache_key}}
- name: Xcode
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
- name: Install simulators in case they are missing.
if: matrix.platform != 'macOS' && matrix.platform != 'catalyst'
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
with:
timeout_minutes: 15
max_attempts: 5
retry_wait_seconds: 120
continue_on_error: true
command: xcodebuild -downloadPlatform ${{ matrix.platform }}
- name: Run setup command, if needed.
if: inputs.setup_command != ''
run: ${{ inputs.setup_command }}
- name: Initialize xcodebuild
run: scripts/setup_spm_tests.sh
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
if: contains(inputs.platforms, matrix.platform)
env:
FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }}
TARGET: ${{ inputs.target }}
PLATFORM: ${{ matrix.platform }}
with:
timeout_minutes: 15
max_attempts: 3
retry_wait_seconds: 120
command: |
./scripts/build.sh \
"$TARGET" \
"$PLATFORM" \
${{ (contains(inputs.buildonly_platforms, matrix.platform) || contains(inputs.buildonly_platforms, 'all')) && 'spmbuildonly' || 'spm' }}
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: xcodebuild-logs-${{ inputs.target }}-${{ matrix.platform }}-${{ matrix.os }}-${{ matrix.xcode }}
path: xcodebuild-*.log
if-no-files-found: error
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: xcresults-${{ inputs.target }}-${{ matrix.platform }}-${{ matrix.os }}-${{ matrix.xcode }}
path: xcresults/*
# If build did not succeed, then xcresult won't exist. Warn for visibility.
if-no-files-found: warn