From fd349e16e5a78f4feff019b8e7ff989137ff1ff6 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Tue, 1 Oct 2024 17:34:13 +0300 Subject: [PATCH] ci: enable CI for screenshot testing inside Cypress CT --- .github/workflows/e2e-cypress.yml | 44 +++++++++++++++---- .../demo-cypress/cypress-image-diff.config.js | 3 ++ .../src/tests/input-phone-international.cy.ts | 2 +- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e-cypress.yml b/.github/workflows/e2e-cypress.yml index b60f18d49aba2..1a8f64f5962e4 100644 --- a/.github/workflows/e2e-cypress.yml +++ b/.github/workflows/e2e-cypress.yml @@ -1,21 +1,49 @@ name: ⚙️ Cypress component testing on: pull_request: - push: - branches: - - main + +env: + CYPRESS_BASELINE_REPO: 'baseline' + CYPRESS_RESULTS_FOLDER: 'projects/demo-cypress/tests-results' + CYPRESS_BASELINE_SNAPSHOTS: 'projects/demo-cypress/tests-results/snapshots/baseline' + CYPRESS_SNAPSHOTS_ARTIFACTS_KEY: + 'cypress-e2e-artifacts--${{ github.event.pull_request.head.sha || github.sha }}-${{ github.run_id }}-${{ + github.event.number }}' jobs: cypress: - if: ${{ !contains(github.head_ref, 'release/') }} runs-on: ubuntu-latest name: Component testing result steps: - uses: actions/checkout@v4.2.0 - - uses: taiga-family/ci/actions/setup/variables@v1.87.8 - - uses: taiga-family/ci/actions/setup/node@v1.87.8 - - run: npx tsc -p projects/demo-cypress/tsconfig.json - - run: npx nx component-test demo-cypress + - uses: actions/checkout@v4.2.0 + with: + ref: ${{ github.base_ref }} + path: ${{ env.CYPRESS_BASELINE_REPO }} + - uses: taiga-family/ci/actions/setup/variables@v1.87.7 + - uses: taiga-family/ci/actions/setup/node@v1.87.7 + - run: | + cd baseline + npx nx component-test demo-cypress + cd ../ + cp ${{ env.CYPRESS_BASELINE_REPO }}/${{ env.CYPRESS_BASELINE_SNAPSHOTS }} ${{ env.CYPRESS_BASELINE_SNAPSHOTS }} + npx nx component-test demo-cypress + - run: | + npm install canvas + npx ts-node ./scripts/visual-testing/combine-cypress-failed-screenshots.ts + + - name: Debug output + continue-on-error: true + run: tree ${{ env.CYPRESS_RESULTS_FOLDER }} -L 1 + + - name: Upload artifacts / ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }} + uses: actions/upload-artifact@v4.4.0 + with: + path: '${{ env.CYPRESS_RESULTS_FOLDER }}/**/*.diff.png' + name: ${{ env.CYPRESS_SNAPSHOTS_ARTIFACTS_KEY }} + if-no-files-found: ignore + compression-level: 0 + retention-days: 1 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/projects/demo-cypress/cypress-image-diff.config.js b/projects/demo-cypress/cypress-image-diff.config.js index d7f30e0631860..a8a11bd2b4f9e 100644 --- a/projects/demo-cypress/cypress-image-diff.config.js +++ b/projects/demo-cypress/cypress-image-diff.config.js @@ -6,4 +6,7 @@ module.exports = { FILENAME: 'report-summary', OVERWRITE: true, }, + RETRY_OPTIONS: { + doNotFail: process.env.CI || false, + }, }; diff --git a/projects/demo-cypress/src/tests/input-phone-international.cy.ts b/projects/demo-cypress/src/tests/input-phone-international.cy.ts index fe35c7b6701fd..d30189390dc3c 100644 --- a/projects/demo-cypress/src/tests/input-phone-international.cy.ts +++ b/projects/demo-cypress/src/tests/input-phone-international.cy.ts @@ -29,7 +29,7 @@ import {createOutputSpy} from 'cypress/angular'; [formControl]="control" [(countryIsoCode)]="countryIsoCode" > - + `,