Skip to content

Commit

Permalink
Parallelize levels tests
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Feb 18, 2024
1 parent c088757 commit 938321c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/tests-levels-matrix.php
@@ -0,0 +1,32 @@
<?php declare(strict_types = 1);

shell_exec('php vendor/bin/phpunit --list-tests-xml test-list.xml');

$simpleXml = simplexml_load_file('test-list.xml');
if ($simpleXml === false) {
throw new RuntimeException('Error loading test-list.xml');
}

$testFilters = [];
foreach($simpleXml->testCaseClass as $testCaseClass) {
foreach($testCaseClass->testCaseMethod as $testCaseMethod) {
if ((string) $testCaseMethod['groups'] !== 'levels') {
continue;
}

$testCaseName = (string) $testCaseMethod['id'];

[$className, $testName] = explode('::', $testCaseName, 2);
$fileName = 'tests/'. str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';

$filter = str_replace('\\', '\\\\', $testCaseName);

$testFilters[] = sprintf("%s --filter %s", escapeshellarg($fileName), escapeshellarg($filter));
}
}

if ($testFilters === []) {
throw new RuntimeException('No tests found');
}

echo json_encode($testFilters);
36 changes: 35 additions & 1 deletion .github/workflows/tests.yml
Expand Up @@ -98,11 +98,45 @@ jobs:
- name: "Tests"
run: "make tests-integration"

tests-levels-matrix:
name: "Determine levels tests matrix"
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: "Checkout"
uses: actions/checkout@v3

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.3"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=1G

- name: "Install PHPUnit 10.x"
run: "composer remove --dev brianium/paratest && composer require --dev --with-all-dependencies phpunit/phpunit:^10"

- id: set-matrix
run: echo "matrix=$(php .github/workflows/tests-levels-matrix.php)" >> $GITHUB_OUTPUT

outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

tests-levels:
needs: tests-levels-matrix

name: "Levels tests"
runs-on: ubuntu-latest
timeout-minutes: 60

strategy:
matrix:
test-filter: "${{fromJson(needs.tests-levels-matrix.outputs.matrix)}}"

steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand All @@ -121,7 +155,7 @@ jobs:
run: "composer install --no-interaction --no-progress"

- name: "Tests"
run: "make tests-levels"
run: "php vendor/bin/phpunit ${{ matrix.test-filter }} --group levels"

tests-old-phpunit:
name: "Tests with old PHPUnit"
Expand Down
Expand Up @@ -112,6 +112,7 @@ public function create(string $projectInstallationPath): ?SourceLocator
foreach ($classMapPaths as $classMapPath) {
if (is_dir($classMapPath)) {
$locators[] = $this->optimizedDirectorySourceLocatorRepository->getOrCreate($classMapPath);
continue;
}
if (!is_file($classMapPath)) {
continue;
Expand Down

0 comments on commit 938321c

Please sign in to comment.