@@ -19,6 +19,7 @@ concurrency:
1919
2020permissions :
2121 contents : read
22+ pull-requests : write
2223
2324# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
2425env :
3435 fail-fast : false
3536 matrix :
3637 python-version : ["3.8", "3.9", "3.10"]
38+ include :
39+ - python-version : " 3.9"
40+ cov-reports : --cov=oci_mlflow --cov-report=xml --cov-report=html
3741
3842 steps :
3943 - uses : actions/checkout@v3
@@ -57,27 +61,65 @@ jobs:
5761 run : |
5862 set -x # print commands that are executed
5963 mkdir -p "$HOME_RUNNER_DIR"/.oci
60- openssl genrsa -out $HOME_RUNNER_DIR/.oci/oci_ads_user .pem 2048
64+ openssl genrsa -out $HOME_RUNNER_DIR/.oci/oci_mlflow_user .pem 2048
6165 cat <<EOT >> "$HOME_RUNNER_DIR/.oci/config"
6266 [DEFAULT]
6367 user=ocid1.user.oc1..xxx
6468 fingerprint=00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
6569 tenancy=ocid1.tenancy.oc1..xxx
6670 region=test_region
67- key_file=$HOME_RUNNER_DIR/.oci/oci_ads_user .pem
71+ key_file=$HOME_RUNNER_DIR/.oci/oci_mlflow_user .pem
6872 EOT
6973 ls -lha "$HOME_RUNNER_DIR"/.oci
7074 echo "Test config file:"
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 : " Calculate coverage"
88+ if : ${{ success() }} && ${{ github.event.issue.pull_request }}
89+ run : |
90+ set -x # print commands that are executed
91+
92+ # Prepare default cov body text
93+ COV_BODY_INTRO="📌 Overall coverage:\n\n"
94+ echo COV_BODY="$COV_BODY_INTRO No success to gather report. 😿" >> $GITHUB_ENV
95+
96+ # Calculate overall coverage and update body message
97+ COV=$(grep -E 'pc_cov' htmlcov/index.html | cut -d'>' -f 2 | cut -d'%' -f 1)
98+ if [[ ! -z $COV ]]; then
99+ ROUNDED_COV=$(echo $COV | cut -d'.' -f 1)
100+ if [[ $ROUNDED_COV -lt 50 ]]; then COLOR=red; elif [[ $ROUNDED_COV -lt 80 ]]; then COLOR=yellow; else COLOR=green; fi
101+ echo COV_BODY="$COV_BODY_INTRO " >> $GITHUB_ENV
102+ fi
103+
104+ - name : " Add comment with coverage info to PR"
105+ uses : actions/github-script@v6
106+ if : ${{ success() }} && ${{ github.event.issue.pull_request }}
107+ with :
108+ github-token : ${{ github.token }}
109+ script : |
110+ github.rest.issues.createComment({
111+ issue_number: context.issue.number,
112+ owner: context.repo.owner,
113+ repo: context.repo.repo,
114+ body: '${{ env.COV_BODY }}'
115+ })
116+
117+ - name : " Save coverage files"
118+ uses : actions/upload-artifact@v3
119+ if : ${{ matrix.cov-reports }}
120+ with :
121+ name : cov-reports
122+ path : |
123+ htmlcov/
124+ .coverage
125+ coverage.xml
0 commit comments