From 12b59efa5b2ce36cb758d5508e4c81b0ab92e359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Thu, 2 Nov 2023 21:21:39 +0100 Subject: [PATCH] fix --- .github/workflows/e2e-tests.yaml | 81 ++++++++++++++++++++++++++++--- tests/AutoReview/E2ECollector.php | 5 ++ tests/AutoReview/GAE2ETest.php | 7 ++- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index cf0c2df8..bc26481e 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -8,7 +8,7 @@ on: types: [ created ] schedule: # Do not make it the first of the month and/or midnight since it is a very busy time - - cron: "* 10 5 * *" + - cron: "* 10 5 * *" # See https://stackoverflow.com/a/72408109 concurrency: @@ -93,7 +93,6 @@ jobs: - 'e2e_035' - 'e2e_036' - 'e2e_037' - - 'e2e_038' php: - '8.1' - '8.2' @@ -150,6 +149,71 @@ jobs: - name: Run e2e ${{ matrix.e2e }} run: make ${{ matrix.e2e }} --debug + + # Most of the job definitions come from https://github.com/sebastianbergmann/phpunit/blob/main/.github/workflows/ci.yml#L228 + # (job name "test-phar"). + test-phpunit-scoping: + runs-on: ubuntu-latest + needs: build-test-phar + + env: + PHP_EXTENSIONS: none, curl, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter + PHP_INI_VALUES: assert.exception=1, phar.readonly=0, zend.assertions=1 + + strategy: + fail-fast: false + matrix: + php-version: + - '8.2' + coverage: + - xdebug + + steps: + - name: Checkout PHPUnit code + uses: actions/checkout@v4 + with: + repository: 'sebastianbergmann/phpunit' + + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: ${{ matrix.coverage }} + extensions: ${{ env.PHP_EXTENSIONS }} + ini-values: ${{ env.PHP_INI_VALUES }} + tools: none + + - name: Install java + uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: 11 + + - name: Retrieve built PHP-Scoper PHAR + uses: actions/download-artifact@v3 + with: + name: php-scoper-phar-${{ matrix.php }} + path: bin + + # See https://github.com/actions/download-artifact#limitations + # the permissions are not guaranteed to be preserved + - name: Ensure PHAR is executable + run: chmod 755 bin/php-scoper.phar + + - name: Make the downloaded PHP-Scoper PHAR the PHPUnit scoper used + run: mv -f bin/php-scoper.phar tools/php-scoper + + - name: Check that the PHP-Scoper PHAR works + run: tools/php-scoper --version + + - name: Build PHPUnit scoped PHAR + run: ant phar-snapshot + + - name: Run PHPUnit PHAR-specific tests + run: ant run-phar-specific-tests + + # This is a "trick", a meta task which does not change, and we can use in # the protected branch rules as opposed to the E2E tests one above which # may change regularly. @@ -161,12 +225,13 @@ jobs: needs: - build-test-phar - e2e-tests + - test-phpunit-scoping if: always() steps: - - name: Successful run - if: ${{ !(contains(needs.*.result, 'failure')) }} - run: exit 0 + - name: Successful run + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 - - name: Failing run - if: ${{ contains(needs.*.result, 'failure') }} - run: exit 1 + - name: Failing run + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 diff --git a/tests/AutoReview/E2ECollector.php b/tests/AutoReview/E2ECollector.php index 10e3f2fd..29092ff7 100644 --- a/tests/AutoReview/E2ECollector.php +++ b/tests/AutoReview/E2ECollector.php @@ -44,6 +44,10 @@ final class E2ECollector 'set012', ]; + private const E2E_TEST_WITHOUT_FIXTURE_DIR = [ + 'e2e_038', + ]; + /** * @return list */ @@ -74,6 +78,7 @@ private static function findE2ENames(): array iterator_to_array($finder, false), ), ); + $names = [...$names, ...self::E2E_TEST_WITHOUT_FIXTURE_DIR]; sort($names, SORT_STRING); diff --git a/tests/AutoReview/GAE2ETest.php b/tests/AutoReview/GAE2ETest.php index b0b89262..d647fc9c 100644 --- a/tests/AutoReview/GAE2ETest.php +++ b/tests/AutoReview/GAE2ETest.php @@ -15,6 +15,7 @@ namespace Humbug\PhpScoper\AutoReview; use PHPUnit\Framework\TestCase; +use function array_diff; /** * @coversNothing @@ -23,9 +24,13 @@ */ class GAE2ETest extends TestCase { + private const IGNORED_E2E_TESTS = [ + 'e2e_038', + ]; + public function test_github_actions_executes_all_the_e2e_tests(): void { - $expected = E2ECollector::getE2ENames(); + $expected = array_diff(E2ECollector::getE2ENames(), self::IGNORED_E2E_TESTS); $actual = GAE2ECollector::getExecutedE2ETests(); self::assertEqualsCanonicalizing($expected, $actual);