Skip to content

E2E Report Generation #492

E2E Report Generation

E2E Report Generation #492

name: E2E Report Generation
on:
workflow_run:
workflows:
- "E2E Testing"
types:
- completed
jobs:
generate-report:
runs-on: ubuntu-22.04
if: github.repository_owner == 'mattermost' && github.event.workflow_run.conclusion == 'success'
steps:
- name: e2e-report/checkout-mattermost-plugin-calls-repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: e2e-report/download-paywright-report-results
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
with:
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
path: e2e-playwright-results
pattern: e2e-playwright-results-*
merge-multiple: true
- name: e2e-report/setup-node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version-file: .nvmrc
- name: e2e-report/generate-reporting
id: stats
working-directory: e2e-playwright-results/
env:
AWS_DEFAULT_REGION: us-east-1
AWS_S3_BUCKET: mattermost-cypress-report
AWS_ACCESS_KEY_ID: ${{ secrets.MM_PLUGIN_CALLS_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MM_PLUGIN_CALLS_AWS_SECRET_ACCESS_KEY }}
run: |
DATETIME="$(date '+%Y_%m_%d__%H_%M_%S')"
echo "Generating the e2e report ... "
cp ${{ github.workspace }}/e2e/scripts/merge-reports.js .
npm install --include=dev @playwright/test playwright-merge-html-reports fs
node merge-reports.js
echo "Upload playwright report to S3 ... "
aws s3 sync merged-html-report/ s3://${AWS_S3_BUCKET}/calls-pw/${DATETIME} --no-progress --cache-control no-cache
NUM_FAILURES=0
NUM_SUCCESSES=0
for i in $(ls pw-results-*.json)
do
# can be `failed`, `flaky`, `timedOut`
NUM_FAILURES=$((NUM_FAILURES + $(jq '.suites[].suites[].specs[].tests[] | last(.results[]) | select(.status != "passed").status' < ./${i} | wc -l)))
NUM_SUCCESSES=$((NUM_SUCCESSES + $(jq '.suites[].suites[].specs[].tests[] | last(.results[]) | select(.status == "passed").status' < ./${i} | wc -l)))
done
echo "S3_REPORT=https://${AWS_S3_BUCKET}.s3.us-east-1.amazonaws.com/calls-pw/${DATETIME}/index.html" >> ${GITHUB_OUTPUT}
echo "FAILURES=${NUM_FAILURES}" >> ${GITHUB_OUTPUT}
echo "SUCCESSES=${NUM_SUCCESSES}" >> ${GITHUB_OUTPUT}
echo "TOTAL=$(( ${NUM_SUCCESSES}+${NUM_FAILURES} ))" >> ${GITHUB_OUTPUT}
- name: e2e-report/generate-summary
run: |
echo "### Playwright Results for [${{ github.event.workflow_run.head_sha }}](https://github.com/mattermost/mattermost-plugin-calls/commit/${{ github.event.workflow_run.head_sha }})" >> "${GITHUB_STEP_SUMMARY}"
echo "We had ${{ steps.stats.outputs.FAILURES }} failures" >> "${GITHUB_STEP_SUMMARY}"
echo "We had ${{ steps.stats.outputs.SUCCESSES }} successes" >> "${GITHUB_STEP_SUMMARY}"
echo "You can find the report [here](${{ steps.stats.outputs.S3_REPORT }})" >> "${GITHUB_STEP_SUMMARY}"
- name: e2e-report/send-success-status
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
with:
script: |
try {
await github.rest.repos.createCommitStatus({
owner: 'mattermost',
repo: 'mattermost-plugin-calls',
sha: '${{ github.event.workflow_run.head_sha }}',
context: 'e2e/report-summary',
description: '${{ steps.stats.outputs.SUCCESSES }}/${{ steps.stats.outputs.TOTAL }} E2E tests passed',
state: 'success',
target_url: '${{ steps.stats.outputs.S3_REPORT }}'
});
} catch (err) {
core.setFailed(`Action failed with error: ${err}`);
}