@@ -11,6 +11,8 @@ name: 🕵️♂️ CLI Unit Tests
11
11
jobs :
12
12
cli-unit-test :
13
13
runs-on : ubuntu-latest
14
+ # permissions:
15
+ # contents: write
14
16
defaults :
15
17
run :
16
18
working-directory : ./CLI
63
65
name : coverage_cli_xml
64
66
path : ./CLI/coverage_cli.xml
65
67
66
- coverage-badge :
68
+ generate- coverage-badge :
67
69
needs : cli-unit-test
68
70
runs-on : ubuntu-latest
69
71
permissions :
@@ -76,41 +78,38 @@ jobs:
76
78
steps :
77
79
- uses : actions/checkout@v4
78
80
with :
79
- fetch-depth : 0
80
- ref : coverage_badges
81
+ fetch-depth : " 0"
81
82
82
- - uses : actions/setup-python@v5
83
+ - name : Generate Badge
84
+ uses : ./.github/actions/coverage/generate-badge
83
85
with :
84
- python-version : ' 3.8'
85
-
86
- - name : Install genbadge
87
- run : pip install genbadge[coverage]
86
+ COVERAGE_REPORT_ARTIFACT : coverage_cli_xml
87
+ COVERAGE_REPORT_NAME : coverage_cli.xml
88
+ LABEL : " CLI coverage"
89
+ OUTPUT_FILE : cli_coverage_badge.svg
90
+ RED_LIMIT : " 50"
91
+ GREEN_LIMIT : " 65"
92
+ BADGE_ARTIFACT_NAME : cli_coverage_badge
93
+
94
+ upload-coverage-badge :
95
+ needs : generate-coverage-badge
96
+ runs-on : ubuntu-latest
97
+ permissions :
98
+ contents : write
99
+ defaults :
100
+ run :
101
+ working-directory : ./
102
+ if : github.ref == 'refs/heads/main' && github.event.head_commit.author.name != 'GitHubActions'
88
103
89
- - name : Download line coverage reports
90
- uses : actions/download-artifact @v4
104
+ steps :
105
+ - uses : actions/checkout @v4
91
106
with :
92
- name : coverage_cli_xml
93
-
94
- - name : Generate badge
95
- run : genbadge coverage -i coverage_cli.xml -n "CLI coverage" -o cli_coverage_badge.svg
107
+ fetch-depth : " 0"
96
108
97
- - name : Verify Changed files
98
- uses : tj-actions/verify-changed-files@v16
99
- id : verify-changed-files
100
- with :
101
- files : cli_coverage_badge.svg
102
-
103
- - name : Commit badge
104
- if : steps.verify-changed-files.outputs.files_changed == 'true'
105
- run : |
106
- git config --local user.email "<>"
107
- git config --local user.name "GitHubActions"
108
- git add cli_coverage_badge.svg
109
- git commit -m "Add/Update CLI badge"
110
-
111
- - name : Push badge commit
112
- if : steps.verify-changed-files.outputs.files_changed == 'true'
113
- uses : ad-m/github-push-action@master
109
+ - name : Upload Badge
110
+ uses : ./.github/actions/coverage/upload-badge
114
111
with :
112
+ BADGE_ARTIFACT_NAME : cli_coverage_badge
113
+ BADGE_FILE_NAME : cli_coverage_badge.svg
114
+ BRANCH_NAME : coverage_badges
115
115
github_token : ${{ secrets.GITHUB_TOKEN }}
116
- branch : coverage_badges # Dedicated branch to store coverage badges
0 commit comments