From a4ed5374a5877e55cb941f8467380da0a4e04612 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:03:59 +1300 Subject: [PATCH] NEW Add docuemntation linting matrix entry (#84) --- action.yml | 4 ++++ job_creator.php | 11 +++++++++++ tests/JobCreatorTest.php | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/action.yml b/action.yml index e366e4e..dc297a5 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,9 @@ inputs: js: type: boolean default: true + doclinting: + type: boolean + default: true # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions outputs: @@ -124,6 +127,7 @@ runs: echo "phpcoverage_force_off: ${{ inputs.phpcoverage_force_off }}" >> __inputs.yml echo "phplinting: ${{ inputs.phplinting }}" >> __inputs.yml echo "phpunit: ${{ inputs.phpunit }}" >> __inputs.yml + echo "doclinting: ${{ inputs.doclinting }}" >> __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 3b36913..c65ac48 100644 --- a/job_creator.php +++ b/job_creator.php @@ -162,6 +162,7 @@ public function createJob(int $phpIndex, array $opts): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => false, + 'doclinting' => false, // Needs full setup if installerVersion is set, OR this is one of the no-installer lockstepped repos 'needs_full_setup' => $this->installerVersion !== '' || in_array($this->repoName, NO_INSTALLER_LOCKSTEPPED_REPOS), ]; @@ -559,6 +560,12 @@ private function buildDynamicMatrix( 'js' => true ]); } + // documentation linting + if ($run['doclinting'] && file_exists('.doclintrc')) { + $matrix['include'][] = $this->createJob(0, [ + 'doclinting' => true + ]); + } return $matrix; } @@ -617,6 +624,7 @@ public function createJson(string $yml): string 'phpcoverage', 'phpcoverage_force_off', 'phplinting', + 'doclinting', ])) { $run[$input] = $this->parseBoolValue($value); } else if ($input === 'extra_jobs') { @@ -714,6 +722,9 @@ public function createJson(string $yml): string if ($job['phplinting'] == 'true') { $name[] = 'phplinting'; } + if ($job['doclinting'] == 'true') { + $name[] = 'doclinting'; + } $name[] = $job['name_suffix']; $name = array_filter($name); $matrix['include'][$i]['name'] = implode(' ', $name); diff --git a/tests/JobCreatorTest.php b/tests/JobCreatorTest.php index 6337506..4672efa 100644 --- a/tests/JobCreatorTest.php +++ b/tests/JobCreatorTest.php @@ -44,6 +44,7 @@ public function provideCreateJob(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => false, + 'doclinting' => false, 'needs_full_setup' => false, ]], // test that NO_INSTALLER_LOCKSTEPPED_REPOS base max PHP version from $branch @@ -248,6 +249,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '7.4 prf-low mysql57 phpunit all', ], @@ -267,6 +269,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.0 mysql57pdo phpunit all', ], @@ -286,6 +289,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 mysql80 phpunit all', ], @@ -317,6 +321,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 prf-low mysql57 phpunit all', ], @@ -335,6 +340,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.2 mariadb phpunit all', ], @@ -353,6 +359,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.3 mysql80 phpunit all', ], @@ -384,6 +391,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 prf-low mysql57 phpunit all', ], @@ -402,6 +410,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.2 mariadb phpunit all', ], @@ -420,6 +429,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.3 mysql80 phpunit all', ], @@ -451,6 +461,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 prf-low mysql57 phpunit all', ], @@ -469,6 +480,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 mariadb phpunit all', ], @@ -487,6 +499,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.2 mysql80 phpunit all', ], @@ -518,6 +531,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.1 prf-low mysql57 phpunit all', ], @@ -536,6 +550,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.2 mariadb phpunit all', ], @@ -554,6 +569,7 @@ public function provideCreateJson(): array 'endtoend_suite' => 'root', 'endtoend_config' => '', 'js' => 'false', + 'doclinting' => 'false', 'needs_full_setup' => 'true', 'name' => '8.3 mysql80 phpunit all', ], @@ -589,6 +605,7 @@ private function getGenericYml(): string phpcoverage_force_off: false phplinting: true phpunit: true + doclinting: true simple_matrix: false composer_install: false EOT; @@ -665,6 +682,7 @@ public function provideGetInputsValid(): array 'phpcoverage_force_off' => false, 'phplinting' => true, 'phpunit' => true, + 'doclinting' => true, 'simple_matrix' => false, 'composer_install' => false, 'github_repository' => 'myaccount/silverstripe-versioned',