-
Notifications
You must be signed in to change notification settings - Fork 37
116 lines (110 loc) · 4.6 KB
/
unit_tests.yml
File metadata and controls
116 lines (110 loc) · 4.6 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
name: Reusable action of Unit tests
on: [workflow_call]
env:
COVERAGE_DIR: ./COVERAGE
jobs:
unittests:
runs-on: macos-14
strategy:
fail-fast: false
matrix:
# github actions are very poor in supporting iOS simulators:
# - multiple Xcode versions are pre installed (not all versions and they change supported xcode versions frequently)
# - each xcode version has own simulator os versions.
# - so to run tests with the target simulator, we have to find a proper xcode version pre-installed and support the target simulator os version.
# also, the xcode version (simulator_xcode_version) and simulator os versions (os) are moving target. We have to change these time to time.
# - see "https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md" for installed macOS, xcode and simulator versions.
include:
- os: 17.2
device: "iPhone 15"
scheme: "OptimizelySwiftSDK-iOS"
test_sdk: "iphonesimulator"
platform: "iOS Simulator"
os_type: "iOS"
simulator_xcode_version: 15.3
- os: 17.4
device: "iPad Pro 11-inch (M4)"
scheme: "OptimizelySwiftSDK-iOS"
test_sdk: "iphonesimulator"
platform: "iOS Simulator"
os_type: "iOS"
simulator_xcode_version: 15.3
- os: 18.2
device: "iPhone 16"
scheme: "OptimizelySwiftSDK-iOS"
test_sdk: "iphonesimulator"
platform: "iOS Simulator"
os_type: "iOS"
simulator_xcode_version: 15.3
- os: 17.5
device: "Apple TV"
scheme: "OptimizelySwiftSDK-tvOS"
test_sdk: "appletvsimulator"
platform: "tvOS Simulator"
os_type: "tvOS"
simulator_xcode_version: 15.3
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
# macos version and supported simulator_xcode_versions are all related to this xcode_version, so be careful when you upgrade this.
xcode-version: 15.3
- name: set SDK Branch if PR
env:
BASE_REF: ${{ github.base_ref }}
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "BRANCH=$BASE_REF" >> $GITHUB_ENV
- name: set SDK Branch if not pull request
env:
REF_NAME: ${{ github.ref_name }}
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "BRANCH=$REF_NAME" >> $GITHUB_ENV
- id: unit_tests
env:
SCHEME: ${{ matrix.scheme }}
TEST_SDK: ${{ matrix.test_sdk }}
PLATFORM: ${{ matrix.platform }}
OS: ${{ matrix.os }}
OS_TYPE: ${{ matrix.os_type }}
SIMULATOR_XCODE_VERSION: ${{ matrix.simulator_xcode_version }}
NAME: ${{ matrix.device }}
run: |
gem install coveralls-lcov
gem install cocoapods -v '1.15.2'
pod repo update
pod install
HOMEBREW_NO_INSTALL_CLEANUP=true brew update && brew install jq
# github actions are very poor in supporting iOS simulators:
# - to find pre-installed xcode version, run this:
##ls /Applications/
# - to find supported simulator os versions, run this (and find simulator with non-error "datapath")
# xcrun simctl list --json devices
# switch to the target xcode version
sudo xcode-select -switch /Applications/Xcode_$SIMULATOR_XCODE_VERSION.app
Scripts/prepare_simulator.sh
Scripts/run_unit_tests.sh
- name: Check on failures (Archive Test Results)
uses: actions/upload-artifact@v4
if: steps.unit_tests.outcome != 'success'
with:
name: build-logs-${{ matrix.device }}-${{ matrix.os }}
path: build/Logs
- # - report coverage for PR and iPhone 16 only (avoid redundant ones)
# - use Xcode16+ (older Xcode reports a wrong number)
name: Check on success
id: coveralls
if: ${{ steps.unit_tests.outcome == 'success' && env.BRANCH == 'master' && env.PLATFORM == 'iOS Simulator' && env.NAME == 'iPhone 16' }}
env:
PLATFORM: ${{ matrix.platform }}
NAME: ${{ matrix.device }}
run: |
Scripts/prepare_coveralls_report.sh
sleep 5
- name: Upload coveralls report
if: steps.coveralls.outcome == 'success'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./xccov2lcov/lcov.info