|
41 | 41 | -only-testing:FacettTests/GoProCommandTests \ |
42 | 42 | -only-testing:FacettTests/SettingsTests \ |
43 | 43 | -only-testing:FacettTests/StateMachineTests \ |
44 | | - -quiet |
| 44 | + -enableCodeCoverage YES \ |
| 45 | + -resultBundlePath TestResults.xcresult |
| 46 | +
|
| 47 | + - name: Code Coverage Summary |
| 48 | + if: always() |
| 49 | + run: | |
| 50 | + if [ -d TestResults.xcresult ]; then |
| 51 | + xcrun xccov view --report --json TestResults.xcresult > coverage.json |
| 52 | + echo "## Code Coverage" >> $GITHUB_STEP_SUMMARY |
| 53 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 54 | + python3 -c " |
| 55 | + import json, sys |
| 56 | + with open('coverage.json') as f: |
| 57 | + data = json.load(f) |
| 58 | + targets = data.get('targets', []) |
| 59 | + for t in targets: |
| 60 | + name = t.get('name', '') |
| 61 | + if name == 'Facett.app': |
| 62 | + pct = t.get('lineCoverage', 0) * 100 |
| 63 | + print(f'**{name}**: {pct:.1f}% line coverage') |
| 64 | + sys.stdout.flush() |
| 65 | + files = t.get('files', []) |
| 66 | + covered = [(f['name'], f['lineCoverage'] * 100) for f in files if f.get('lineCoverage', 0) > 0] |
| 67 | + covered.sort(key=lambda x: -x[1]) |
| 68 | + print() |
| 69 | + print('| File | Coverage |') |
| 70 | + print('|------|----------|') |
| 71 | + for fname, cov in covered[:20]: |
| 72 | + print(f'| {fname} | {cov:.1f}% |') |
| 73 | + " >> $GITHUB_STEP_SUMMARY |
| 74 | + fi |
0 commit comments