|
9 | 9 | performance-tests: |
10 | 10 | name: 'Performance Tests' |
11 | 11 | runs-on: ubuntu-latest |
12 | | - strategy: |
13 | | - fail-fast: false |
14 | | - matrix: |
15 | | - shard: [ 1/4, 2/4, 3/4, 4/4 ] |
16 | 12 | env: |
17 | 13 | WP_BASE_URL: 'http://localhost:8888' |
18 | 14 | WP_USERNAME: 'admin' |
@@ -55,45 +51,49 @@ jobs: |
55 | 51 |
|
56 | 52 | - name: Run tests |
57 | 53 | run: | |
58 | | - yarn test:performance --shard ${{ matrix.shard }} |
| 54 | + yarn test:performance |
| 55 | + mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_after.json |
59 | 56 |
|
60 | | - - name: Upload blob report to GitHub Actions Artifacts |
61 | | - if: always() |
62 | | - uses: actions/upload-artifact@v4 |
63 | | - with: |
64 | | - name: all-blob-reports |
65 | | - path: blob-report |
66 | | - retention-days: 1 |
67 | | - |
68 | | - merge-reports: |
69 | | - # Merge reports after playwright-tests, even if some shards have failed |
70 | | - if: always() |
71 | | - needs: [ performance-tests ] |
72 | | - runs-on: ubuntu-latest |
73 | | - steps: |
74 | | - - uses: actions/checkout@v4 |
75 | | - |
76 | | - - name: Setup Node |
77 | | - uses: actions/setup-node@v4 |
78 | | - with: |
79 | | - node-version-file: '.nvmrc' |
80 | | - cache: yarn |
| 57 | + - name: Check out base commit |
| 58 | + run: | |
| 59 | + if [[ -z "$BASE_REF" ]]; then |
| 60 | + git fetch -n origin $BASE_SHA |
| 61 | + git reset --hard $BASE_SHA |
| 62 | + else |
| 63 | + git fetch -n origin $BASE_REF |
| 64 | + git reset --hard $BASE_SHA |
| 65 | + fi |
| 66 | + env: |
| 67 | + BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }} |
| 68 | + BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} |
| 69 | + |
| 70 | + # Run tests without causing job to fail if they don't pass (e.g. because of env issues). |
| 71 | + - name: Run tests for base |
| 72 | + run: | |
| 73 | + npm run test:performance || true |
| 74 | + if [ -f "{{ env.WP_ARTIFACTS_PATH }}/performance-results.json" ]; then |
| 75 | + mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_before.json |
| 76 | + fi; |
81 | 77 |
|
82 | | - - name: Install dependencies |
83 | | - run: yarn install --immutable |
| 78 | + - name: Reset to original commit |
| 79 | + run: | |
| 80 | + git reset --hard $GITHUB_SHA |
84 | 81 |
|
85 | | - - name: Download blob reports from GitHub Actions Artifacts |
86 | | - uses: actions/download-artifact@v4 |
87 | | - with: |
88 | | - name: all-blob-reports |
89 | | - path: all-blob-reports |
| 82 | + - name: Compare results with base |
| 83 | + run: | |
| 84 | + if [ -f "${{ runner.temp }}/results_before.json" ]; then |
| 85 | + yarn test:performance:results ${{ runner.temp }}/results_after.json ${{ runner.temp }}/results_before.json |
| 86 | + else |
| 87 | + yarn test:performance:results ${{ runner.temp }}/results_after.json |
| 88 | + fi; |
90 | 89 |
|
91 | | - - name: Merge into single performance report |
92 | | - run: yarn test:performance:merge-reports |
| 90 | + - name: Add workflow summary |
| 91 | + run: | |
| 92 | + cat ${{ env.WP_ARTIFACTS_PATH }}/performance-results.md >> $GITHUB_STEP_SUMMARY |
93 | 93 |
|
94 | | - - name: Upload performance report |
| 94 | + - name: Upload performance results |
| 95 | + if: success() |
95 | 96 | uses: actions/upload-artifact@v4 |
96 | 97 | with: |
97 | | - name: performance-report-${{ github.run_attempt }} |
98 | | - path: artifacts/performance-results.json |
99 | | - retention-days: 14 |
| 98 | + name: performance-results |
| 99 | + path: ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json |
0 commit comments