From c64f7e04fe5fe7c751a484443ee2eec584317e6e Mon Sep 17 00:00:00 2001
From: tedbow <tedbow@240860.no-reply.drupal.org>
Date: Tue, 17 Aug 2021 13:36:46 +0000
Subject: [PATCH] Issue #3228125 by tedbow, phenaproxima: Ensure build tests
 run and pass on Drupalci

---
 drupalci.yml                               | 17 ++++++++---------
 src/ComposerStager/ProcessFactory.php      |  8 +++++++-
 src/Updater.php                            |  1 -
 tests/src/Build/AttendedUpdateTestBase.php | 15 ++++++++++++---
 4 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/drupalci.yml b/drupalci.yml
index 232228cdb2..d5d93d9bc9 100644
--- a/drupalci.yml
+++ b/drupalci.yml
@@ -3,7 +3,7 @@
 # cspell:disable
 build:
   assessment:
-    validate_codebase:
+    # validate_codebase:
     # automatic_updates code quality checking matches that of Drupal core: it is checked by container_command.commit_checks.
     testing:
       # Run code quality checks.
@@ -40,14 +40,6 @@ build:
       # halt-on-fail can be set on the run_tests tasks in order to fail fast.
       # suppress-deprecations is false in order to be alerted to usages of
       # deprecated code.
-      # @todo Uncomment in https://www.drupal.org/i/3228125
-#      run_tests.build:
-#        # Limit concurrency due to disk space concerns.
-#        concurrency: 15
-#        types: 'PHPUnit-Build'
-#        testgroups: '--all'
-#        suppress-deprecations: false
-#        halt-on-fail: false
       run_tests.phpunit:
         types: 'PHPUnit-Unit'
         testgroups: '--all'
@@ -58,6 +50,13 @@ build:
         testgroups: '--all'
         suppress-deprecations: false
         halt-on-fail: false
+      run_tests.build:
+        # Limit concurrency due to disk space concerns.
+        concurrency: 15
+        types: 'PHPUnit-Build'
+        testgroups: '--all'
+        suppress-deprecations: false
+        halt-on-fail: false
       run_tests.functional:
         types: 'PHPUnit-Functional'
         testgroups: '--all'
diff --git a/src/ComposerStager/ProcessFactory.php b/src/ComposerStager/ProcessFactory.php
index 018040c93a..fec8b8d48a 100644
--- a/src/ComposerStager/ProcessFactory.php
+++ b/src/ComposerStager/ProcessFactory.php
@@ -20,7 +20,13 @@ final class ProcessFactory implements ProcessFactoryInterface {
   public function create(array $command): Process {
     try {
       if ($this->isComposerCommand($command)) {
-        return new Process($command, NULL, ['COMPOSER_HOME' => $this->getComposerHomePath()]);
+        $process = new Process($command, NULL, ['COMPOSER_HOME' => $this->getComposerHomePath()]);
+        $path = function_exists('apache_getenv') ? apache_getenv('PATH') : getenv('PATH');
+        $path .= ':' . dirname(PHP_BINARY);
+        $env = $process->getEnv();
+        $env['PATH'] = $path;
+        $process->setEnv($env);
+        return $process;
       }
       return new Process($command);
       // @codeCoverageIgnore
diff --git a/src/Updater.php b/src/Updater.php
index 2d6a428f08..5c88ef3895 100644
--- a/src/Updater.php
+++ b/src/Updater.php
@@ -265,7 +265,6 @@ class Updater {
    * @see \PhpTuf\ComposerStager\Domain\StagerInterface::stage()
    */
   protected function stageCommand(array $command): void {
-    $this->setEnv('PATH', $this->getEnv('PATH') . ":/usr/local/bin");
     $this->stager->stage($command, $this->getStageDirectory());
   }
 
diff --git a/tests/src/Build/AttendedUpdateTestBase.php b/tests/src/Build/AttendedUpdateTestBase.php
index 1f0b3633c8..1de9ad105c 100644
--- a/tests/src/Build/AttendedUpdateTestBase.php
+++ b/tests/src/Build/AttendedUpdateTestBase.php
@@ -38,9 +38,18 @@ abstract class AttendedUpdateTestBase extends QuickStartTestBase {
    * {@inheritdoc}
    */
   protected function getPackagePath(array $package): string {
-    return $package['name'] === 'drupal/core'
-      ? 'core'
-      : $this->traitGetPackagePath($package);
+    if ($package['name'] === 'drupal/core') {
+      return 'core';
+    }
+
+    [$vendor, $name] = explode('/', $package['name']);
+
+    // Assume any contributed module is in modules/contrib/$name.
+    if ($vendor === 'drupal' && $package['type'] === 'drupal-module') {
+      return implode(DIRECTORY_SEPARATOR, ['modules', 'contrib', $name]);
+    }
+
+    return $this->traitGetPackagePath($package);
   }
 
   /**
-- 
GitLab