-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (92 loc) · 3.76 KB
/
test.yml
File metadata and controls
106 lines (92 loc) · 3.76 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
name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
test:
name: Run Unit Tests
runs-on: macos-latest
strategy:
matrix:
swift-version: ['6.0']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Select Xcode version
run: sudo xcode-select -s /Applications/Xcode.app
- name: Show Swift version
run: swift --version
- name: Resolve dependencies
run: swift package resolve
- name: Build package
run: swift build
- name: Run tests with code coverage
run: |
swift test --enable-code-coverage
- name: Find coverage data
id: coverage
run: |
PROF_DATA=$(find .build -name "default.profdata" -type f | head -1)
# Find the test executable binary inside the .xctest bundle
XCTEST_BUNDLE=$(find .build -name "DesignAlgorithmsKitPackageTests.xctest" -type d | head -1)
if [ -n "$XCTEST_BUNDLE" ]; then
BINARY="$XCTEST_BUNDLE/Contents/MacOS/DesignAlgorithmsKitPackageTests"
else
# Fallback: try to find the binary directly
BINARY=$(find .build -name "DesignAlgorithmsKitPackageTests" -type f -path "*/Contents/MacOS/*" | head -1)
fi
echo "profdata=$PROF_DATA" >> $GITHUB_OUTPUT
echo "binary=$BINARY" >> $GITHUB_OUTPUT
echo "Found profdata: $PROF_DATA"
echo "Found binary: $BINARY"
echo "XCTest bundle: $XCTEST_BUNDLE"
- name: Generate code coverage report
if: steps.coverage.outputs.profdata != '' && steps.coverage.outputs.binary != ''
run: |
if [ -f "${{ steps.coverage.outputs.binary }}" ]; then
xcrun llvm-cov export -format="lcov" \
-instr-profile="${{ steps.coverage.outputs.profdata }}" \
"${{ steps.coverage.outputs.binary }}" \
-ignore-filename-regex=".build|Tests" > coverage.lcov
echo "Coverage report generated successfully"
ls -lh coverage.lcov
else
echo "Binary not found, skipping coverage generation"
echo "Binary path: ${{ steps.coverage.outputs.binary }}"
fi
- name: Upload coverage to Codecov
if: steps.coverage.outputs.profdata != '' && steps.coverage.outputs.binary != ''
uses: codecov/codecov-action@v4
with:
file: ./coverage.lcov
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Generate HTML coverage report
if: steps.coverage.outputs.profdata != '' && steps.coverage.outputs.binary != ''
run: |
if [ -f "${{ steps.coverage.outputs.binary }}" ]; then
mkdir -p .build/coverage-html || true
xcrun llvm-cov show -format="html" \
-instr-profile="${{ steps.coverage.outputs.profdata }}" \
-output-dir=.build/coverage-html \
"${{ steps.coverage.outputs.binary }}" \
-ignore-filename-regex=".build|Tests" || echo "HTML report generation skipped"
# Ensure directory exists even if generation fails
touch .build/coverage-html/index.html || true
else
echo "Binary not found, skipping HTML report generation"
fi
- name: Upload coverage HTML report
if: steps.coverage.outputs.profdata != '' && always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: .build/coverage-html
retention-days: 30
if-no-files-found: ignore