Skip to content

Test Converters

Test Converters #85

name: frameworkTesting
run-name: Test Converters
on:
push:
branches:
- main
- feature/*
paths:
- "src/**"
pull_request:
branches:
- main
paths:
- "src/**"
- ".github/workflows/**" #remove later
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- run: npm install
- run: npm run test
# - name: Convert code coverage results for summary
# uses: irongut/[email protected]
# with:
# filename: coverage/*.xml
# badge: true
# format: 'markdown'
# output: 'file'
# - name: Add code coverage PR comment
# uses: marocchino/sticky-pull-request-comment@v2
# if: github.event_name == 'pull_request'
# with:
# recreate: true
# path: code-coverage-results.md
# - name: Write to job summary
# run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Convert code coverage results for badge
uses: irongut/[email protected]
with:
filename: coverage/*.xml
hide_branch_rate: true
hide_complexity: true
badge: true
output: 'file'
#https://img.shields.io/badge/Code%20Coverage-80%25-success?style=flat
#https://img.shields.io/badge/Code%20Coverage-40%25-critical?style=flat
#green=44cc11
#orange=e05d44
- name: Extract code coverage badge
run: |
read -r line < code-coverage-results.txt
coverage=$(echo "$line" | sed -n 's/.*Code%20Coverage-\([0-9]*\)%.*/\1/p')
condition=$(echo "$line" | sed -n 's/.*%25-\([a-z]*\)?.*/\1/p')
color=$(( condition == "critical" ? "#e05d44" : "#44cc11" ))
cat <<EOF > cov.json
{
"schemaVersion": 1,
"label": "Code Coverage",
"message": "$coverage",
"style": "for-the-badge",
"color": "$color"
}
- name: Publish code coverage badge
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: dd5dc24ffa62de59b3d836f856f48a10
file_path: cov.json