From 066d42daf3560c44a379fdc1c8fe829d6134dc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa=20Silva?= <1574795+joaocsilva@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:41:45 +0100 Subject: [PATCH] DQA-8645: Prepare release 10.8.0 (#733) --- CHANGELOG.md | 11 +++++++ docs/guide/commands.rst | 2 +- phpdoc.dist.xml | 2 +- .../Commands/DocumentationCommands.php | 21 ++++++++++--- src/TaskRunner/Commands/ReleaseCommands.php | 31 +++++++++++-------- src/Toolkit.php | 2 +- tests/fixtures/commands/documentation.yml | 21 +++---------- tests/fixtures/commands/release.yml | 9 +++--- 8 files changed, 57 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d02fc135..d491960e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Toolkit change log +## Version 10.8.0 + - DQA-7921: Align Toolkit default deployment commands with Drush standards. + - DQA-8113: Component check - Forbid deprecated scripts in composer.json. + - DQA-8575: Component-check (Unsupported) - Error when there is no reco…. + - DQA-8115: Component check - Forbid deprecated configuration. + - DQA-8117: Detect PHPStan includes if using phpstan/extension-installer. + - DQA-8236: Allow to append commands for local development environment. + - DQA-8253: Setting drupal.site.settings_override_file ignored. + - DQA-8608: Toolkit phpcs ruleset improvements. + - DQA-8583: Module Evaluation error & group evaluation components. + ## Version 9.17.0 | 10.7.0 - DQA-8360: Set the config drupal.root_absolute. - DQA-8373: Opts-review should ignore upper-quotes. diff --git a/docs/guide/commands.rst b/docs/guide/commands.rst index b58aa6f13..59821472a 100644 --- a/docs/guide/commands.rst +++ b/docs/guide/commands.rst @@ -63,7 +63,7 @@ See bellow current list of available commands: toolkit:patch-list [tk-pl] Lists remote patches from the root composer.json. toolkit:requirements Check the Toolkit Requirements. toolkit:run-blackfire [tk-bfire|tbf] Run Blackfire. - toolkit:run-deploy Run deployment sequence. + toolkit:run-deploy [tk-deploy] Run deployment sequence. toolkit:run-gitleaks [tk-gitleaks] Executes the Gitleaks. toolkit:run-phpcbf [tk-phpcbf] Run PHP code autofixing. toolkit:setup-behat Setup the Behat file. diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index 529eb43c5..960915e2f 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -9,7 +9,7 @@ docs - + latest diff --git a/src/TaskRunner/Commands/DocumentationCommands.php b/src/TaskRunner/Commands/DocumentationCommands.php index 4f0021493..3faf82014 100644 --- a/src/TaskRunner/Commands/DocumentationCommands.php +++ b/src/TaskRunner/Commands/DocumentationCommands.php @@ -149,19 +149,32 @@ public function toolkitGenerateDocumentation(ConsoleIO $io, array $options = [ * * @aliases tk-gcl */ - public function toolkitGenerateCommandsList() + public function toolkitGenerateCommandsList(ConsoleIO $io) { + $commandsFile = 'docs/guide/commands.rst'; + if (!file_exists($commandsFile)) { + $io->warning("The file $commandsFile could not be found."); + return ResultData::EXITCODE_OK; + } // Get the available commands. - $commands = $this->taskExec($this->getBin('run')) + $commands = $this->taskExec($this->getBin('run') . ' --no-ansi') ->silent(true)->run()->getMessage(); + if (empty($commands)) { + $io->error('Fail to load existing commands.'); + return ResultData::EXITCODE_ERROR; + } // Remove the header part. - $commands = preg_replace('/((.|\n)*)(Available commands:)/', '\3', $commands); + $commands = strstr($commands, 'Available commands:'); + if (empty($commands)) { + $io->error('Fail to load existing commands from output.'); + return ResultData::EXITCODE_ERROR; + } // Add spaces to match the .rst format. $commands = preg_replace('/^/im', ' ', $commands); $start = ".. toolkit-block-commands\n\n.. code-block::\n\n"; $end = "\n\n.. toolkit-block-commands-end"; - $task = $this->taskReplaceBlock('docs/guide/commands.rst') + $task = $this->taskReplaceBlock($commandsFile) ->start($start)->end($end)->content($commands); return $this->collectionBuilder()->addTask($task); } diff --git a/src/TaskRunner/Commands/ReleaseCommands.php b/src/TaskRunner/Commands/ReleaseCommands.php index ded92b2e5..f7aaa85ba 100644 --- a/src/TaskRunner/Commands/ReleaseCommands.php +++ b/src/TaskRunner/Commands/ReleaseCommands.php @@ -6,6 +6,7 @@ use Composer\Semver\Semver; use EcEuropa\Toolkit\TaskRunner\AbstractCommands; +use EcEuropa\Toolkit\Toolkit; use Robo\Contract\VerbosityThresholdInterface; use Robo\ResultData; use Robo\Symfony\ConsoleIO; @@ -29,14 +30,7 @@ class ReleaseCommands extends AbstractCommands * * @var string */ - private string $releaseBranch = 'release/9.x'; - - /** - * The Toolkit repo url. - * - * @var string - */ - private string $repo = 'https://github.com/ec-europa/toolkit'; + private string $releaseBranch = 'release/10.x'; /** * Write the specified version string into needed places. @@ -80,9 +74,10 @@ public function toolkitVersionWrite(ConsoleIO $io, string $version) $tasks[] = $this->taskReplaceInFile('tests/fixtures/commands/tool.yml') ->regex('#Toolkit version OK \([0-9.]+\)#') ->to("Toolkit version OK ($version)"); + $major = explode('.', $version)[0]; $tasks[] = $this->taskReplaceInFile('tests/fixtures/commands/tool.yml') ->regex('#Current version: [0-9.]+#') - ->to("Current version: $version"); + ->to("Current version: $major"); } return $this->collectionBuilder()->addTaskList($tasks); @@ -128,6 +123,10 @@ public function toolkitChangelogWrite(ConsoleIO $io, string $version, string $fr $from = $changelog_latest; } if (!Semver::satisfies($version, '>' . $from)) { + if (Semver::satisfies($version, '=' . $from)) { + $io->warning('Changelog file is already in the given version.'); + return ResultData::EXITCODE_OK; + } $io->error("The given version $version do not satisfies the version $from found in the $this->changelog file."); return ResultData::EXITCODE_ERROR; } @@ -136,7 +135,8 @@ public function toolkitChangelogWrite(ConsoleIO $io, string $version, string $fr if ($options['full-link'] === true) { $changelog[] = ''; - $changelog[] = "**Full Changelog**: $this->repo/compare/$from...$version"; + $repo = Toolkit::REPOSITORY; + $changelog[] = "**Full Changelog**: https://github.com/$repo/compare/$from...$version"; } $body = implode(PHP_EOL, $changelog) . PHP_EOL; @@ -182,7 +182,12 @@ private function getLatestChangelogVersion() } $content = file_get_contents($this->changelog); preg_match('/## Version (.*)/', $content, $match); - return !empty($match[1]) ? $match[1] : ''; + $version = !empty($match[1]) ? $match[1] : ''; + // Check if the changelog version contains two versions on it. + if (strpos($version, ' | ')) { + $version = explode(' | ', $version)[1]; + } + return $version; } /** @@ -251,10 +256,10 @@ private function prepareChangelogRow(array $data, array $options) $log = ' - ' . trim($message, '.') . '.'; if ($options['show-name'] === true) { - $log .= ' by ' . $name; + $log .= " by $name"; } if ($options['show-pr'] === true) { - $log .= ' in ' . $this->repo . "/pull/$pr"; + $log .= ' in https://github.com/' . Toolkit::REPOSITORY . "/pull/$pr"; } return $log; diff --git a/src/Toolkit.php b/src/Toolkit.php index 8050b087c..8dd02594a 100644 --- a/src/Toolkit.php +++ b/src/Toolkit.php @@ -14,7 +14,7 @@ final class Toolkit /** * Constant holding the current version. */ - public const VERSION = '10.7.0'; + public const VERSION = '10.8.0'; /** * The Toolkit repository. diff --git a/tests/fixtures/commands/documentation.yml b/tests/fixtures/commands/documentation.yml index 584984fa5..f25af51d7 100644 --- a/tests/fixtures/commands/documentation.yml +++ b/tests/fixtures/commands/documentation.yml @@ -103,12 +103,7 @@ resources: [] expectations: - contains: | - [Simulator] Simulating Exec('./vendor/bin/run') - ->silent(1) - [Simulator] Running ./vendor/bin/run - [error] in task EcEuropa\Toolkit\Task\File\ReplaceBlock - - The file docs/guide/commands.rst could not be found. + [WARNING] The file docs/guide/commands.rst could not be found. - command: 'toolkit:generate-commands-list' resources: @@ -116,16 +111,8 @@ to: docs/guide/commands.rst expectations: - contains: | - [Simulator] Simulating Exec('./vendor/bin/run') + [Simulator] Simulating Exec('./vendor/bin/run --no-ansi') ->silent(1) - [Simulator] Running ./vendor/bin/run - [Simulator] Simulating EcEuropa\Toolkit\Task\File\ReplaceBlock('docs/guide/commands.rst') - ->start('.. toolkit-block-commands - - .. code-block:: - - ') - ->end(' + [Simulator] Running ./vendor/bin/run --no-ansi - .. toolkit-block-commands-end') - ->content(' ') + [ERROR] Fail to load existing commands. diff --git a/tests/fixtures/commands/release.yml b/tests/fixtures/commands/release.yml index 1e258c076..81cbb1551 100644 --- a/tests/fixtures/commands/release.yml +++ b/tests/fixtures/commands/release.yml @@ -32,7 +32,7 @@ ->to('Toolkit version OK (9.5.0)') [Simulator] Simulating File\Replace('tests/fixtures/commands/tool.yml') ->regex('#Current version: [0-9.]+#') - ->to('Current version: 9.5.0') + ->to('Current version: 9') - command: 'toolkit:version-write 9.5.0' configuration: [] @@ -74,8 +74,7 @@ to: CHANGELOG.md expectations: - contains: | - [ERROR] The given version 9.5.0 do not satisfies the version 9.5.0 found in the - CHANGELOG.md file. + [WARNING] Changelog file is already in the given version. - command: 'toolkit:changelog-write 9.6.0' configuration: [] @@ -84,7 +83,7 @@ to: CHANGELOG.md expectations: - contains: | - [Simulator] Running git log 9.5.0...release/9.x --pretty='%s##%an##%ae' --reverse + [Simulator] Running git log 9.5.0...release/10.x --pretty='%s##%an##%ae' --reverse [Simulator] Simulating Development\Changelog('CHANGELOG.md') ->setHeader('# Toolkit change log @@ -102,7 +101,7 @@ to: CHANGELOG.md expectations: - contains: | - [Simulator] Running git log 9.5.0...release/9.x --pretty='%s##%an##%ae' --reverse + [Simulator] Running git log 9.5.0...release/10.x --pretty='%s##%an##%ae' --reverse [Simulator] Simulating Development\Changelog('CHANGELOG.md') ->setHeader('# Toolkit change log