Skip to content

Commit

Permalink
NEW Pass in-memory-cache input for extra_jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jul 9, 2024
1 parent 350589f commit 0332303
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
phpunit:
type: boolean
default: true
phpunit_skip_suites:
type: string
required: false
default: ''
js:
type: boolean
default: true
Expand Down Expand Up @@ -146,6 +150,7 @@ runs:
echo "phplinting: ${{ inputs.phplinting }}" >> __inputs.yml
echo "phpunit: ${{ inputs.phpunit }}" >> __inputs.yml
echo "doclinting: ${{ inputs.doclinting }}" >> __inputs.yml
echo "phpunit_skip_suites: ${{ inputs.phpunit_skip_suites }}" >> __inputs.yml
echo "dynamic_matrix: ${{ inputs.dynamic_matrix }}" >> __inputs.yml
echo "simple_matrix: ${{ inputs.simple_matrix }}" >> __inputs.yml
echo "github_repository: '$GITHUB_REPOSITORY'" >> __inputs.yml
Expand Down
16 changes: 14 additions & 2 deletions job_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public function createJob(int $phpIndex, array $opts): array
'endtoend_config' => '',
'js' => false,
'doclinting' => false,
'install_inmemory_cache_exts' => false,
// Needs full setup if installerVersion is set, OR this is a recipe
'needs_full_setup' => $this->installerVersion !== '' || (isset($this->repoData['type']) && $this->repoData['type'] === 'recipe'),
];
Expand Down Expand Up @@ -389,7 +390,8 @@ private function buildDynamicMatrix(
array $matrix,
array $run,
bool $composerInstall,
bool $simpleMatrix
bool $simpleMatrix,
array $skipPhpunitSuites
): array {
if ($run['phpunit'] && (file_exists('phpunit.xml') || file_exists('phpunit.xml.dist'))) {
$dom = new DOMDocument();
Expand All @@ -402,6 +404,9 @@ private function buildDynamicMatrix(
continue;
}
$suite = $testsuite->getAttribute('name');
if (in_array($suite, $skipPhpunitSuites)) {
continue;
}
$matrix = $this->createPhpunitJobs($matrix, $composerInstall, $simpleMatrix, $suite, $run);
}
// phpunit.xml has no defined testsuites, or only defaults a "Default"
Expand Down Expand Up @@ -519,6 +524,7 @@ public function createJson(string $yml): string
$composerInstall = false;
$dynamicMatrix = true;
$simpleMatrix = false;
$skipPhpunitSuites = [];
foreach ($inputs as $input => $value) {
if (in_array($input, [
'endtoend',
Expand All @@ -543,6 +549,9 @@ public function createJson(string $yml): string
$simpleMatrix = $this->parseBoolValue($value);
} else if (in_array($input, ['github_my_ref', 'github_repository', 'parent_branch'])) {
continue;
} else if ($input === 'phpunit_skip_suites') {
// value is a comma-separated string
$skipPhpunitSuites = array_map(fn($val) => trim($val), explode(',', $value));
} else {
throw new LogicException("Unhandled input $input");
}
Expand All @@ -557,7 +566,7 @@ public function createJson(string $yml): string
}

if ($dynamicMatrix) {
$matrix = $this->buildDynamicMatrix($matrix, $run, $composerInstall, $simpleMatrix);
$matrix = $this->buildDynamicMatrix($matrix, $run, $composerInstall, $simpleMatrix, $skipPhpunitSuites);
}

// extra jobs
Expand Down Expand Up @@ -628,6 +637,9 @@ public function createJson(string $yml): string
if ($job['doclinting'] == 'true') {
$name[] = 'doclinting';
}
if ($job['install_inmemory_cache_exts'] == 'true') {
$name[] = 'inmemorycache';
}
$name[] = $job['name_suffix'];
$name = array_filter($name);
$matrix['include'][$i]['name'] = implode(' ', $name);
Expand Down

0 comments on commit 0332303

Please sign in to comment.