Skip to content

Test Converters

Test Converters #229

name: frameworkTesting
run-name: Test Converters
on:
push:
branches:
- main
paths:
- "src/**"
- "package.json"
pull_request:
branches:
- main
paths:
- "src/**"
- "package.json"
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
env:
E2G_CACHE_FOLDER: 'tmp/e2g-cache'
- 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 (if owner)
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dickwolff'
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]
if: github.event_name != 'pull_request'
with:
filename: coverage/*.xml
hide_branch_rate: true
hide_complexity: true
badge: true
output: 'file'
- name: Extract code coverage badge
if: github.event_name != 'pull_request'
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')
[[ $condition == "critical" ]] && color="#e05d44" || color="#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
if: github.event_name != 'pull_request'
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: dd5dc24ffa62de59b3d836f856f48a10
file_path: cov.json