Repository navigation
132 lines (111 loc) · 3.9 KB
/
Copy pathtest.yml
File metadata and controls
132 lines (111 loc) · 3.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
name: Test
on:
workflow_dispatch:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
checks: write
pull-requests: write
contents: read
jobs:
test-ios:
runs-on: macos-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Fix SwiftLint config permissions
run: chmod 644 .swiftlint.yml
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'
- name: Show Xcode + Simulator Info
run: |
xcodebuild -version
xcrun simctl list
- name: List and Boot simulator
run: |
echo "Available simulators:"
xcrun simctl list devices | grep "iPhone 16 Pro"
echo "Booting simulator..."
# Get the first iPhone 16 Pro running iOS 26.1
UDID=$(xcrun simctl list devices | grep "iPhone 16 Pro" | grep -v "Max" | head -1 | grep -o '([A-F0-9-]\{36\})' | tr -d '()')
echo "Simulator UDID: $UDID"
if [ -z "$UDID" ]; then
echo "ERROR: Could not find simulator"
exit 1
fi
xcrun simctl boot "$UDID"
xcrun simctl bootstatus "$UDID" -b
echo "Simulator booted successfully"
- name: Install SwiftLint
run: brew install swiftlint
- name: Run Tests
run: |
xcodebuild test \
-scheme "LittleLemon" \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
-enableCodeCoverage YES \
-resultBundlePath TestResults.xcresult \
-only-testing:LittleLemonTests
- name: Cache Homebrew Tools
id: cache-brew-tools
uses: actions/cache@v4
with:
path: |
~/Library/Caches/Homebrew
/opt/homebrew/Cellar/xcresultparser
/opt/homebrew/Cellar/xcparse
/opt/homebrew/bin/xcresultparser
/opt/homebrew/bin/xcparse
key: ${{ runner.os }}-brew-tools-${{ hashFiles('.github/workflows/test.yml') }}
restore-keys: |
${{ runner.os }}-brew-tools-
- name: Install Tools
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
if: (success() || failure()) && steps.cache-brew-tools.outputs.cache-hit != 'true'
run: |
brew install xcresultparser
brew install chargepoint/xcparse/xcparse
- name: Convert xcresult to JUnit
if: success() || failure()
run: |
if [ -d "TestResults.xcresult" ]; then
xcresultparser -o junit TestResults.xcresult > junit.xml
fi
- name: Extract Attachments
if: success() || failure()
run: |
if [ -d "TestResults.xcresult" ]; then
xcparse attachments TestResults.xcresult TestAttachments
fi
- name: Sanitize Attachment Filenames
if: success() || failure()
run: |
if [ -d "TestAttachments" ]; then
find TestAttachments -type f -print0 | while IFS= read -r -d '' file; do
filename=$(basename "$file")
clean_filename=$(echo "$filename" | tr -d '":<>|*?\r\n')
if [ "$filename" != "$clean_filename" ]; then
mv "$file" "$(dirname "$file")/$clean_filename"
fi
done
fi
- name: Upload Test Attachments
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-attachments
path: TestAttachments
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: 'junit*.xml'