diff --git a/.eslintignore b/.eslintignore index 55058ece812..8bb41d4fcdf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,5 @@ target/ fixture/ storybook-static/ playwright-report/ +blob-report/ +all-blob-reports/ diff --git a/.github/workflows/pull_request_packages.yml b/.github/workflows/pull_request_packages.yml index d98a080b979..1ef5a053194 100644 --- a/.github/workflows/pull_request_packages.yml +++ b/.github/workflows/pull_request_packages.yml @@ -88,6 +88,40 @@ jobs: with: ref: refs/pull/${{ github.event.pull_request.number }}/merge + test_e2e_prepare_report: + needs: test_e2e + name: Prepare e2e's HTML report + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-scripts + + - name: Download Playwright blob reports from GitHub Actions Artifacts + uses: actions/download-artifact@v3 + with: + name: all-blob-reports + path: all-blob-reports + + - name: Merge Playwright blob reports into HTML Report + run: yarn run playwright:cmd:merge-reports --reporter html ./all-blob-reports + + - name: Upload Playwright HTML report to GitHub Actions Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: playwright-report + path: playwright-report + retention-days: 30 + analyze_bundle_size: if: ${{ needs.changed_files.outputs.package_vkui == 'true' }} needs: changed_files @@ -126,7 +160,7 @@ jobs: - changed_files - linters - test - - test_e2e + - test_e2e_prepare_report runs-on: ubuntu-latest name: Report CI results steps: @@ -140,13 +174,12 @@ jobs: with: name: test-output - - name: Download Playwright Report artifact - # см. [Примечание 1] + - name: Download Playwright HTML report from GitHub Actions Artifacts if: ${{ needs.changed_files.outputs.package_vkui == 'true' }} uses: actions/download-artifact@v3 with: name: playwright-report - path: playwright-report/ + path: playwright-report - name: Upload Playwright Report if: ${{ needs.changed_files.outputs.package_vkui == 'true' }} diff --git a/.github/workflows/reusable_workflow_test_e2e.yml b/.github/workflows/reusable_workflow_test_e2e.yml index 10c03802134..604dd594f01 100644 --- a/.github/workflows/reusable_workflow_test_e2e.yml +++ b/.github/workflows/reusable_workflow_test_e2e.yml @@ -16,7 +16,12 @@ jobs: # см. https://github.com/microsoft/playwright/blob/main/utils/docker/Dockerfile.focal image: mcr.microsoft.com/playwright:v1.37.0-focal options: --ipc=host - name: Run visual (aka e2e) tests + strategy: + fail-fast: false + matrix: + shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + shardTotal: [10] + name: 'Run e2e tests for (shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }})' steps: - name: Checkout uses: actions/checkout@v3 @@ -56,30 +61,12 @@ jobs: - name: Run e2e tests for @vkontakte/vkui workspace # Почему HOME=/root см. https://github.com/microsoft/playwright/issues/6500 - run: HOME=/root yarn run test:e2e:ci + run: HOME=/root yarn run test:e2e:ci --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} - # TODO Playwright реализовать покрытие - # - name: Upload coverage to Codecov - # uses: codecov/codecov-action@v3 - # with: - # token: ${{ secrets.CODECOV_TOKEN }} - # flags: e2e-${{ matrix.browser }}-${{ matrix.platform }}-${{ matrix.appearance }} - # files: .nyc_output/coverage.json - # fail_ci_if_error: true - - - name: Upload test artifact - uses: actions/upload-artifact@v3 + - name: Upload Playwright blob report to GitHub Actions Artifacts if: always() - with: - name: e2e-output - path: | - packages/vkui/__diff_output__/ - packages/vkui/e2e-results.json - - - name: Upload Playwright HTML report uses: actions/upload-artifact@v3 - if: always() with: - name: playwright-report - path: packages/vkui/playwright-report/ - retention-days: 30 + name: all-blob-reports + path: packages/vkui/blob-report + retention-days: 1 diff --git a/.gitignore b/.gitignore index d8d7df4944a..a8f7173ba0e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ lint-results.json e2e-results.json yarn-error.log playwright-report/ +blob-report/ +all-blob-reports/ # Caches .cache diff --git a/.prettierignore b/.prettierignore index 289cb1a4149..c784a5c25db 100644 --- a/.prettierignore +++ b/.prettierignore @@ -17,3 +17,5 @@ target/ fixture/ storybook-static/ playwright-report/ +blob-report/ +all-blob-reports/ diff --git a/package.json b/package.json index b4db31f1b7f..31a6dd8235e 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "prepare": "husky install", "pre-commit": "lint-staged", "playwright:install": "playwright install --with-deps", + "playwright:cmd:merge-reports": "playwright merge-reports", "codesandbox:install": "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 yarn install", "deduplicate": "yarn-deduplicate --list && yarn-deduplicate --fail" }, diff --git a/packages/vkui/playwright-ct.config.ts b/packages/vkui/playwright-ct.config.ts index 4532bcfdef5..2e9dcd3c374 100644 --- a/packages/vkui/playwright-ct.config.ts +++ b/packages/vkui/playwright-ct.config.ts @@ -22,10 +22,7 @@ const TS_CONFIG_ALIASES = Object.entries(tsconfig.compilerOptions.paths).reduce< return aliases; }, {}); -const DEFAULT_REPORTERS: ReporterDescription[] = [ - ['html', { open: 'never' }], - ['json', { outputFile: 'e2e-results.json' }], -]; +const DEFAULT_REPORTERS: ReporterDescription[] = [['json', { outputFile: 'e2e-results.json' }]]; /** * See https://playwright.dev/docs/test-configuration. @@ -56,16 +53,18 @@ export default defineConfig({ forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: 0, + /* Limit the number of failures on CI to save resources. */ + maxFailures: process.env.CI ? 10 : undefined, /* Opt out of parallel tests on CI. */ workers: process.env.CI - ? 4 + ? 1 : typeof process.env.PLAYWRIGHT_WORKERS === 'string' ? Number(process.env.PLAYWRIGHT_WORKERS) : undefined, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: process.env.CI - ? [['github'], ['dot'], ...DEFAULT_REPORTERS] - : [['list'], ...DEFAULT_REPORTERS], + ? [['github'], ['dot'], ['blob'], ...DEFAULT_REPORTERS] + : [['list'], ['html', { open: 'never' }], ...DEFAULT_REPORTERS], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: {