From a45c0c166fe253078ca28c9dfa366f9a9ef66a51 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 20 May 2022 16:47:09 +0100 Subject: [PATCH] merging report inline HTML, fixing webhook to prevent 400s from discord --- .github/workflows/smoke_test.yaml | 6 +++--- package.json | 2 +- packages/builder/package.json | 5 +++-- packages/builder/reporterConfig.json | 4 ++-- packages/builder/scripts/cypressResultsWebhook.js | 15 +++++++-------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/smoke_test.yaml b/.github/workflows/smoke_test.yaml index 09da7ec44e..7002c8335b 100644 --- a/.github/workflows/smoke_test.yaml +++ b/.github/workflows/smoke_test.yaml @@ -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 diff --git a/package.json b/package.json index 28d234ee89..bd71dd6bc7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/builder/package.json b/packages/builder/package.json index 91be8932c9..a21c9bb274 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -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" }, diff --git a/packages/builder/reporterConfig.json b/packages/builder/reporterConfig.json index a3b713a3cd..2c2ef7c138 100644 --- a/packages/builder/reporterConfig.json +++ b/packages/builder/reporterConfig.json @@ -1,10 +1,10 @@ { "reporterEnabled": "mochawesome", "mochawesomeReporterOptions": { - "reportDir": "cypress/reports/mocha", + "reportDir": "cypress/reports", "quiet": true, "overwrite": false, - "html": true, + "html": false, "json": true } } \ No newline at end of file diff --git a/packages/builder/scripts/cypressResultsWebhook.js b/packages/builder/scripts/cypressResultsWebhook.js index f224664120..457093e013 100644 --- a/packages/builder/scripts/cypressResultsWebhook.js +++ b/packages/builder/scripts/cypressResultsWebhook.js @@ -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), }, ], },