-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (59 loc) · 2.37 KB
/
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
name: Run tests
on:
pull_request:
branches: ["main"]
env:
XCODE_PROJECT: TemplateApp.xcodeproj
SCHEME: TemplateApp
TEST_PLAN: AllTests
TEST_RESULT_BUNDLE: TestResults.xcresult
jobs:
build:
name: Run tests
runs-on: [macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode version
run: sudo xcode-select --switch /Applications/Xcode_15.3.app
- name: Cache Swift Package Manager dependencies
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/SourcePackages
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-
- name: Install Swift packages
run: |
xcodebuild -project "${{ env.XCODE_PROJECT }}" \
-scheme "${{ env.SCHEME }}" \
-onlyUsePackageVersionsFromResolvedFile \
-resolvePackageDependencies \
-clonedSourcePackagesDirPath "${{ runner.temp }}/SourcePackages"
- name: Determine test device
run: |
echo "PLATFORM=iOS Simulator" >> "$GITHUB_ENV"
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
echo "DEVICE=$(xcrun xctrace list devices 2>&1 | grep -oE 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//")" >> "$GITHUB_ENV"
- name: Build for testing
run: |
xcodebuild build-for-testing -project "${{ env.XCODE_PROJECT }}" \
-scheme "${{ env.SCHEME }}" \
-destination "platform=$PLATFORM,name=$DEVICE" \
-clonedSourcePackagesDirPath "${{ runner.temp }}/SourcePackages" \
-disableAutomaticPackageResolution
- name: Run tests
run: |
xcodebuild test-without-building -project "${{ env.XCODE_PROJECT }}" \
-scheme "${{ env.SCHEME }}" \
-testPlan "${{ env.TEST_PLAN }}" \
-destination "platform=$PLATFORM,name=$DEVICE" \
-resultBundlePath "${{ env.TEST_RESULT_BUNDLE }}" \
-clonedSourcePackagesDirPath "${{ runner.temp }}/SourcePackages" \
-disableAutomaticPackageResolution
- name: Upload test result bundle
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: ${{ env.SCHEME }}-${{ github.ref_name }}-${{ github.sha }}.xcresult
path: ${{ env.TEST_RESULT_BUNDLE }}