@@ -2,24 +2,24 @@ name: coverage
2
2
on :
3
3
pull_request :
4
4
branches :
5
- - ' master'
5
+ - " master"
6
6
push :
7
7
branches :
8
- - ' master'
8
+ - " master"
9
9
jobs :
10
- code-coverage :
11
- runs-on : ubuntu-20 .04
10
+ code-coverage-proto3 :
11
+ runs-on : ubuntu-22 .04
12
12
env :
13
13
ENVIRONMENT : TEST_RUNNER
14
- OS : ubuntu-20 .04
15
- PYTHON : ' 3.9'
14
+ OS : ubuntu-22 .04
15
+ PYTHON : " 3.9"
16
16
COVERAGE_TOTAL : 49 # Coverage threshold percentage
17
17
steps :
18
18
- name : Checkout (admin token)
19
19
if : ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
20
20
uses : actions/checkout@master
21
21
with :
22
- token : ' ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
22
+ token : " ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}"
23
23
fetch-depth : " 2" # Original commit + code cov badge commit
24
24
- name : Checkout (normal flow)
25
25
if : ${{github.event_name == 'pull_request'}}
@@ -34,17 +34,85 @@ jobs:
34
34
id : coverage-installer
35
35
run : |
36
36
python -m pip install --upgrade pip
37
- pip install cython==0.29.21 numpy==1.23.2
38
37
sudo apt-get install jq
39
38
pip install -r requirements.txt
40
39
pip install -r requirements-dev.txt
41
40
pip install coverage-badge
41
+ pip install .[proto3]
42
42
- name : Run tests and calculate coverage
43
43
id : test-runner
44
44
run : |
45
45
coverage run -m pytest
46
46
coverage-badge -f -o docs/coverage.svg
47
- COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
47
+ coverage json
48
+ COVERAGE_SCORE=$(jq '.totals.percent_covered' coverage.json)
49
+ echo "::set-output name=coverageScore::$COVERAGE_SCORE"
50
+ - name : Verify Changed files
51
+ uses : tj-actions/verify-changed-files@v6
52
+ id : changed_files
53
+ with :
54
+ files : docs/coverage.svg
55
+ - name : Commit code coverage badge
56
+ if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
57
+ run : |
58
+ git config --local user.name "$(git log -1 --pretty=format:'%an' | xargs)"
59
+ git config --local user.email "$(git log -1 --pretty=format:'%ae' | xargs)"
60
+ git add docs/coverage.svg
61
+ git commit -m "test: update coverage.svg"
62
+ git reset --soft HEAD~2
63
+ # shellcheck disable=SC1083 # code is irrelevant because git needs this literal
64
+ git commit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"
65
+ - name : Push code coverage badge
66
+ if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
67
+ uses : ad-m/github-push-action@master
68
+ with :
69
+ force : true
70
+ github_token : ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}
71
+ branch : ${{ github.event.pull_request.head.repo.full_name }}
72
+ - name : Coverage total fail - exit
73
+ if : ${{github.event_name == 'pull_request' && steps.test-runner.outputs.coverageScore < env.COVERAGE_TOTAL}}
74
+ run : |
75
+ echo "cov total fail ${{ steps.test-runner.outputs.coverageScore }}"
76
+ exit 1
77
+ code-coverage-proto4 :
78
+ runs-on : ubuntu-22.04
79
+ env :
80
+ ENVIRONMENT : TEST_RUNNER
81
+ OS : ubuntu-22.04
82
+ PYTHON : " 3.9"
83
+ COVERAGE_TOTAL : 49 # Coverage threshold percentage
84
+ steps :
85
+ - name : Checkout (admin token)
86
+ if : ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
87
+ uses : actions/checkout@master
88
+ with :
89
+ token : " ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}"
90
+ fetch-depth : " 2" # Original commit + code cov badge commit
91
+ - name : Checkout (normal flow)
92
+ if : ${{github.event_name == 'pull_request'}}
93
+ uses : actions/checkout@master
94
+ with :
95
+ fetch-depth : " 2" # Original commit + code cov badge commit
96
+ - name : Setup Python
97
+ uses : actions/setup-python@master
98
+ with :
99
+ python-version : 3.9
100
+ - name : Install dependencies
101
+ id : coverage-installer
102
+ run : |
103
+ python -m pip install --upgrade pip
104
+ sudo apt-get install jq
105
+ pip install -r requirements.txt
106
+ pip install -r requirements-dev.txt
107
+ pip install coverage-badge
108
+ pip install .[proto4]
109
+ - name : Run tests and calculate coverage
110
+ id : test-runner
111
+ run : |
112
+ coverage run -m pytest
113
+ coverage-badge -f -o docs/coverage.svg
114
+ coverage json
115
+ COVERAGE_SCORE=$(jq '.totals.percent_covered' coverage.json)
48
116
echo "::set-output name=coverageScore::$COVERAGE_SCORE"
49
117
- name : Verify Changed files
50
118
uses : tj-actions/verify-changed-files@v6
0 commit comments