Create python-package.yml #208
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
- V2-stable | |
pull_request: | |
branches: | |
- master | |
- V2-stable | |
name: test-coverage | |
jobs: | |
test-coverage: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: covr | |
- name: Test coverage | |
run: covr::package_coverage() | |
shell: Rscript {0} | |
- name: Generate code coverage | |
run: | | |
set -x | |
R -e 'covr::package_coverage()' &> out.txt | |
total=$(grep "Coverage: " out.txt | grep -oP "(\d+\.\d+)") | |
if (( $(echo "$total <= 30" | bc -l) )) ; then | |
COLOR=red | |
elif (( $(echo "$total > 80" | bc -l) )); then | |
COLOR=green | |
else | |
COLOR=orange | |
fi | |
echo "TOTAL=$(echo "$total"%)" >> $GITHUB_ENV | |
echo "COLOR=$(echo "$COLOR")" >> $GITHUB_ENV | |
- name: Create code coverage badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: db82500941e9bea7d7a5c0bfd5e6db8d | |
filename: cover.json | |
label: coverage | |
message: ${{ env.TOTAL }} | |
color: ${{ env.COLOR }} | |
style: flat-square |