From 3206b8caf810f92cf95ce7416339da4de08b0741 Mon Sep 17 00:00:00 2001 From: Dave Gudgeon Date: Thu, 27 Feb 2025 15:59:37 +0000 Subject: [PATCH 1/3] Stop printing script content in normal output and instead show a progress bar for scripts. --- src/Scripts/ScriptRunner.php | 7 ++++--- tests/Scripts/ScriptRunnerTest.php | 33 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Scripts/ScriptRunner.php b/src/Scripts/ScriptRunner.php index 0a12e316..62444d56 100644 --- a/src/Scripts/ScriptRunner.php +++ b/src/Scripts/ScriptRunner.php @@ -64,7 +64,10 @@ public function run($scriptName) { foreach ($this->scripts as $scripts) { if (isset($scripts[$scriptName]) && !empty($scripts[$scriptName])) { + $this->io->text(sprintf('Running scripts for "%s"', $scriptName)); + $this->io->progressStart(count($scripts[$scriptName])); $this->runScripts($scriptName, $scripts); + $this->io->progressFinish(); } } } @@ -78,16 +81,14 @@ public function run($scriptName) */ private function runScripts($scriptName, $scripts) { - $this->io->text(sprintf('Running scripts for "%s"', $scriptName)); - foreach ($scripts[$scriptName] as $script) { if (strpos($script, '@') === 0) { // NB: Infinite recursion detection happens when processing the config $script = substr($script, 1); $this->runScripts($script, $scripts); } else { - $this->io->text(sprintf('$ "%s" in "%s"', $script, $this->getWorkingDir())); $this->processRunner->run($script, $this->getWorkingDir()); + $this->io->progressAdvance(); } } $this->io->newLine(); diff --git a/tests/Scripts/ScriptRunnerTest.php b/tests/Scripts/ScriptRunnerTest.php index e8225e5f..61936770 100644 --- a/tests/Scripts/ScriptRunnerTest.php +++ b/tests/Scripts/ScriptRunnerTest.php @@ -171,4 +171,37 @@ public function testRunsCombinedReferencedScriptWithMultipleCommands() $scriptRunner->run('test'); } + + public function testRunUpdatesProgressBar() + { + $mockIO = Mockery::mock(\Meteor\IO\IOInterface::class, [ + 'text' => null, + 'debug' => null, + 'newLine' => null, + ]); + + $mockIO->shouldReceive('progressStart') + ->once() + ->with(2); + + $mockIO->shouldReceive('progressAdvance') + ->twice(); + + $mockIO->shouldReceive('progressFinish') + ->once(); + + $this->processRunner->shouldReceive('run') + ->withAnyArgs() + ->twice(); + + $scriptRunner = new ScriptRunner($this->processRunner, $mockIO, [ + 'jadu/cms' => [ + 'test' => ['@clear-cache', '@warm-cache'], + 'clear-cache' => ['clear-cache.sh'], + 'warm-cache' => ['warm-cache.sh'], + ], + ]); + + $scriptRunner->run('test'); + } } From 2e732bb3f979853884fac3a493b395d05256b8f8 Mon Sep 17 00:00:00 2001 From: Dave Gudgeon Date: Thu, 27 Feb 2025 10:16:56 +0000 Subject: [PATCH 2/3] Upgrade to upload and download artifact v4 --- .github/workflows/test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 56bb890b..a55026bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,10 +106,11 @@ jobs: files: "bin/meteor.phar" fail: true - name: Store the artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: meteor.phar path: bin/meteor.phar + overwrite: true package-for-testing: name: Create test package @@ -125,7 +126,7 @@ jobs: url: "https://gist.githubusercontent.com/DenisYaschuk/d3ade2d88d058cf9c971cf9d1f580a0f/raw/871ee04ee0ee01a6a2e0f97e67ce0206f78e3179/migrations-update.php" target: tests/mock_project/package - name: Copy meteor to mock project - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: meteor.phar path: "tests/mock_project/package" @@ -156,10 +157,11 @@ jobs: target: "tests/mock_project/package/output/github-action-test_2.0/github-action-test_2.0" - name: Store the mock project artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: mock_project path: tests/mock_project + overwrite: true functional-tests: name: Functional Tests @@ -184,7 +186,7 @@ jobs: php-version: ${{ matrix.php-version }} - name: Retrieve the mock project - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: mock_project path: mock_project From a0e653beed851d307775061e7f1d3e54ebe84ada Mon Sep 17 00:00:00 2001 From: Dave Gudgeon Date: Wed, 12 Mar 2025 17:07:15 +0000 Subject: [PATCH 3/3] Remove unnecessary isset --- src/Scripts/ScriptRunner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Scripts/ScriptRunner.php b/src/Scripts/ScriptRunner.php index 62444d56..588e0ad3 100644 --- a/src/Scripts/ScriptRunner.php +++ b/src/Scripts/ScriptRunner.php @@ -63,7 +63,7 @@ public function setWorkingDir($workingDir) public function run($scriptName) { foreach ($this->scripts as $scripts) { - if (isset($scripts[$scriptName]) && !empty($scripts[$scriptName])) { + if (!empty($scripts[$scriptName])) { $this->io->text(sprintf('Running scripts for "%s"', $scriptName)); $this->io->progressStart(count($scripts[$scriptName])); $this->runScripts($scriptName, $scripts);