-
Notifications
You must be signed in to change notification settings - Fork 7
180 lines (163 loc) · 5.57 KB
/
tests.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
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
name: PerformanceSuite Tests
on:
push:
branches:
- main
pull_request:
branches:
- '*'
jobs:
swiftpm-build:
runs-on: macos-13
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v4
- name: SwiftLint
run:
Pods/SwiftLint/swiftlint lint --strict
# to compile swift package we should remove workspace and xcodeproj
# otherwise xcodebuild takes schemes from them
- name: Remove workspace
run: |
rm -rf Project.xcodeproj
rm -rf Project.xcworkspace
- name: Compile
run: |
xcodebuild -scheme PerformanceSuite -destination 'generic/platform=iOS'
xcodebuild -scheme PerformanceSuiteCrashlytics -destination 'generic/platform=iOS'
xcodebuild -scheme PerformanceApp -destination 'generic/platform=iOS'
# restore removed files just in case it is needed for the further steps
- name: Restore workspace
run: |
git checkout -- Project.xcodeproj
git checkout -- Project.xcworkspace
unit-tests:
runs-on: macos-latest
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v4
- name: Install CocoaPods
run: |
pod install
- name: Run Unit Tests
env:
scheme: UnitTests
destination: platform=iOS Simulator,name=iPhone 15 Pro,OS=17.5
workspace: Project.xcworkspace
run: |
xcodebuild test -scheme "$scheme" -workspace "$workspace" -destination "$destination" -derivedDataPath DerivedData
- name: Slather
env:
scheme: UnitTests
workspace: Project.xcworkspace
project: Project.xcodeproj
binary_file: DerivedData/Build/Products/Debug-iphonesimulator/PerformanceSuite/PerformanceSuite.framework/PerformanceSuite
build_directory: DerivedData/Build
run: |
gem install slather
slather coverage --simple-output --workspace $workspace --scheme $scheme --binary-file "$binary_file" --build-directory $build_directory $project | grep -E '^Test Coverage|^Tested ' > code_coverage.txt
slather coverage --cobertura-xml --workspace $workspace --scheme $scheme --binary-file "$binary_file" --build-directory $build_directory $project
- name: Upload code_coverage.txt
uses: actions/upload-artifact@v4
with:
name: code_coverage.txt
path: code_coverage.txt
- name: Upload cobertura.xml
uses: actions/upload-artifact@v4
with:
name: cobertura.xml
path: cobertura.xml
ui-tests:
runs-on: macos-latest
steps:
- name: Set Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 15.4
- name: Checkout
uses: actions/checkout@v4
- name: Install CocoaPods
run: |
pod install
- name: Run UI Tests
env:
scheme: UITests
destination: platform=iOS Simulator,name=iPhone 15 Pro,OS=17.5
workspace: Project.xcworkspace
run: |
xcodebuild test -scheme "$scheme" -workspace "$workspace" -destination "$destination"
coverage-report:
runs-on: ubuntu-latest
needs: unit-tests
steps:
- name: Download cobertura.xml
uses: actions/download-artifact@v4
with:
name: cobertura.xml
- name: Code coverage markdown report
uses: irongut/[email protected]
with:
filename: cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
output: both
thresholds: '75 85'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Upload code-coverage-results.md
uses: actions/upload-artifact@v4
with:
name: code-coverage-results.md
path: code-coverage-results.md
coverage-badge:
if: github.ref == 'refs/heads/main'
needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: badges
- name: Download code_coverage.txt
uses: actions/download-artifact@v4
with:
name: code_coverage.txt
- name: Commit code_coverage.txt
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if [[ `git status --porcelain` ]]; then
git add code_coverage.txt
git commit -m "Update code_coverage.txt"
git push
else
echo "No changes to code coverage"
fi
- name: Load coverage data
id: load-coverage
run: |
echo "coverage=$(cat code_coverage.txt | grep -o -E '[0-9\.]+%' | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Make Coverage Badge
uses: action-badges/[email protected]
with:
label: coverage
message: "${{ steps.load-coverage.outputs.coverage }}"
message-color: brightgreen
file-name: code_coverage.svg
badge-branch: badges
github-token: "${{ secrets.GITHUB_TOKEN }}"