From bcc73253e08ca5f11ac287b9e45e0ce1a5d7e042 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jun 2023 16:35:25 +0100 Subject: [PATCH 1/4] Test --- .github/workflows/element-web.yaml | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/.github/workflows/element-web.yaml b/.github/workflows/element-web.yaml index d369641f171..ab805294e63 100644 --- a/.github/workflows/element-web.yaml +++ b/.github/workflows/element-web.yaml @@ -85,3 +85,79 @@ jobs: path: element-web/webapp # We'll only use this in a triggered job, then we're done with it retention-days: 1 + + tests: + name: "Run Tests" + needs: build + runs-on: ubuntu-latest + permissions: + actions: read + issues: read + pull-requests: read + environment: Cypress + steps: + - uses: browser-actions/setup-chrome@c485fa3bab6be59dce18dbc18ef6ab7cbc8ff5f1 + - run: echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV + + - uses: actions/download-artifact@v3 + with: + name: previewbuild + path: webapp + + - uses: actions/checkout@v3 + with: + persist-credentials: false + path: matrix-react-sdk + + - name: Run Cypress tests + uses: cypress-io/github-action@fbfad281d97a63e3e8a605ebfccba8dbea8aea93 + with: + working-directory: matrix-react-sdk + # The built-in Electron runner seems to grind to a halt trying + # to run the tests, so use chrome. + browser: "${{ env.BROWSER_PATH }}" + start: npx serve -p 8080 ../webapp + wait-on: "http://localhost:8080" + record: true + command-prefix: "yarn percy exec --parallel --" + config: '{"reporter":"cypress-multi-reporters", "reporterOptions": { "configFile": "cypress-ci-reporter-config.json" } }' + ci-build-id: ${{ needs.prepare.outputs.uuid }} + env: + # pass the Dashboard record key as an environment variable + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + + # Use existing chromium rather than downloading another + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true + + # pass GitHub token to allow accurately detecting a build vs a re-run build + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # make Node's os.tmpdir() return something where we actually have permissions + TMPDIR: ${{ runner.temp }} + + # tell Cypress more details about the context of this run + COMMIT_INFO_BRANCH: ${{ github.event.workflow_run.head_branch }} + COMMIT_INFO_SHA: ${{ github.event.workflow_run.head_sha }} + COMMIT_INFO_REMOTE: ${{ github.repositoryUrl }} + COMMIT_INFO_MESSAGE: ${{ needs.prepare.outputs.commit_message }} + COMMIT_INFO_AUTHOR: ${{ needs.prepare.outputs.commit_author }} + COMMIT_INFO_EMAIL: ${{ needs.prepare.outputs.commit_email }} + CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }} + CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }} + + - name: Upload Artifact + if: failure() + uses: actions/upload-artifact@v3 + with: + name: cypress-results + path: | + matrix-react-sdk/cypress/screenshots + matrix-react-sdk/cypress/videos + matrix-react-sdk/cypress/synapselogs + + - name: Upload reports + if: always() + uses: actions/upload-artifact@v3 + with: + name: cypress-junit + path: matrix-react-sdk/cypress/results From df38af81d029e1ad2cac50e3f0bf0b4e74b22c91 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jun 2023 16:45:39 +0100 Subject: [PATCH 2/4] Iterate --- .github/workflows/element-web.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/element-web.yaml b/.github/workflows/element-web.yaml index ab805294e63..0540f08d322 100644 --- a/.github/workflows/element-web.yaml +++ b/.github/workflows/element-web.yaml @@ -96,8 +96,8 @@ jobs: pull-requests: read environment: Cypress steps: - - uses: browser-actions/setup-chrome@c485fa3bab6be59dce18dbc18ef6ab7cbc8ff5f1 - - run: echo "BROWSER_PATH=$(which chrome)" >> $GITHUB_ENV + - id: setup-chrome + uses: browser-actions/setup-chrome@c485fa3bab6be59dce18dbc18ef6ab7cbc8ff5f1 - uses: actions/download-artifact@v3 with: @@ -113,9 +113,8 @@ jobs: uses: cypress-io/github-action@fbfad281d97a63e3e8a605ebfccba8dbea8aea93 with: working-directory: matrix-react-sdk - # The built-in Electron runner seems to grind to a halt trying - # to run the tests, so use chrome. - browser: "${{ env.BROWSER_PATH }}" + # The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome. + browser: ${{ steps.setup-chrome.outputs.chrome-path }} start: npx serve -p 8080 ../webapp wait-on: "http://localhost:8080" record: true @@ -145,6 +144,9 @@ jobs: CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }} CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }} + PERCY_BROWSER_EXECUTABLE: ${{ steps.setup-chrome.outputs.chrome-path }} + PERCY_ENABLE: 0 + - name: Upload Artifact if: failure() uses: actions/upload-artifact@v3 From dcc8323cac399e1354d910225d83b8b9bdac1ccb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jun 2023 16:53:37 +0100 Subject: [PATCH 3/4] Try headed mode --- .github/workflows/element-web.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/element-web.yaml b/.github/workflows/element-web.yaml index 0540f08d322..4314c228bb7 100644 --- a/.github/workflows/element-web.yaml +++ b/.github/workflows/element-web.yaml @@ -115,6 +115,7 @@ jobs: working-directory: matrix-react-sdk # The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome. browser: ${{ steps.setup-chrome.outputs.chrome-path }} + headed: true start: npx serve -p 8080 ../webapp wait-on: "http://localhost:8080" record: true From 83c2061597db46b56394e59ed3bb4b191c22265a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jun 2023 17:17:12 +0100 Subject: [PATCH 4/4] Switch Cypress to headed mode --- .github/workflows/cypress.yaml | 8 +-- .github/workflows/element-web.yaml | 79 ------------------------------ 2 files changed, 4 insertions(+), 83 deletions(-) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 012a4b65bb2..b470ad99227 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -166,9 +166,9 @@ jobs: uses: cypress-io/github-action@fbfad281d97a63e3e8a605ebfccba8dbea8aea93 with: working-directory: matrix-react-sdk - # The built-in Electron runner seems to grind to a halt trying - # to run the tests, so use chrome. - browser: "${{ env.BROWSER_PATH }}" + # The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome. + browser: ${{ steps.setup-chrome.outputs.chrome-path }} + headed: true start: npx serve -p 8080 ../webapp wait-on: "http://localhost:8080" record: true @@ -202,7 +202,7 @@ jobs: # pass the Percy token as an environment variable PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} PERCY_ENABLE: ${{ needs.prepare.outputs.percy_enable }} - PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium-browser + PERCY_BROWSER_EXECUTABLE: ${{ steps.setup-chrome.outputs.chrome-path }} # tell Percy more details about the context of this run PERCY_BRANCH: ${{ github.event.workflow_run.head_branch }} PERCY_COMMIT: ${{ github.event.workflow_run.head_sha }} diff --git a/.github/workflows/element-web.yaml b/.github/workflows/element-web.yaml index 4314c228bb7..d369641f171 100644 --- a/.github/workflows/element-web.yaml +++ b/.github/workflows/element-web.yaml @@ -85,82 +85,3 @@ jobs: path: element-web/webapp # We'll only use this in a triggered job, then we're done with it retention-days: 1 - - tests: - name: "Run Tests" - needs: build - runs-on: ubuntu-latest - permissions: - actions: read - issues: read - pull-requests: read - environment: Cypress - steps: - - id: setup-chrome - uses: browser-actions/setup-chrome@c485fa3bab6be59dce18dbc18ef6ab7cbc8ff5f1 - - - uses: actions/download-artifact@v3 - with: - name: previewbuild - path: webapp - - - uses: actions/checkout@v3 - with: - persist-credentials: false - path: matrix-react-sdk - - - name: Run Cypress tests - uses: cypress-io/github-action@fbfad281d97a63e3e8a605ebfccba8dbea8aea93 - with: - working-directory: matrix-react-sdk - # The built-in Electron runner seems to grind to a halt trying to run the tests, so use chrome. - browser: ${{ steps.setup-chrome.outputs.chrome-path }} - headed: true - start: npx serve -p 8080 ../webapp - wait-on: "http://localhost:8080" - record: true - command-prefix: "yarn percy exec --parallel --" - config: '{"reporter":"cypress-multi-reporters", "reporterOptions": { "configFile": "cypress-ci-reporter-config.json" } }' - ci-build-id: ${{ needs.prepare.outputs.uuid }} - env: - # pass the Dashboard record key as an environment variable - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - - # Use existing chromium rather than downloading another - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true - - # pass GitHub token to allow accurately detecting a build vs a re-run build - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # make Node's os.tmpdir() return something where we actually have permissions - TMPDIR: ${{ runner.temp }} - - # tell Cypress more details about the context of this run - COMMIT_INFO_BRANCH: ${{ github.event.workflow_run.head_branch }} - COMMIT_INFO_SHA: ${{ github.event.workflow_run.head_sha }} - COMMIT_INFO_REMOTE: ${{ github.repositoryUrl }} - COMMIT_INFO_MESSAGE: ${{ needs.prepare.outputs.commit_message }} - COMMIT_INFO_AUTHOR: ${{ needs.prepare.outputs.commit_author }} - COMMIT_INFO_EMAIL: ${{ needs.prepare.outputs.commit_email }} - CYPRESS_PULL_REQUEST_ID: ${{ needs.prepare.outputs.pr_id }} - CYPRESS_PULL_REQUEST_URL: https://github.com/${{ github.repository }}/pull/${{ needs.prepare.outputs.pr_id }} - - PERCY_BROWSER_EXECUTABLE: ${{ steps.setup-chrome.outputs.chrome-path }} - PERCY_ENABLE: 0 - - - name: Upload Artifact - if: failure() - uses: actions/upload-artifact@v3 - with: - name: cypress-results - path: | - matrix-react-sdk/cypress/screenshots - matrix-react-sdk/cypress/videos - matrix-react-sdk/cypress/synapselogs - - - name: Upload reports - if: always() - uses: actions/upload-artifact@v3 - with: - name: cypress-junit - path: matrix-react-sdk/cypress/results