Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 2, 2023
1 parent 1c4a312 commit 12b59ef
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 9 deletions.
81 changes: 73 additions & 8 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -93,7 +93,6 @@ jobs:
- 'e2e_035'
- 'e2e_036'
- 'e2e_037'
- 'e2e_038'
php:
- '8.1'
- '8.2'
Expand Down Expand Up @@ -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.
Expand All @@ -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
5 changes: 5 additions & 0 deletions tests/AutoReview/E2ECollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ final class E2ECollector
'set012',
];

private const E2E_TEST_WITHOUT_FIXTURE_DIR = [
'e2e_038',
];

/**
* @return list<string>
*/
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion tests/AutoReview/GAE2ETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Humbug\PhpScoper\AutoReview;

use PHPUnit\Framework\TestCase;
use function array_diff;

/**
* @coversNothing
Expand All @@ -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);
Expand Down

0 comments on commit 12b59ef

Please sign in to comment.