From 9d354a93a4465fe6d55ebbd35fb5afbaaaeb8407 Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Thu, 14 Mar 2024 11:02:02 +0000 Subject: [PATCH] Revert "uses shard to get the perf report" This reverts commit f8f7b4590184fcff27bf538a9acc8122f42c64d3. --- .github/workflows/perf-tests.yml | 78 +++++++++++++------------- tests/performance/playwright.config.ts | 2 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/perf-tests.yml b/.github/workflows/perf-tests.yml index 446efc5..b9d0dc9 100644 --- a/.github/workflows/perf-tests.yml +++ b/.github/workflows/perf-tests.yml @@ -9,10 +9,6 @@ jobs: performance-tests: name: 'Performance Tests' runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - shard: [ 1/4, 2/4, 3/4, 4/4 ] env: WP_BASE_URL: 'http://localhost:8888' WP_USERNAME: 'admin' @@ -55,45 +51,49 @@ jobs: - name: Run tests run: | - yarn test:performance --shard ${{ matrix.shard }} + yarn test:performance + mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_after.json - - name: Upload blob report to GitHub Actions Artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: all-blob-reports - path: blob-report - retention-days: 1 - - merge-reports: - # Merge reports after playwright-tests, even if some shards have failed - if: always() - needs: [ performance-tests ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: yarn + - name: Check out base commit + run: | + if [[ -z "$BASE_REF" ]]; then + git fetch -n origin $BASE_SHA + git reset --hard $BASE_SHA + else + git fetch -n origin $BASE_REF + git reset --hard $BASE_SHA + fi + env: + BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }} + BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + + # Run tests without causing job to fail if they don't pass (e.g. because of env issues). + - name: Run tests for base + run: | + npm run test:performance || true + if [ -f "{{ env.WP_ARTIFACTS_PATH }}/performance-results.json" ]; then + mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_before.json + fi; - - name: Install dependencies - run: yarn install --immutable + - name: Reset to original commit + run: | + git reset --hard $GITHUB_SHA - - name: Download blob reports from GitHub Actions Artifacts - uses: actions/download-artifact@v4 - with: - name: all-blob-reports - path: all-blob-reports + - name: Compare results with base + run: | + if [ -f "${{ runner.temp }}/results_before.json" ]; then + yarn test:performance:results ${{ runner.temp }}/results_after.json ${{ runner.temp }}/results_before.json + else + yarn test:performance:results ${{ runner.temp }}/results_after.json + fi; - - name: Merge into single performance report - run: yarn test:performance:merge-reports + - name: Add workflow summary + run: | + cat ${{ env.WP_ARTIFACTS_PATH }}/performance-results.md >> $GITHUB_STEP_SUMMARY - - name: Upload performance report + - name: Upload performance results + if: success() uses: actions/upload-artifact@v4 with: - name: performance-report-${{ github.run_attempt }} - path: artifacts/performance-results.json - retention-days: 14 + name: performance-results + path: ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json diff --git a/tests/performance/playwright.config.ts b/tests/performance/playwright.config.ts index fb8d13e..ae56a4a 100644 --- a/tests/performance/playwright.config.ts +++ b/tests/performance/playwright.config.ts @@ -13,7 +13,7 @@ process.env.STORAGE_STATE_PATH ??= join( process.env.WP_ARTIFACTS_PATH, authStoragePath ); -process.env.TEST_ITERATIONS ??= '20'; +process.env.TEST_ITERATIONS ??= '4'; const config = defineConfig({ globalSetup: require.resolve('../e2e/global-setup.ts'),