Skip to content

Commit

Permalink
Making CI builds more verbose.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Dec 7, 2016
1 parent 3dac6d8 commit 0e9b5c8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 2 additions & 7 deletions phing/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ behat:
blt:
update:
ignore-existing-file: ${blt.root}/scripts/blt/ignore-existing.txt
# Default verbosity level for <exec> tasks.
# Default verbosity level for <exec> 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
Expand Down
46 changes: 27 additions & 19 deletions phing/phingcludes/VerbosityTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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,
Expand All @@ -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');
}

}
15 changes: 5 additions & 10 deletions phing/tasks/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,15 @@
<!-- Send errors to /dev/null, for environments like ACE without composer. -->
<exec dir="${repo.root}" command="composer info acquia/blt 2> /dev/null | grep versions | awk '{print $4}'" outputProperty="blt.version" logoutput="false" checkreturn="true" level="${blt.exec_level}" />

<!--verbosityTask is used to set the verbosity level of Phing via a property. It is necessary because the -verbose, -debug, -silent, and -quiet command line options are not available as properties and cannot be utilized in task conditionals. -->
<verbosityTask level="${blt.level}"/>
<!-- Think of blt.level as a maximum verbosity level. Anything above the default level of info (e.g., verbose and debug) are hidden unless the maximum verbosity is raised to the "verbose" or "debug" level. Raising blt.level increases the visibility of otherwise hidden output. -->
<!-- When blt.level is above "warn", then increase verbosity of common project tasks. -->
<!-- Set the ${verbosity} variable. -->
<verbosityTask returnProperty="verbosity"/>
<if>
<or>
<equals arg1="${blt.level}" arg2="debug"/>
<equals arg1="${blt.level}" arg2="verbose"/>
<equals arg1="${blt.level}" arg2="info"/>
<equals arg1="${verbosity}" arg2="debug"/>
<equals arg1="${verbosity}" arg2="verbose"/>
</or>
<then>
<!--blt.exec_level is used for most <exec> tasks.-->
<property name="blt.exec_level" value="info"/>
<!--blt.verbose is used to toggle the verbosity on other tasks, such as Drush and Behat-->
<!-- blt.verbose is used to toggle the verbosity on other tasks, such as Drush and Behat. -->
<property name="blt.verbose" value="true"/>
</then>
</if>
Expand Down
2 changes: 1 addition & 1 deletion scripts/cloud-hooks/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scripts/pipelines/acquia-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e9b5c8

Please sign in to comment.