summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Aslett (Mixologic)2018-02-25 16:12:48 (GMT)
committerRyan Aslett (Mixologic)2018-02-25 16:12:48 (GMT)
commita9d022c57074f8ef31a2134e560731a1e69d9713 (patch)
tree60dc2d8f013841b4e5f1158abfbd38b02c21db89
parentb1fbfb89c3cd3e84a2ad0f7438c5445eb36eeb5f (diff)
parent777a7917c61c23de9689cb8c19b3d11f887c4c43 (diff)
Merge branch '2845732-add-processor-count' into dev
-rw-r--r--src/DrupalCI/Build/Environment/Environment.php11
-rw-r--r--src/DrupalCI/Build/Environment/EnvironmentInterface.php6
-rw-r--r--src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/PhpLint.php8
-rw-r--r--src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php5
4 files changed, 27 insertions, 3 deletions
diff --git a/src/DrupalCI/Build/Environment/Environment.php b/src/DrupalCI/Build/Environment/Environment.php
index d2e6cfc..386bfd4 100644
--- a/src/DrupalCI/Build/Environment/Environment.php
+++ b/src/DrupalCI/Build/Environment/Environment.php
@@ -390,4 +390,15 @@ class Environment implements Injectable, EnvironmentInterface {
return $this->chromeContainer['name'];
}
+ /**
+ * @inheritDoc
+ */
+ public function getHostProcessorCount() {
+ $cpuinfo = file_get_contents('/proc/cpuinfo');
+ preg_match_all('/^processor/m', $cpuinfo, $matches);
+ $numCpus = count($matches[0]);
+ return $numCpus;
+ }
+
+
}
diff --git a/src/DrupalCI/Build/Environment/EnvironmentInterface.php b/src/DrupalCI/Build/Environment/EnvironmentInterface.php
index 0b3ec96..9582c83 100644
--- a/src/DrupalCI/Build/Environment/EnvironmentInterface.php
+++ b/src/DrupalCI/Build/Environment/EnvironmentInterface.php
@@ -62,4 +62,10 @@ interface EnvironmentInterface {
*/
public function getContainerComposerCacheDir();
+ /**
+ * @return int
+ * The number of processors available in the host environment
+ */
+ public function getHostProcessorCount();
+
}
diff --git a/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/PhpLint.php b/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/PhpLint.php
index d489ab8..db8ba4e 100644
--- a/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/PhpLint.php
+++ b/src/DrupalCI/Plugin/BuildTask/BuildStep/CodebaseValidate/PhpLint.php
@@ -60,9 +60,14 @@ class PhpLint extends BuildTaskBase implements BuildStepInterface, BuildTaskInte
// Make sure
if (0 < filesize($lintable_files)) {
$this->saveHostArtifact($lintable_files,'lintable_files.txt');
+
+ if (empty($this->configuration['concurrency'])) {
+ $this->configuration['concurrency'] = $this->environment->getHostProcessorCount();
+ }
+ $concurrency = $this->configuration['concurrency'];
+
// This should be come Codebase->getLocalDir() or similar
// Use xargs to concurrently run linting on file.
- $concurrency = $this->configuration['concurrency'];
$cmd = "cd " . $this->environment->getExecContainerSourceDir() . " && xargs -P $concurrency -a " . $this->environment->getContainerWorkDir() . '/' . $this->pluginDir . "/lintable_files.txt -I {} php -l '{}'";
// TODO Throw a BuildException if there are syntax errors.
$result = $this->environment->executeCommands($cmd);
@@ -79,7 +84,6 @@ class PhpLint extends BuildTaskBase implements BuildStepInterface, BuildTaskInte
*/
public function getDefaultConfiguration() {
return [
- 'concurrency' => '4',
];
}
diff --git a/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php b/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php
index e35e4f4..8a8ea05 100644
--- a/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php
+++ b/src/DrupalCI/Plugin/BuildTask/BuildStep/Testing/Simpletest.php
@@ -217,7 +217,6 @@ class Simpletest extends BuildTaskBase implements BuildStepInterface, BuildTaskI
public function getDefaultConfiguration() {
return [
'testgroups' => '--all',
- 'concurrency' => 4,
'types' => 'Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional',
'color' => TRUE,
'die-on-fail' => FALSE,
@@ -394,6 +393,10 @@ class Simpletest extends BuildTaskBase implements BuildStepInterface, BuildTaskI
if (empty($config['url'])) {
$config['url'] = 'http://' . $this->environment->getExecContainer()['name'] . '/subdirectory';
}
+ if (empty($config['concurrency'])) {
+ $config['concurrency'] = $this->environment->getHostProcessorCount();
+ }
+
foreach ($config as $key => $value) {
// Temporary backwards compatibility fix for https://www.drupal.org/node/2906212
// This will allow us to use older build.yml files. Remove after Feb 2018 or so.