From afb0a398b53a2e5d64a79f41c31e4cdb2636a91c Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:02:31 +1200 Subject: [PATCH] NEW Pass in-memory-cache input for extra_jobs (#98) --- action.yml | 5 +++++ job_creator.php | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index ec3deff..154c235 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,10 @@ inputs: phpunit: type: boolean default: true + phpunit_skip_suites: + type: string + required: false + default: '' js: type: boolean default: true @@ -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 diff --git a/job_creator.php b/job_creator.php index 686c550..08f032c 100644 --- a/job_creator.php +++ b/job_creator.php @@ -152,6 +152,7 @@ public function createJob(int $phpIndex, array $opts): array 'endtoend_config' => '', 'js' => false, 'doclinting' => false, + 'install_in_memory_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'), ]; @@ -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(); @@ -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" @@ -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', @@ -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('trim', explode(',', $value)); } else { throw new LogicException("Unhandled input $input"); } @@ -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 @@ -628,6 +637,9 @@ public function createJson(string $yml): string if ($job['doclinting'] == 'true') { $name[] = 'doclinting'; } + if ($job['install_in_memory_cache_exts'] == 'true') { + $name[] = 'inmemorycache'; + } $name[] = $job['name_suffix']; $name = array_filter($name); $matrix['include'][$i]['name'] = implode(' ', $name);