-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (73 loc) · 2.39 KB
/
deploy-coverage.yml
File metadata and controls
90 lines (73 loc) · 2.39 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
name: Deploy Coverage Report
on:
workflow_run:
workflows: [Testing]
types: [completed]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy-coverage:
name: Deploy Coverage Report
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download coverage HTML report
uses: actions/download-artifact@v4
with:
name: coverage-html
path: ./coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Download coverage JSON report
uses: actions/download-artifact@v4
with:
name: coverage-json
path: ./coverage-json
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Convert coverage JSON for shields.io
run: |
# Convert pytest-cov JSON to shields.io format
if [ -f ./coverage-json/coverage.json ]; then
python3 -c "
import json
# Read pytest-cov coverage.json
with open('./coverage-json/coverage.json', 'r') as f:
data = json.load(f)
# Extract coverage percentage
totals = data.get('totals', {})
percent_covered = totals.get('percent_covered', 0)
# Create shields.io compatible JSON
shields_data = {
'schemaVersion': 1,
'label': 'Coverage',
'message': f'{percent_covered:.1f}%',
'color': 'green' if percent_covered >= 80 else 'yellow' if percent_covered >= 60 else 'red',
'namedLogo': 'python',
'logoColor': 'white'
}
# Write shields.io compatible JSON
with open('./coverage-report/coverage.json', 'w') as f:
json.dump(shields_data, f)
print(f'Coverage: {percent_covered:.1f}%')
"
fi
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload to Pages
uses: actions/upload-pages-artifact@v3
with:
path: ./coverage-report
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4