From 0e9b5c8b4fdb5159fd426f792ad777d914d92bb9 Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Wed, 7 Dec 2016 09:28:33 -0500 Subject: [PATCH] Making CI builds more verbose. --- .travis.yml | 2 +- phing/build.yml | 9 ++--- phing/phingcludes/VerbosityTask.php | 46 +++++++++++++++----------- phing/tasks/properties.xml | 15 +++------ scripts/cloud-hooks/functions.sh | 2 +- scripts/pipelines/acquia-pipelines.yml | 2 +- scripts/travis/.travis.yml | 2 +- 7 files changed, 38 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93efeb5ceb..bfaf2f1e80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,7 +96,7 @@ script: - 'if [[ "$TRAVIS_PULL_REQUEST" == "true" ]]; then printf "behat.paths: [ ${repo.root}/tests/behat ]" >> blt/project.yml; fi' - cat blt/project.yml # Call targets in the new 'blt-project' project. - - blt ci:build:validate:test -Dcreate_alias=false -Dbehat.run-server=true -Dbehat.launch-phantom=true + - blt ci:build:validate:test -Dcreate_alias=false -Dbehat.run-server=true -Dbehat.launch-phantom=true -Dblt.verbose=true # Initialize ACSF config. - blt acsf:init # Ensure that the doctor doesn't report any problems at this point. diff --git a/phing/build.yml b/phing/build.yml index f0a43adf06..4c2bcd9f68 100644 --- a/phing/build.yml +++ b/phing/build.yml @@ -20,15 +20,10 @@ behat: blt: update: ignore-existing-file: ${blt.root}/scripts/blt/ignore-existing.txt - # Default verbosity level for tasks. + # Default verbosity level for tasks. If Phing msg level is => than info, this will be set to info. exec_level: verbose - # If blt.level >= info, this will be changed to true. Affects verbosity of tasks like Drush, Behat. + # If Phing verbosity is flagged, this will be changed to true. Affects verbosity of tasks like Drush, Behat. verbose: false - # Control the maximum level of verbosity that will be printed to screen. - # From most to least verbose: debug, verbose, info, warn, error. - # Equivalent of using Phing arguments -debug, -verbose, [none], -quiet, -silent - # Note that this does not affect passthru output. - level: info config-files: project: ${repo.root}/blt/project.yml local: ${repo.root}/blt/project.local.yml diff --git a/phing/phingcludes/VerbosityTask.php b/phing/phingcludes/VerbosityTask.php index c7a7156cb5..e567d4f0f9 100644 --- a/phing/phingcludes/VerbosityTask.php +++ b/phing/phingcludes/VerbosityTask.php @@ -4,18 +4,18 @@ * A phing task to loop through properties. */ require_once 'phing/Task.php'; -use Symfony\Component\Yaml\Yaml; class VerbosityTask extends Task { + protected $return_property = null; + /** - * Path the Drush executable. + * The name of a Phing property to assign the Drush command's output to. */ - public function setLevel($str) { - $this->level = $str; + public function setReturnProperty($str) { + $this->return_property = $str; } - /** * The main entry point method. * @@ -24,6 +24,11 @@ public function setLevel($str) { */ public function main() { + // Set value of the return property. + if (empty($this->return_property)) { + throw new \Exception('You must set a return property for the Verbosity task.'); + } + $map = [ 'debug' => Project::MSG_DEBUG, 'verbose' => Project::MSG_VERBOSE, @@ -32,21 +37,24 @@ public function main() { 'error' => Project::MSG_ERR, ]; - if (is_numeric($this->level)) { - $this->setLoggerLevel($this->level); - } - elseif (array_key_exists($this->level, $map)) { - $this->setLoggerLevel($map[$this->level]); - } - else { - $this->log("blt.level '{$this->level}' is invalid. Acceptable values are " . implode(', ', array_keys($map)), Project::MSG_ERR); - } - } - public function setLoggerLevel($level) { - $listeners = $this->getProject()->getBuildListeners(); - foreach ($listeners as $listener) { - $listener->setMessageOutputLevel($level); + // If -verbose flag is used, ignore the rest. + global $argv; + foreach ($argv as $argument) { + switch ($argv) { + case '-debug': + case '-verbose': + case '-quiet': + case '-silent': + $level = substr($argument, 1, strlen($argument)); + $this->getProject()->setProperty($this->return_property, $level); + return TRUE; + + break; + } } + + // Set default level to info. + $this->getProject()->setProperty($this->return_property, 'info'); } } diff --git a/phing/tasks/properties.xml b/phing/tasks/properties.xml index 13b5d73dc7..e5b63eacc6 100644 --- a/phing/tasks/properties.xml +++ b/phing/tasks/properties.xml @@ -36,20 +36,15 @@ - - - - + + - - - + + - - - + diff --git a/scripts/cloud-hooks/functions.sh b/scripts/cloud-hooks/functions.sh index bef18a378e..9f15a42b3a 100644 --- a/scripts/cloud-hooks/functions.sh +++ b/scripts/cloud-hooks/functions.sh @@ -12,7 +12,7 @@ deploy_updates() { export PATH=$repo_root/vendor/bin:$PATH cd $repo_root - blt deploy:update -Denvironment=$target_env + blt deploy:update -Denvironment=$target_env -Dblt.verbose=true if [ $? -ne 0 ]; then echo "Update errored." status=1; diff --git a/scripts/pipelines/acquia-pipelines.yml b/scripts/pipelines/acquia-pipelines.yml index 755ab9e8a7..9a49e6172f 100644 --- a/scripts/pipelines/acquia-pipelines.yml +++ b/scripts/pipelines/acquia-pipelines.yml @@ -34,7 +34,7 @@ events: # The local.hostname must be set to 127.0.0.1:8888 because we are using drush runserver to test the site. - drupal init - drupal yaml:update:value blt/project.yml project.local.hostname '127.0.0.1:8888' - - blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-selenium=false -Dbehat.tags='~javascript&&experimental' ci:build:validate:test + - blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-selenium=false -Dbehat.tags='~javascript&&experimental' -Dblt.verbose=true ci:build:validate:test # Generate - prepare-artifact: diff --git a/scripts/travis/.travis.yml b/scripts/travis/.travis.yml index 57ed47f9c7..798faea7e0 100644 --- a/scripts/travis/.travis.yml +++ b/scripts/travis/.travis.yml @@ -73,7 +73,7 @@ before_script: - drupal yaml:update:value blt/project.yml project.local.hostname '127.0.0.1:8888' script: - - blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-phantom=true ci:build:validate:test + - blt -Dbehat.run-server=true -Dcreate_alias=false -Dbehat.launch-phantom=true ci:build:validate:test -Dblt.verbose=true deploy: - provider: script