-
Notifications
You must be signed in to change notification settings - Fork 23
59 lines (51 loc) · 1.82 KB
/
code_coverage.yaml
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
name: code coverage
on:
push:
branches: "master"
pull_request:
branches: "master"
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Install dependencies and build package
run: |
poetry install
- name: Build coverage file
run: |
poetry run pytest --cov-config=.coveragerc --junitxml=pytest.xml --cov=psnawp_api | tee pytest-coverage.txt
env:
NPSSO_CODE: ${{ secrets.NPSSO_CODE }}
USER_NAME: ${{ secrets.USER_NAME }}
- name: PyTest Coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
hide-comment: true
badge-title: Coverage
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: Create Variable of Summary Report
id: summary_report
run: |
SUMMARY_REPORT=${{ steps.coverageComment.outputs.summaryReport }}
echo "::set-output name=content::$SUMMARY_REPORT"
- name: Update Readme with Coverage Html
run: |
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md
- name: Commit & Push changes to Readme
uses: actions-js/push@master
with:
branch: master
message: Update coverage on Readme
github_token: ${{ secrets.GITHUB_TOKEN }}