merging report inline HTML, fixing webhook to prevent 400s from discord

This commit is contained in:
Martin McKeaveney 2022-05-20 16:47:09 +01:00
parent 692b96cfaf
commit a45c0c166f
5 changed files with 16 additions and 16 deletions

View File

@ -41,12 +41,12 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: Test Reports
path: packages/builder/cypress/reports/mocha
path: packages/builder/cypress/reports/testReport.html
- name: Cypress Discord Notify
run: yarn test:e2e:ci:report
run: yarn test:e2e:ci:notify
env:
CYPRESS_WEBHOOK_URL: ${{ secrets.BUDI_QA_WEBHOOK }}
CYPRESS_OUTCOME: ${{ steps.cypress.outcome }}
CYPRESS_DASHBOARD_URL: ${{ steps.cypress.outputs.dashboardUrl }}
GITHUB_RUN_URL: ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}
GITHUB_RUN_URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID

View File

@ -49,7 +49,7 @@
"test:e2e": "lerna run cy:test --stream",
"test:e2e:ci": "lerna run cy:ci --stream",
"test:e2e:ci:record": "lerna run cy:ci:record --stream",
"test:e2e:ci:report": "lerna run cy:ci:report",
"test:e2e:ci:notify": "lerna run cy:ci:notify",
"build:specs": "lerna run specs",
"build:docker": "lerna run build:docker && npm run build:docker:proxy:compose && cd hosting/scripts/linux/ && ./release-to-docker-hub.sh $BUDIBASE_RELEASE_VERSION && cd -",
"build:docker:proxy": "docker build hosting/proxy -t proxy-service",

View File

@ -17,8 +17,9 @@
"cy:run:ci:record": "xvfb-run cypress run --headed --browser chrome --record",
"cy:test": "start-server-and-test cy:setup http://localhost:4100/builder cy:run",
"cy:ci": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:run:ci",
"cy:ci:record": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:run:ci:record",
"cy:ci:report": "node scripts/cypressResultsWebhook",
"cy:ci:record": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:run:ci:record && npm run cy:ci:report",
"cy:ci:report": "mochawesome-merge cypress/reports/*.json > cypress/reports/testReport.json && marge cypress/reports/testReport.json --reportDir cypress/reports --inline",
"cy:ci:notify": "node scripts/cypressResultsWebhook",
"cy:debug": "start-server-and-test cy:setup http://localhost:4100/builder cy:open",
"cy:debug:ci": "start-server-and-test cy:setup:ci http://localhost:4100/builder cy:open"
},

View File

@ -1,10 +1,10 @@
{
"reporterEnabled": "mochawesome",
"mochawesomeReporterOptions": {
"reportDir": "cypress/reports/mocha",
"reportDir": "cypress/reports",
"quiet": true,
"overwrite": false,
"html": true,
"html": false,
"json": true
}
}

View File

@ -2,7 +2,7 @@
const fetch = require("node-fetch")
const path = require("path")
const { merge } = require("mochawesome-merge")
const fs = require("fs")
const WEBHOOK_URL = process.env.CYPRESS_WEBHOOK_URL
const OUTCOME = process.env.CYPRESS_OUTCOME
@ -17,11 +17,10 @@ async function generateReport() {
"..",
"cypress",
"reports",
"mocha",
"*.json"
"testReport.json"
)
const testReport = await merge({ files: [REPORT_PATH] })
return testReport
const report = fs.readFileSync(REPORT_PATH, "utf-8")
return JSON.parse(report)
}
async function discordCypressResultsNotification(report) {
@ -66,7 +65,7 @@ async function discordCypressResultsNotification(report) {
fields: [
{
name: "Commit",
value: GIT_SHA || "None Supplied",
value: `https://github.com/Budibase/budibase/commit/${GIT_SHA}`,
},
{
name: "Cypress Dashboard URL",
@ -74,7 +73,7 @@ async function discordCypressResultsNotification(report) {
},
{
name: "Github Actions Run URL",
value: GITHUB_ACTIONS_RUN_URL,
value: GITHUB_ACTIONS_RUN_URL || "None Supplied",
},
{
name: "Test Suites",
@ -106,7 +105,7 @@ async function discordCypressResultsNotification(report) {
},
{
name: "Pass Percentage",
value: passPercent,
value: Math.floor(passPercent),
},
],
},