Narrow foreach body to non-empty regardless of polluteScopeWithAlwaysIterableForeach #4412
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Benchmark" | |
| on: | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - '.github/workflows/bench.yml' | |
| - 'tests/bench/**' | |
| push: | |
| branches: | |
| - "2.2.x" | |
| paths: | |
| - 'src/**' | |
| - '.github/workflows/bench.yml' | |
| - 'tests/bench/**' | |
| concurrency: | |
| group: bench-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| baseline: | |
| name: "Baseline (PHP ${{ matrix.php-version }})" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: | |
| - "7.4" | |
| - "8.5" | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: "Checkout base branch" | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| - name: "Install PHP" | |
| uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # 2.37.2 | |
| with: | |
| coverage: "none" | |
| php-version: "${{ matrix.php-version }}" | |
| tools: pecl | |
| extensions: ds,mbstring | |
| ini-file: development | |
| ini-values: memory_limit=-1 | |
| - name: "Downgrade PHPUnit" | |
| if: matrix.php-version == '7.4' | |
| run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 doctrine/instantiator:^1.0 --update-with-dependencies --ignore-platform-reqs" | |
| - uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0 | |
| # tests/composer.json pins the Composer platform to PHP 8.2, which would make | |
| # Composer resolve PHPBench's Symfony dependencies to versions that cannot | |
| # even be parsed on PHP 7.4. Unsetting it resolves against the real PHP version. | |
| - name: "Downgrade PHPBench" | |
| if: matrix.php-version == '7.4' | |
| run: | | |
| composer config --unset platform.php --working-dir=tests | |
| composer require --dev phpbench/phpbench:1.2.14 phpunit/phpunit:^9.6 brianium/paratest:^6.5 --update-with-all-dependencies --working-dir=tests | |
| - uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0 | |
| if: matrix.php-version != '7.4' | |
| with: | |
| working-directory: "tests/" | |
| - uses: ./.github/actions/downgrade-code | |
| with: | |
| php-version: "${{ matrix.php-version }}" | |
| - name: "Run phpbench baseline" | |
| run: "tests/vendor/bin/phpbench run --dump-file=tests/bench/storage/baseline-${{ matrix.php-version }}.xml --ansi" | |
| # Before committing an artifact as the new baseline, compare the <baseline-machine> | |
| # values (md5, file_rw) in it with the ones in the currently committed baseline. | |
| # GitHub runners differ in speed by up to 2x, and a baseline recorded on a fast | |
| # runner makes every later run look like a regression. | |
| - name: "Upload baseline artifact" | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: phpbench-baseline-${{ matrix.php-version }} | |
| path: tests/bench/storage/baseline-${{ matrix.php-version }}.xml | |
| test: | |
| name: "Test (PHP ${{ matrix.php-version }})" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # phpbench 1.2.14 is the last version supporting PHP 7.4 | |
| # and it does not have the aggregate-preview report 'my-report' extends | |
| - php-version: "7.4" | |
| report: "aggregate" | |
| - php-version: "8.5" | |
| report: "my-report" | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | |
| with: | |
| egress-policy: audit | |
| - name: "Checkout" | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | |
| - name: "Install PHP" | |
| uses: "shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240" # 2.37.2 | |
| with: | |
| coverage: "none" | |
| php-version: "${{ matrix.php-version }}" | |
| tools: pecl | |
| extensions: ds,mbstring | |
| ini-file: development | |
| ini-values: memory_limit=-1 | |
| - name: "Downgrade PHPUnit" | |
| if: matrix.php-version == '7.4' | |
| run: "composer require --dev phpunit/phpunit:^9.6 sebastian/diff:^4.0 doctrine/instantiator:^1.0 --update-with-dependencies --ignore-platform-reqs" | |
| - uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0 | |
| # tests/composer.json pins the Composer platform to PHP 8.2, which would make | |
| # Composer resolve PHPBench's Symfony dependencies to versions that cannot | |
| # even be parsed on PHP 7.4. Unsetting it resolves against the real PHP version. | |
| - name: "Downgrade PHPBench" | |
| if: matrix.php-version == '7.4' | |
| run: | | |
| composer config --unset platform.php --working-dir=tests | |
| composer require --dev phpbench/phpbench:1.2.14 phpunit/phpunit:^9.6 brianium/paratest:^6.5 --update-with-all-dependencies --working-dir=tests | |
| - uses: "ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda" # v4.0.0 | |
| if: matrix.php-version != '7.4' | |
| with: | |
| working-directory: "tests/" | |
| - uses: ./.github/actions/downgrade-code | |
| with: | |
| php-version: "${{ matrix.php-version }}" | |
| # PHPBench does not fail when the baseline file is missing, it just runs | |
| # with an empty baseline and every assertion passes | |
| - name: "Check that the baseline exists" | |
| run: | | |
| test -f tests/bench/storage/baseline-${{ matrix.php-version }}.xml \ | |
| || (echo "Missing tests/bench/storage/baseline-${{ matrix.php-version }}.xml, download it from the phpbench-baseline-${{ matrix.php-version }} artifact of the Baseline job and commit it." && exit 1) | |
| - name: "Run phpbench test" | |
| run: "tests/vendor/bin/phpbench run --file=tests/bench/storage/baseline-${{ matrix.php-version }}.xml --report=${{ matrix.report }} --ansi" |