diff --git a/.badges/backend-coverage.json b/.badges/backend-coverage.json new file mode 100644 index 00000000..9f370b1c --- /dev/null +++ b/.badges/backend-coverage.json @@ -0,0 +1 @@ +{"schemaVersion":1,"label":"backend coverage","message":"76%","color":"yellow"} diff --git a/.badges/backend-tests.json b/.badges/backend-tests.json new file mode 100644 index 00000000..963a6441 --- /dev/null +++ b/.badges/backend-tests.json @@ -0,0 +1 @@ +{"schemaVersion":1,"label":"backend tests","message":"844 passed","color":"brightgreen"} diff --git a/.badges/frontend-coverage.json b/.badges/frontend-coverage.json new file mode 100644 index 00000000..b539dc5d --- /dev/null +++ b/.badges/frontend-coverage.json @@ -0,0 +1 @@ +{"schemaVersion":1,"label":"frontend coverage","message":"26%","color":"red"} diff --git a/.badges/frontend-tests.json b/.badges/frontend-tests.json new file mode 100644 index 00000000..f44929af --- /dev/null +++ b/.badges/frontend-tests.json @@ -0,0 +1 @@ +{"schemaVersion":1,"label":"frontend tests","message":"8 E2E passed","color":"brightgreen"} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 419a467d..d926f9ed 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,8 +38,8 @@ jobs: COVERAGE=$(grep 'Statements' test-output.txt | tail -1 | grep -oP '[\d.]+(?=%)') mkdir -p .badges - echo "{\"schemaVersion\":1,\"label\":\"tests\",\"message\":\"${TOTAL_PASS}/${TOTAL_PASS} passed\",\"color\":\"brightgreen\"}" > .badges/tests.json - echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${COVERAGE}%\",\"color\":\"$([ $(echo \"$COVERAGE > 80\" | bc -l) -eq 1 ] && echo 'brightgreen' || ([ $(echo \"$COVERAGE > 60\" | bc -l) -eq 1 ] && echo 'yellow' || echo 'red'))\"}" > .badges/coverage.json + echo "{\"schemaVersion\":1,\"label\":\"backend tests\",\"message\":\"${TOTAL_PASS} passed\",\"color\":\"brightgreen\"}" > .badges/backend-tests.json + echo "{\"schemaVersion\":1,\"label\":\"backend coverage\",\"message\":\"${COVERAGE}%\",\"color\":\"$([ $(echo \"$COVERAGE > 80\" | bc -l) -eq 1 ] && echo 'brightgreen' || ([ $(echo \"$COVERAGE > 60\" | bc -l) -eq 1 ] && echo 'yellow' || echo 'red'))\"}" > .badges/backend-coverage.json echo "## Test Results" >> $GITHUB_STEP_SUMMARY echo "**${TOTAL_PASS} tests passed, ${TOTAL_FAIL} failed** | Coverage: ${COVERAGE}%" >> $GITHUB_STEP_SUMMARY @@ -55,7 +55,9 @@ jobs: PORT=13581 node server.js & SERVER_PID=$! sleep 5 - BASE_URL=http://localhost:13581 node test-e2e-playwright.js + BASE_URL=http://localhost:13581 node test-e2e-playwright.js 2>&1 | tee e2e-output.txt + E2E_PASS=$(grep -oP '\d+(?= passed)' e2e-output.txt | tail -1) + echo "{\"schemaVersion\":1,\"label\":\"frontend tests\",\"message\":\"${E2E_PASS:-0} E2E passed\",\"color\":\"brightgreen\"}" > .badges/frontend-tests.json kill $SERVER_PID 2>/dev/null || true - name: Publish badges diff --git a/README.md b/README.md index 14763b01..7c0aaab9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # MeshCore Analyzer -[![Tests](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/tests.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) -[![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/coverage.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) +[![Backend Tests](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/backend-tests.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) +[![Backend Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/backend-coverage.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) +[![Frontend Tests](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/frontend-tests.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) +[![Frontend Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/Kpa-clawbot/meshcore-analyzer/master/.badges/frontend-coverage.json)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) [![Deploy](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml/badge.svg)](https://github.com/Kpa-clawbot/meshcore-analyzer/actions/workflows/deploy.yml) > Self-hosted, open-source MeshCore packet analyzer — a community alternative to the closed-source `analyzer.letsmesh.net`.