Skip to content

Commit

Permalink
fix: Create proper summary from detox output
Browse files Browse the repository at this point in the history
  • Loading branch information
toninis committed Jun 11, 2024
1 parent 555243f commit 2151b2f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/e2e-detox-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ jobs:
with:
ref: ${{ inputs.MOBILE_VERSION }}

- name: ci/prepare-node-deps
uses: ./.github/actions/prepare-node-deps

- name: Create artifacts directory
run: mkdir -p detox/artifacts/

- name: Download All Artifacts
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
Expand Down Expand Up @@ -219,10 +213,11 @@ jobs:
id: summary
run: |
echo "FAILURES=$(cat detox/artifacts/summary.json | jq .stats.failures)" >> ${GITHUB_OUTPUT}
- name: Generate Summary
run: |
echo "$(cat detox/artifacts/summary.json | jq .statsFieldValue)" >> ${GITHUB_STEP_SUMMARY}
echo "PASSES=$(cat detox/artifacts/summary.json | jq .stats.passes)" >> ${GITHUB_OUTPUT}
echo "SKIPPED=$(cat detox/artifacts/summary.json | jq .stats.skipped)" >> ${GITHUB_OUTPUT}
echo "TOTAL=$(cat detox/artifacts/summary.json | jq .stats.tests)" >> ${GITHUB_OUTPUT}
echo "ERRORS=$(cat detox/artifacts/summary.json | jq .stats.errors)" >> ${GITHUB_OUTPUT}
echo "PERCENTAGE=$(cat detox/artifacts/summary.json | jq .stats.passPercent)" >> ${GITHUB_OUTPUT}
- name: Set Target URL
id: set-url
Expand All @@ -241,3 +236,12 @@ jobs:
else
echo "STATUS=success" >> ${GITHUB_OUTPUT}
fi
- name: Generate Summary
run: |
echo "| Tests | Passed :white_check_mark: | Failed :x: | Skipped :fast_forward: | Errors :warning: | " >> ${GITHUB_STEP_SUMMARY}
echo "|:---:|:---:|:---:|:---:|:---:|" >> ${GITHUB_STEP_SUMMARY}
echo "| ${{ steps.summary.outputs.TOTAL }} | ${{ steps.summary.outputs.PASSES }} | ${{ steps.summary.outputs.FAILURES }} | ${{ steps.summary.outputs.SKIPPED }} | ${{ steps.summary.outputs.ERRORS }} |" >> ${GITHUB_STEP_SUMMARY}
echo "" >> ${GITHUB_STEP_SUMMARY}
echo "You can check the full report [here](${{ steps.set-url.outputs.TARGET_URL }})" >> ${GITHUB_STEP_SUMMARY}
echo "There was **${{ steps.summary.outputs.PERCENTAGE }}%** success rate." >> ${GITHUB_STEP_SUMMARY}
4 changes: 2 additions & 2 deletions detox/utils/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function generateStats(allTests) {
const start = allTests.start;
const end = allTests.end;
const passes = tests - (failures + errors);
const passPercent = tests > 0 ? (passes / tests) * 100 : 0;
const passPercent = tests > 0 ? ((passes / tests) * 100).toFixed(2) : 0;

return {
suites,
Expand All @@ -134,7 +134,7 @@ function generateStatsFieldValue(stats, failedFullTitles) {
let statsFieldValue = `
| Key | Value |
|:---|:---|
| Passing Rate | ${stats.passPercent.toFixed(2)}% |
| Passing Rate | ${stats.passPercent}% |
| Duration | ${(stats.duration / (60 * 1000)).toFixed(4)} mins |
| Suites | ${stats.suites} |
| Tests | ${stats.tests} |
Expand Down

0 comments on commit 2151b2f

Please sign in to comment.