Skip to content

ci: set coverage badge values correctly #36

ci: set coverage badge values correctly

ci: set coverage badge values correctly #36

Workflow file for this run

name: Tests
on:
push:
branches: ["main"]
paths-ignore:
- "**.md"
pull_request:
branches: ["main"]
paths-ignore:
- "**.md"
jobs:
Jest:
name: Jest (Unit & Integration)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Launch tests
run: npm run installAll && npm run jest
- uses: actions/upload-artifact@v4
with:
name: jest-coverage
path: ./.coverage
retention-days: 30
- name: Set coverage environment variable
run: |
COVERAGE_JSON=$(cat ./.coverage/coverage-summary.json)
COVERAGE_LINES=$(echo $COVERAGE_JSON | jq -r '.total.lines.pct')
COVERAGE_BRANCHES=$(echo $COVERAGE_JSON | jq -r '.total.branches.pct')
COVERAGE_PERCENT=$(echo "scale=0; ($COVERAGE_LINES + $COVERAGE_BRANCHES) / 2" | bc)
echo "jestCoverage=$COVERAGE_PERCENT" >> $GITHUB_ENV
- name: Set coverage badge (README.md)
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.DIALPLAN_COVERAGE_SECRET }}
gistID: c6512f0c95bc37287d7118b9023b8288
filename: dialplanCoverage.json
label: Coverage
message: ${{env.jestCoverage}}%
valColorRange: ${{env.jestCoverage}}
minColorRange: 50
maxColorRange: 100
Playwright:
name: Playwright (API & E2E)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Launch project
run: docker-compose up --detach
- name: Launch tests
run: |
ATTEMPT=1
CONNECTED=false
while ! $CONNECTED; do
CONNECTED=$(curl --max-time 20 -s http://localhost:80 | grep -q "Dialplan" && echo true || echo false)
ATTEMPT=$(($ATTEMPT+1))
! $CONNECTED && echo "Failed connection attempt $ATTEMPT" && sleep 3
done
echo "Project server is ready, launching tests..."
docker-compose -f ./testing/compose.pw.yaml --env-file ./testing/ci.env up --exit-code-from playwright
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: ./testing/playwright-report
retention-days: 7