-
-
Notifications
You must be signed in to change notification settings - Fork 126
108 lines (94 loc) · 3.28 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
name: Tests
on:
push:
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ios-unit-tests:
name: iOS Unit Tests
runs-on: macos-12
timeout-minutes: 30
steps:
- # Checkout the repository
uses: actions/checkout@v4
- # Install dependencies
run: brew install xcbeautify
- # Run Tests iOS
name: Run Tests iOS
run: |
set -o pipefail && \
env NSUnbufferedIO=YES \
xcodebuild -workspace . \
-scheme "TPPDF" \
-sdk iphonesimulator \
-destination "OS=16.2,name=iPhone 14 Pro" \
-configuration Debug \
-enableCodeCoverage YES \
-derivedDataPath /tmp/DerivedData \
-resultBundlePath test_output \
CODE_SIGNING_ALLOWED="NO" \
test 2>&1 | tee test.log | xcbeautify
- name: Upload test log file on error
uses: actions/upload-artifact@v4
if: failure()
with:
name: test.log
path: test.log
- name: Generate code coverage reports
run: |
PROFDATA_PATH=$(find /tmp/DerivedData -name "*.profdata")
echo "Detected profdata at path: $PROFDATA_PATH"
xcrun llvm-cov export \
/tmp/DerivedData/Build/Products/Debug-iphonesimulator/TPPDFTests.xctest/TPPDFTests \
--instr-profile $PROFDATA_PATH \
--format="lcov" > unit-tests.coverage.lcov
xcrun llvm-cov export \
/tmp/DerivedData/Build/Products/Debug-iphonesimulator/TPPDFIntegrationTests.xctest/TPPDFIntegrationTests \
--instr-profile $PROFDATA_PATH \
--format="lcov" > integration-tests.coverage.lcov
- # Codecov Coverage
name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
fail_ci_if_error: true
files: ./unit-tests.coverage.lcov,./integration-tests.coverage.lcov
flags: iOS
xcode_archive_path: test_output.xcresults
path_to_write_report: coverage_report.txt
- # Upload the generated Codecov report to the GitHub artifacts
name: Upload coverage report
uses: actions/upload-artifact@v4
if: success()
with:
name: coverage_report.txt
path: coverage_report.txt
macos-unit-tests:
name: macOS Unit Tests
runs-on: macos-12
timeout-minutes: 30
steps:
- # Checkout the repository
uses: actions/checkout@v4
- # Install dependencies
run: brew install xcbeautify
- # Run tests on macOS with coverage enabled
name: Run tests
run: swift test --parallel --enable-code-coverage
- name: Generate code coverage reports
run: |
xcrun llvm-cov export \
.build/debug/TPPDFPackageTests.xctest/Contents/MacOS/TPPDFPackageTests \
--instr-profile .build/debug/codecov/default.profdata \
--format="lcov" > coverage.lcov
- # Codecov Coverage
name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
fail_ci_if_error: true
files: ./coverage.lcov
flags: macOS
path_to_write_report: coverage_report.txt