3434 fail-fast : false
3535 matrix :
3636 python-version : ["3.8", "3.9", "3.10"]
37+ include :
38+ - python-version : " 3.9"
39+ cov-reports : --cov=ads --cov-report=xml --cov-report=html
40+
3741
3842 steps :
3943 - uses : actions/checkout@v3
@@ -71,13 +75,50 @@ jobs:
7175 cat $HOME_RUNNER_DIR/.oci/config
7276
7377 - name : " Run tests"
74- timeout-minutes : 15
78+ timeout-minutes : 5
7579 shell : bash
76- env :
77- NoDependency : True
7880 run : |
7981 set -x # print commands that are executed
8082 $CONDA/bin/conda init
8183 source /home/runner/.bashrc
8284 pip install -r test-requirements.txt
83- python -m pytest -v -p no:warnings --durations=5 tests
85+ python -m pytest ${{ matrix.cov-reports }} tests
86+
87+ - name : " Save coverage files"
88+ uses : actions/upload-artifact@v3
89+ if : ${{ matrix.cov-reports }}
90+ with :
91+ name : cov-reports-${{ matrix.name }}
92+ path : |
93+ htmlcov/
94+ .coverage
95+ coverage.xml
96+
97+ - name : " Add comment with coverage info to PR"
98+ if : ${{ success() }} && ${{ github.event.issue.pull_request }}
99+ run : |
100+ set -x # print commands that are executed
101+
102+ # Prepare default cov body text
103+ COV_BODY_INTRO="📌 Overall coverage:\n\n"
104+ echo COV_BODY="$COV_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
105+
106+ # Calculate overall coverage and update body message
107+ COV=$(grep -E 'pc_cov' htmlcov/index.html | cut -d'>' -f 2 | cut -d'%' -f 1)
108+ if [[ ! -z $COV ]]; then
109+ if [[ $COV -lt 50 ]]; then COLOR=red; elif [[ $COV -lt 80 ]]; then COLOR=yellow; else COLOR=green; fi
110+ echo COV_BODY="$COV_BODY_INTRO " >> $GITHUB_ENV
111+ fi
112+
113+ - name : " Add comment with cov diff to PR"
114+ uses : actions/github-script@v6
115+ if : ${{ success() }} && ${{ github.event.issue.pull_request }}
116+ with :
117+ github-token : ${{ github.token }}
118+ script : |
119+ github.rest.issues.createComment({
120+ issue_number: context.issue.number,
121+ owner: context.repo.owner,
122+ repo: context.repo.repo,
123+ body: '${{ env.COV_BODY }}'
124+ })
0 commit comments