|
| 1 | +name: Benchmark Tests |
| 2 | + |
| 3 | +# To be aware it need to be the counter-part of benchmark-empty.yaml. |
| 4 | +on: |
| 5 | + pull_request: ~ |
| 6 | + |
| 7 | +# See https://stackoverflow.com/a/72408109 |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +env: |
| 13 | + TERM: xterm |
| 14 | + |
| 15 | +jobs: |
| 16 | + main-bench-test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + name: Benchmark main branch |
| 19 | + steps: |
| 20 | + - name: Checkout main branch |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ref: main |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Setup PHP |
| 27 | + uses: shivammathur/setup-php@v2 |
| 28 | + with: |
| 29 | + php-version: '8.2' |
| 30 | + ini-values: phar.readonly=0, display_errors=On, error_reporting=-1 |
| 31 | + tools: composer |
| 32 | + coverage: none |
| 33 | + |
| 34 | + - name: Install Composer dependencies |
| 35 | + uses: ramsey/composer-install@v2 |
| 36 | + |
| 37 | + - name: Ensure that the make target is up to date |
| 38 | + run: make _vendor_install |
| 39 | + |
| 40 | + - name: Install PHPBench |
| 41 | + uses: ramsey/composer-install@v2 |
| 42 | + with: |
| 43 | + working-directory: vendor-bin/phpbench |
| 44 | + |
| 45 | + - name: Ensure that the PHPBench make target is up to date |
| 46 | + run: make phpbench_install |
| 47 | + |
| 48 | + - name: Run PHPBench |
| 49 | + run: make phpbench_main |
| 50 | + |
| 51 | + - uses: actions/upload-artifact@v3 |
| 52 | + name: Upload the Benchmark results |
| 53 | + with: |
| 54 | + name: bench-main-result |
| 55 | + path: dist/bench-branch-main-result.xml |
| 56 | + |
| 57 | + pr-bench-test: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + name: Benchmark PR |
| 60 | + needs: main-bench-test |
| 61 | + steps: |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + fetch-depth: 0 |
| 66 | + |
| 67 | + - name: Setup PHP |
| 68 | + uses: shivammathur/setup-php@v2 |
| 69 | + with: |
| 70 | + php-version: '8.2' |
| 71 | + ini-values: phar.readonly=0, display_errors=On, error_reporting=-1 |
| 72 | + tools: composer |
| 73 | + coverage: none |
| 74 | + |
| 75 | + - name: Install Composer dependencies |
| 76 | + uses: ramsey/composer-install@v2 |
| 77 | + |
| 78 | + - name: Ensure that the make target is up to date |
| 79 | + run: make _vendor_install |
| 80 | + |
| 81 | + - name: Install PHPBench |
| 82 | + uses: ramsey/composer-install@v2 |
| 83 | + with: |
| 84 | + working-directory: vendor-bin/phpbench |
| 85 | + |
| 86 | + - name: Ensure that the PHPBench make target is up to date |
| 87 | + run: make phpbench_install |
| 88 | + |
| 89 | + - name: Download the Benchmark results of the main branch |
| 90 | + uses: actions/download-artifact@v3 |
| 91 | + with: |
| 92 | + name: bench-branch-main-result |
| 93 | + |
| 94 | + - name: Run PHPBench against PR branch |
| 95 | + run: make phpbench_pr |
| 96 | + |
| 97 | + |
| 98 | + # This is a "trick", a meta task which does not change, and we can use in |
| 99 | + # the protected branch rules as opposed to the tests one above which |
| 100 | + # may change regularly. |
| 101 | + validate-tests: |
| 102 | + name: Benchmark tests status |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: |
| 105 | + - pr-bench-test |
| 106 | + if: always() |
| 107 | + steps: |
| 108 | + - name: Successful run |
| 109 | + if: ${{ !(contains(needs.*.result, 'failure')) }} |
| 110 | + run: exit 0 |
| 111 | + |
| 112 | + - name: Failing run |
| 113 | + if: ${{ contains(needs.*.result, 'failure') }} |
| 114 | + run: exit 1 |
0 commit comments