@@ -15,61 +15,61 @@ jobs:
15
15
PYTHON : ' 3.9'
16
16
COVERAGE_TOTAL : 49 # Coverage threshold percentage
17
17
steps :
18
- - name : Checkout (admin token)
19
- if : ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
20
- uses : actions/checkout@master
21
- with :
22
- token : ' ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
23
- fetch-depth : " 2" # Original commit + code cov badge commit
24
- - name : Checkout (normal flow)
25
- if : ${{github.event_name == 'pull_request'}}
26
- uses : actions/checkout@master
27
- with :
28
- fetch-depth : " 2" # Original commit + code cov badge commit
29
- - name : Setup Python
30
- uses : actions/setup-python@master
31
- with :
32
- python-version : 3.9
33
- - name : Install dependencies
34
- id : coverage-installer
35
- run : |
36
- python -m pip install --upgrade pip
37
- pip install cython==0.29.21 numpy==1.23.2
38
- sudo apt-get install jq
39
- pip install -r requirements.txt
40
- pip install -r requirements-dev.txt
41
- pip install coverage-badge
42
- - name : Run tests and calculate coverage
43
- id : test-runner
44
- run : |
45
- coverage run -m pytest
46
- coverage-badge -f -o docs/coverage.svg
47
- COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
48
- echo "::set-output name=coverageScore::$COVERAGE_SCORE"
49
- - name : Verify Changed files
50
- uses : tj-actions/verify-changed-files@v6
51
- id : changed_files
52
- with :
53
- files : docs/coverage.svg
54
- - name : Commit code coverage badge
55
- if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
56
- run : |
57
- git config --local user.name "$(git log -1 --pretty=format:'%an' | xargs)"
58
- git config --local user.email "$(git log -1 --pretty=format:'%ae' | xargs)"
59
- git add docs/coverage.svg
60
- git commit -m "test: update coverage.svg"
61
- git reset --soft HEAD~2
62
- # shellcheck disable=SC1083 # code is irrelevant because git needs this literal
63
- git commit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"
64
- - name : Push code coverage badge
65
- if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
66
- uses : ad-m/github-push-action@master
67
- with :
68
- force : true
69
- github_token : ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}
70
- branch : ${{ github.event.pull_request.head.repo.full_name }}
71
- - name : Coverage total fail - exit
72
- if : ${{github.event_name == 'pull_request' && steps.test-runner.outputs.coverageScore < env.COVERAGE_TOTAL}}
73
- run : |
74
- echo "cov total fail ${{ steps.test-runner.outputs.coverageScore }}"
75
- exit 1
18
+ - name : Checkout (admin token)
19
+ if : ${{github.event_name != 'pull_request'}} # We don't want to use the admin token for PR flows
20
+ uses : actions/checkout@master
21
+ with :
22
+ token : ' ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}'
23
+ fetch-depth : " 2" # Original commit + code cov badge commit
24
+ - name : Checkout (normal flow)
25
+ if : ${{github.event_name == 'pull_request'}}
26
+ uses : actions/checkout@master
27
+ with :
28
+ fetch-depth : " 2" # Original commit + code cov badge commit
29
+ - name : Setup Python
30
+ uses : actions/setup-python@master
31
+ with :
32
+ python-version : 3.9
33
+ - name : Install dependencies
34
+ id : coverage-installer
35
+ run : |
36
+ python -m pip install --upgrade pip
37
+ pip install cython==0.29.21 numpy==1.23.2
38
+ sudo apt-get install jq
39
+ pip install -r requirements.txt
40
+ pip install -r requirements-dev.txt
41
+ pip install coverage-badge
42
+ - name : Run tests and calculate coverage
43
+ id : test-runner
44
+ run : |
45
+ coverage run -m pytest
46
+ coverage-badge -f -o docs/coverage.svg
47
+ COVERAGE_SCORE=$(coverage json -o /dev/stdout | jq .totals.percent_covered)
48
+ echo "::set-output name=coverageScore::$COVERAGE_SCORE"
49
+ - name : Verify Changed files
50
+ uses : tj-actions/verify-changed-files@v6
51
+ id : changed_files
52
+ with :
53
+ files : docs/coverage.svg
54
+ - name : Commit code coverage badge
55
+ if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
56
+ run : |
57
+ git config --local user.name "$(git log -1 --pretty=format:'%an' | xargs)"
58
+ git config --local user.email "$(git log -1 --pretty=format:'%ae' | xargs)"
59
+ git add docs/coverage.svg
60
+ git commit -m "test: update coverage.svg"
61
+ git reset --soft HEAD~2
62
+ # shellcheck disable=SC1083 # code is irrelevant because git needs this literal
63
+ git commit -m "$(git log --format=%B --reverse HEAD..HEAD@{1})"
64
+ - name : Push code coverage badge
65
+ if : ${{ steps.changed_files.outputs.files_changed == 'true' && github.event_name != 'pull_request'}}
66
+ uses : ad-m/github-push-action@master
67
+ with :
68
+ force : true
69
+ github_token : ${{ secrets.GIT_ADMIN_WORKFLOW_TOKEN }}
70
+ branch : ${{ github.event.pull_request.head.repo.full_name }}
71
+ - name : Coverage total fail - exit
72
+ if : ${{github.event_name == 'pull_request' && steps.test-runner.outputs.coverageScore < env.COVERAGE_TOTAL}}
73
+ run : |
74
+ echo "cov total fail ${{ steps.test-runner.outputs.coverageScore }}"
75
+ exit 1
0 commit comments