diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-05-29 00:40:14 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-05-29 00:40:14 +0300 |
commit | 0e4959e8d3baecd8a12333f2e9617fa77667158a (patch) | |
tree | b6aa100d2f1c34643814c8208490a5ecf44b39a0 /plugins/CoreConsole | |
parent | 51e725ede4378df7eeab296335ec5dab6a026b94 (diff) |
Upload and sync processed plugin system test build artifacts (#12995)
* upload and sync plugin system tests artifacts
* Update tests/travis submodule.
Diffstat (limited to 'plugins/CoreConsole')
-rw-r--r-- | plugins/CoreConsole/Commands/DevelopmentSyncProcessedSystemTests.php | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/plugins/CoreConsole/Commands/DevelopmentSyncProcessedSystemTests.php b/plugins/CoreConsole/Commands/DevelopmentSyncProcessedSystemTests.php index 8e86adacc4..db2ea521b3 100644 --- a/plugins/CoreConsole/Commands/DevelopmentSyncProcessedSystemTests.php +++ b/plugins/CoreConsole/Commands/DevelopmentSyncProcessedSystemTests.php @@ -13,6 +13,7 @@ use Piwik\Common; use Piwik\Container\StaticContainer; use Piwik\Decompress\Tar; use Piwik\Development; +use Piwik\Filesystem; use Piwik\Http; use Piwik\Plugin\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; @@ -22,8 +23,6 @@ use Symfony\Component\Console\Output\OutputInterface; class DevelopmentSyncProcessedSystemTests extends ConsoleCommand { - private $targetDir = 'tests/PHPUnit/System/processed'; - public function isEnabled() { return Development::isEnabled(); @@ -32,15 +31,21 @@ class DevelopmentSyncProcessedSystemTests extends ConsoleCommand protected function configure() { $this->setName('development:sync-system-test-processed'); - $this->setDescription('For Piwik core devs. Copies processed system tests from travis artifacts to ' . $this->targetDir); + $this->setDescription('For Piwik core devs. Copies processed system tests from travis artifacts to local processed directories'); $this->addArgument('buildnumber', InputArgument::REQUIRED, 'Travis build number you want to sync, eg "14820".'); } protected function execute(InputInterface $input, OutputInterface $output) { + $this->updateCoreFiles($input, $output); + $this->updatePluginsFiles($input, $output); + } + + protected function updateCoreFiles(InputInterface $input, OutputInterface $output) + { $buildNumber = $input->getArgument('buildnumber'); - $targetDir = PIWIK_INCLUDE_PATH . '/' . dirname($this->targetDir); - $tmpDir = StaticContainer::get('path.tmp'); + $targetDir = PIWIK_INCLUDE_PATH . '/tests/PHPUnit/System/processed'; + $tmpDir = StaticContainer::get('path.tmp') . '/'; $this->validate($buildNumber, $targetDir, $tmpDir); @@ -57,10 +62,55 @@ class DevelopmentSyncProcessedSystemTests extends ConsoleCommand file_put_contents($tarFile, $tests); $tar = new Tar($tarFile, 'bz2'); + $tar->extract($targetDir); $this->writeSuccessMessage($output, array( - 'All processed system test results were copied to <comment>' . $this->targetDir . '</comment>', + 'All processed system test results were copied to <comment>' . $targetDir . '</comment>', + 'Compare them with the expected test results and commit them if needed.' + )); + + unlink($tarFile); + } + + + protected function updatePluginsFiles(InputInterface $input, OutputInterface $output) + { + $buildNumber = $input->getArgument('buildnumber'); + $targetDir = PIWIK_INCLUDE_PATH . '/plugins/%s/tests/System/processed/'; + $tmpDir = StaticContainer::get('path.tmp') . '/'; + + if (Common::stringEndsWith($buildNumber, '.1')) { + // eg make '14820.1' to '14820' to be backwards compatible + $buildNumber = substr($buildNumber, 0, -2); + } + + $filename = sprintf('system.plugins.%s.tar.bz2', $buildNumber); + $urlBase = sprintf('https://builds-artifacts.matomo.org/matomo-org/matomo/%s', $filename); + $tests = Http::sendHttpRequest($urlBase, $timeout = 120); + + $tarFile = $tmpDir . $filename; + file_put_contents($tarFile, $tests); + + $tar = new Tar($tarFile, 'bz2'); + + $extractionTarget = $tmpDir . '/artifacts'; + + Filesystem::mkdir($extractionTarget); + $tar->extract($extractionTarget); + + $artifacts = Filesystem::globr($extractionTarget, '*~~*'); + + foreach($artifacts as $artifact) { + $artifactName = basename($artifact); + list($plugin, $file) = explode('~~', $artifactName); + Filesystem::copy($artifact, sprintf($targetDir, $plugin) . $file); + } + + Filesystem::unlinkRecursive($extractionTarget, true); + + $this->writeSuccessMessage($output, array( + 'All processed plugin system test results were copied to <comment>' . $targetDir . '</comment>', 'Compare them with the expected test results and commit them if needed.' )); |