-
Notifications
You must be signed in to change notification settings - Fork 26
393 lines (375 loc) · 15.9 KB
/
Copy pathtests.yaml
File metadata and controls
393 lines (375 loc) · 15.9 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
name: Tests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
pull_request:
env:
NSUnbufferedIO: YES
jobs:
Preflight:
name: Preflight Checks
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
outputs:
is_master_or_tagged: ${{ steps.check_master.outputs.is_master_or_tagged }}
is_master: ${{ steps.check_master.outputs.is_master }}
is_draft: ${{ steps.check_draft_status.outputs.is_draft }}
tag_name: ${{ steps.check_master.outputs.tag_name }}
changed_files: ${{ steps.list_changed_files.outputs.changed_files }}
has_duplicates: ${{ steps.report_summary.outputs.has_duplicates }}
duplicate_files: ${{ steps.list_changed_files.outputs.duplicate_paths_list }}
has_source_changes: ${{ steps.check_source_changes.outputs.has_source_changes }}
has_documentation_changes: ${{ steps.check_documentation_changes.outputs.has_documentation_changes }}
has_secrets: ${{ steps.check_secrets.outputs.has_secrets }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for Merge into Master or Release Tag
id: check_master
run: |
github_ref="${{ github.ref }}"
tag_name=${github_ref#refs/tags/}
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "is_master_or_tagged=true" >> $GITHUB_OUTPUT
echo "is_master=true" >> $GITHUB_OUTPUT
elif [[ "${github_ref}" == refs/tags/* ]]; then
echo "is_master_or_tagged=true" >> $GITHUB_OUTPUT
echo "tag_name=${tag_name}" >> $GITHUB_OUTPUT
fi
- name: Check if the PR is a draft
id: check_draft_status
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft }}
shell: bash
run: |
echo "is_draft=true" >> $GITHUB_OUTPUT
- name: List Changed Files
id: list_changed_files
run: |
COMMITS_RANGE=""
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# For Pull Requests: Compare the HEAD of the PR branch with its base branch.
COMMITS_RANGE="${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
elif [[ "${{ github.event_name }}" == "push" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then
# For standard Push events, compare the current commit with the commit before the push.
COMMITS_RANGE="${{ github.event.before }}..${{ github.sha }}"
fi
if [[ -z "$COMMITS_RANGE" ]]; then
# If no commit range was identified from the github events, get a list of all changes
git ls-tree -r HEAD --name-only > changes
elif ! git diff --name-only "$COMMITS_RANGE" > changes; then
# If diffing the commit range failed (e.g. due to a force push or rebased branch), fall back to listing all changes
git ls-tree -r HEAD --name-only > changes
fi
{
echo 'changed_files<<EOF'
cat changes
echo EOF
} >> $GITHUB_OUTPUT
- name: Check for Source Changes
id: check_source_changes
run: |
if grep -qE '^(Sources/|Tests/|Package|\w+\.podspec)' changes; then
echo "has_source_changes=true" >> $GITHUB_OUTPUT
fi
- name: Check for Documentation Changes
id: check_documentation_changes
run: |
if grep -qE '^(Sources/.*\.(md|swift)|.github/workflows/documentation.yaml)' changes; then
echo "has_documentation_changes=true" >> $GITHUB_OUTPUT
fi
- name: Check for Integration Test Secrets
id: check_secrets
env:
TEST_CONFIGURATION: ${{ secrets.TEST_CONFIGURATION }}
TEST_OKTA_PLIST: ${{ secrets.TEST_OKTA_PLIST }}
run: |
if [[ -n "$TEST_CONFIGURATION" ]] && [[ -n "$TEST_OKTA_PLIST" ]]; then
echo "has_secrets=true" >> $GITHUB_OUTPUT
fi
- name: Report preflight check summary
id: report_summary
env:
is_master: ${{ steps.check_master.outputs.is_master }}
is_draft: ${{ steps.check_draft_status.outputs.is_draft }}
tag_name: ${{ steps.check_master.outputs.tag_name }}
changed_files: ${{ steps.list_changed_files.outputs.changed_files }}
has_source_changes: ${{ steps.check_source_changes.outputs.has_source_changes }}
has_documentation_changes: ${{ steps.check_documentation_changes.outputs.has_documentation_changes }}
has_secrets: ${{ steps.check_secrets.outputs.has_secrets }}
run: |
if [[ "$is_draft" == "true" ]]; then
echo "Is a draft PR"
export draft_status=":white_check_mark:"
fi
if [[ "$is_master" == "true" ]]; then
echo "Is committed to master"
export master_status=":white_check_mark:"
fi
if [[ -n "$tag_name" ]]; then
echo "Pushed tag \`$tag_name\`"
export tag_status=":white_check_mark: \`$tag_name\`"
fi
if [[ "$has_source_changes" == "true" ]]; then
echo "Has source changes"
export source_status=":white_check_mark:"
fi
if [[ "$has_documentation_changes" == "true" ]]; then
echo "Has documentation changes"
export doc_status=":white_check_mark:"
fi
if [[ "$has_secrets" == "true" ]]; then
echo "Has secrets available"
export secrets_status=":white_check_mark:"
fi
cat <<__EOF__ >> $GITHUB_STEP_SUMMARY
## Preflight Status Checks
| Preflight Check | Enabled |
| --- | --- |
| Is a draft PR | ${draft_status} |
| Merged to \`master\` | ${master_status} |
| Commit tagged | ${tag_status} |
| Changed files | $(cat changes | wc -l) files changed |
| Has source changes | ${source_status} |
| Documentation rebuild needed | ${doc_status} |
| Has integration test secrets | ${secrets_status} |
__EOF__
./.github/workflows/preflight-check_duplicate_files.sh Sources
- name: Upload Preflight Artifacts
uses: actions/upload-artifact@v4
with:
name: changes
path: changes
SwiftLint:
name: Lint Sources
needs: Preflight
if: ${{ needs.Preflight.outputs.has_source_changes == 'true' }}
runs-on: macos-15
steps:
- uses: actions/checkout@v2
- name: Setup Swift Lint
run: |
if ! which -s swiftlint; then
echo "Installing SwiftLint..."
brew install swiftlint
fi
- name: Lint code
run: |
swiftlint lint --reporter github-actions-logging Sources
SwiftBuild:
name: Swift ${{ matrix.swift_version }} on ${{ matrix.os }}
needs: SwiftLint
if: ${{ !github.event.pull_request.draft && needs.Preflight.outputs.has_source_changes == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- swift_version: "5.10"
os: macos-15
- swift_version: "6.0"
os: macos-15
- swift_version: "6.1"
os: macos-15
- swift_version: "6.2"
os: macos-15
- swift_version: "6.0"
os: ubuntu-latest
env:
LOG_NAME: "${{github.job}}-${{ matrix.swift_version }}-${{ matrix.os }}"
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-swift
with:
swift-version: "${{ matrix.swift_version }}"
- name: Build
run: swift build --build-tests $SWIFT_ARGUMENTS
- name: Test
run: swift test $SWIFT_ARGUMENTS --skip-build --sanitize=thread
Cocoapods:
name: CocoaPods Build
needs:
- SwiftBuild
- XcodeBuild
if: ${{ !github.event.pull_request.draft && needs.Preflight.outputs.has_source_changes == 'true' }}
runs-on: macos-15
strategy:
matrix:
platform: [iOS, tvOS, watchOS, macOS, visionOS]
env:
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@master
- name: Lint Podspec
run: pod lib lint OktaClient.podspec --include-podspecs="**.podspec" --allow-warnings --verbose --platforms=${{ matrix.platform }}
XcodeBuild:
name: Xcode ${{ matrix.xcode_version }} on ${{ matrix.destination }}
needs:
- SwiftBuild
- Documentation
if: ${{ !github.event.pull_request.draft && needs.Preflight.outputs.has_source_changes == 'true' }}
strategy:
matrix:
include:
- destination: "platform=iOS Simulator,OS=18.6,name=iPhone 16 Pro Max"
xcode_version: "16.4"
os: macos-15
- destination: "platform=tvOS Simulator,OS=18.5,name=Apple TV"
xcode_version: "16.4"
os: macos-15
- destination: "platform=visionOS Simulator,OS=2.5,name=Apple Vision Pro"
xcode_version: "16.4"
os: macos-15
- destination: "platform=watchOS Simulator,OS=11.5,name=Apple Watch Series 10 (46mm)"
xcode_version: "16.4"
os: macos-15
- destination: "platform=macOS,name=My Mac"
xcode_version: "16.4"
os: macos-15
- destination: "platform=macOS,name=My Mac"
xcode_version: "26.0"
os: macos-15
runs-on: ${{ matrix.os }}
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer
DESTINATION: "${{ matrix.destination }}"
LOG_NAME: "${{github.job}}-${{ matrix.xcode_version }}-${{ matrix.destination }}"
timeout-minutes: 25
steps:
- uses: actions/checkout@master
- name: Setup test environment
run: xcrun simctl shutdown all
- name: Setup environment
run: |
mkdir -p .build/ci-logs
XCODE_MAJOR_VERSION=$(echo "${{ matrix.xcode_version }}" | cut -d'.' -f1)
if [[ "$XCODE_MAJOR_VERSION" -lt 16 ]]; then
echo "Xcode version is < 16. Filtering noisy warnings from xcbeautify output."
echo "XCBEAUTIFY_ARGS=--renderer github-actions --quieter --disable-logging" >> $GITHUB_ENV
else
echo "XCBEAUTIFY_ARGS=--renderer github-actions --disable-logging" >> $GITHUB_ENV
fi
- name: Build AuthFoundation
run: |
set -o pipefail && xcrun xcodebuild build-for-testing \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme AuthFoundation \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Test AuthFoundation
run: |
set -o pipefail && xcrun xcodebuild test-without-building \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme AuthFoundation \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Build OktaDirectAuth
run: |
set -o pipefail && xcrun xcodebuild build-for-testing \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OktaDirectAuth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Test OktaDirectAuth
run: |
set -o pipefail && xcrun xcodebuild test-without-building \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OktaDirectAuth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Build OAuth2Auth
run: |
set -o pipefail && xcrun xcodebuild build-for-testing \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OAuth2Auth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Build OktaIdxAuth
run: |
set -o pipefail && xcrun xcodebuild build-for-testing \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OktaIdxAuth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Test OktaIdxAuth
run: |
set -o pipefail && xcrun xcodebuild test-without-building \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OktaIdxAuth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Test OAuth2Auth
run: |
set -o pipefail && xcrun xcodebuild test-without-building \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme OAuth2Auth \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Build BrowserSignin
if: "!contains(matrix.destination, 'tvOS') && !contains(matrix.destination, 'watchOS')"
run: |
set -o pipefail && xcrun xcodebuild build-for-testing \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme BrowserSignin \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Test BrowserSignin
if: "!contains(matrix.destination, 'tvOS') && !contains(matrix.destination, 'watchOS')"
run: |
set -o pipefail && xcrun xcodebuild test-without-building \
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \
-derivedDataPath .build/DerivedData \
-clonedSourcePackagesDirPath .build/ClonedSources \
-scheme BrowserSignin \
-destination "$DESTINATION" 2>&1 | tee -a ".build/ci-logs/${LOG_NAME}.log" | xcbeautify $XCBEAUTIFY_ARGS
- name: Upload Logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: Logs-${{ env.LOG_NAME }}
path: |
.build/ci-logs/**
.build/DerivedData/Logs/
Documentation:
name: Build Documentation Archives
needs: SwiftLint
if: ${{ !github.event.pull_request.draft && needs.Preflight.outputs.has_documentation_changes == 'true' }}
runs-on: macos-15
env:
DOCC_JSON_PRETTYPRINT: YES
DEVELOPER_DIR: /Applications/Xcode_16.4.app/Contents/Developer
DESTINATION: "${{ matrix.destination }}"
LOG_NAME: "${{github.job}}-${{ matrix.xcode_version }}-${{ matrix.destination }}"
NSUnbufferedIO: YES
steps:
- uses: actions/checkout@master
- name: Swift Package Documentation lint
run: |
mkdir -p ~/Build/Docs
TARGET_LIST=""
for TARGET in $(swift package describe --type json | jq ".products[].name" | sed -e 's/"//g'); do
NAME=$(echo "$TARGET" | tr '[:upper:]' '[:lower:]')
TARGET_LIST="$TARGET_LIST --target $TARGET"
done
swift package --allow-writing-to-directory ~/Build/Docs generate-documentation \
--disable-indexing \
--output-path ~/Build/Docs \
--include-extended-types \
--symbol-graph-minimum-access-level public \
--experimental-skip-synthesized-symbols \
--enable-experimental-combined-documentation \
--enable-experimental-mentioned-in \
--enable-experimental-external-link-support \
--enable-experimental-overloaded-symbol-presentation \
--analyze \
--emit-fixits \
$TARGET_LIST | ./.github/workflows/swift-log-renderer.sh