-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (74 loc) · 2.59 KB
/
pr-tests.yml
File metadata and controls
87 lines (74 loc) · 2.59 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
name: Run Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ main ]
permissions:
contents: read
actions: read # needed to look up the artifact download URL
pull-requests: write
jobs:
unit_tests:
name: Unit Tests
runs-on: macos-15
timeout-minutes: 30
env:
DERIVED_DATA_PATH: ${{ github.workspace }}/.derived_data
IPHONE_DEST: "platform=iOS Simulator,name=iPhone 17 Pro,OS=26.2,arch=arm64"
XCODE_VERSION: "26.2"
steps:
- name: Checkout code
uses: actions/checkout@v4
# To find available Xcode versions for current mac runner, see here: https://github.com/actions/runner-images/tree/main/images/macos
- name: Select Xcode Version
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer
- name: Cache SPM dependencies
uses: actions/cache@v4
with:
path: |
${{ env.DERIVED_DATA_PATH }}/SourcePackages
~/Library/Caches/org.swift.swiftpm
key: ${{ runner.os }}-spm-xcode-${{ env.XCODE_VERSION }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-xcode-${{ env.XCODE_VERSION }}-
${{ runner.os }}-spm-
# Uncomment below for debugging
# - name: Show available simulators
# run: xcrun simctl list devices available
- name: Resolve Swift Package dependencies
shell: bash
run: >
xcodebuild
-project Daydream.xcodeproj
-scheme Daydream
-resolvePackageDependencies
-derivedDataPath "${DERIVED_DATA_PATH}"
- name: Set dynamic env
run: |
echo "UNIT_XCRESULT=$RUNNER_TEMP/UnitTests.xcresult" >> "$GITHUB_ENV"
- name: Build and run unit tests
id: unit_tests
continue-on-error: true
run: |
set -o pipefail
xcodebuild test \
-project Daydream.xcodeproj \
-scheme Daydream \
-testPlan unittests \
-destination "${IPHONE_DEST}" \
-configuration Debug \
-resultBundlePath "${UNIT_XCRESULT}" \
CODE_SIGNING_ALLOWED=NO
- name: Upload unit test .xcresult bundle
if: steps.unit_tests.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: ${{ github.run_id }}.xcresult
path: ${{ env.UNIT_XCRESULT }}
if-no-files-found: error
retention-days: 14
- name: Fail job when unit tests fail
if: steps.unit_tests.outcome == 'failure'
run: |
echo "Unit tests failed. See uploaded xcresult artifact."
exit 1