Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override default filesets or avoid validating filesets not needed for a command #4408

Open
FlorentTorregrosa opened this issue Nov 3, 2021 · 2 comments
Labels
Support A support request

Comments

@FlorentTorregrosa
Copy link

I want to...
Test to validate Twig files with BLT.

It's not working because...
When including BLT on an existing project with Composer, BLT expects to have a "tests" and "config" directories at the project root.

When creating these empty directories it is ok.

I tried to find a way to override it without success.

I don't understand why all filesets are validated whereas not used for this command.

Detailed error output
If a BLT command is failing, run it again with the -vvv argument and post the full output here.

root@42099090406f:/project# ./vendor/bin/blt validate:twig -vvv
[warning] The xDebug extension is loaded. This will significantly decrease performance.
[debug] Drupal VM is not initialized.
Validating twig syntax for all custom modules and themes...
[debug] Gathering filesets from annotated methods...
[debug] Calling getFilesetPhpCustomModules on Acquia\Blt\Robo\Filesets\Filesets object...
[debug] Calling getFilesetPhpCustomThemes on Acquia\Blt\Robo\Filesets\Filesets object...
[debug] Calling getFilesetPhpTests on Acquia\Blt\Robo\Filesets\Filesets object...
[error]  The "/project/tests" directory does not exist. 
0.174s total time elapsed.

BLT doctor output

root@42099090406f:/project# ./vendor/bin/blt blt:doctor
[warning] The xDebug extension is loaded. This will significantly decrease performance.
+---------------------------+--------------------------------------------+
| Property                  | Value                                      |
+---------------------------+--------------------------------------------+
| %paths.%root              | /project/app                               |
| %paths.%site              | sites/default                              |
| %paths.%modules           | sites/all/modules                          |
| %paths.%themes            | sites/all/themes                           |
| %paths.%config-sync       | /project/app/../conf/drupal/default/sync   |
| %paths.%files             | sites/default/files                        |
| %paths.%temp              | /tmp                                       |
| %paths.%private           | /project/app/../private_files/default      |
| admin-theme               | seven                                      |
| alias-searchpaths.0       | /project/drush/sites                       |
| blt-version               | 13.1.0.0                                   |
| bootstrap                 | Successful                                 |
| composer-version          | Composer version 2.1.8 2021-09-15 13:55:14 |
| config-sync               | /project/app/../conf/drupal/default/sync   |
| db-driver                 | mysql                                      |
| db-hostname               | mysql                                      |
| db-name                   | drupal                                     |
| db-password               | drupal                                     |
| db-port                   | 3306                                       |
| db-status                 | Connected                                  |
| db-username               | drupal                                     |
| drupal-settings-file      | sites/default/settings.php                 |
| drupal-version            | 9.3.0-alpha1                               |
| drush-alias-files.0       | /project/drush/sites/default.site.yml      |
| drush-cache-directory     | /root/.drush/cache                         |
| drush-conf.0              | /project/vendor/drush/drush/drush.yml      |
| drush-conf.1              | /project/drush/drush.yml                   |
| drush-script              | /project/vendor/drush/drush/drush          |
| drush-temp                | /tmp                                       |
| drush-version             | 10.6.1                                     |
| files                     | sites/default/files                        |
| install-profile           | ftorregrosa                                |
| modules                   | sites/all/modules                          |
| php-bin                   | /usr/local/bin/php                         |
| php-conf.1                | /usr/local/etc/php/php.ini                 |
| php-os                    | Linux                                      |
| private                   | /project/app/../private_files/default      |
| root                      | /project/app                               |
| site                      | sites/default                              |
| stacks.drupal-vm.inited   | false                                      |
| stacks.dev-desktop.inited | false                                      |
| temp                      | /tmp                                       |
| theme                     | ftorregrosa_theme                          |
| themes                    | sites/all/themes                           |
| uri                       | http://default                             |
+---------------------------+--------------------------------------------+
+--------------------------------------+--------------------------------------------------------------+
| Check                                | Problem                                                      |
+--------------------------------------+--------------------------------------------------------------+
| ConfigCheck:checkGitConfig           | Git repositories are not defined in blt.yml.                 |
|                                      |   Add values for git.remotes to blt.yml to enabled automated |
|                                      | deployment.                                                  |
| NodeCheck:checkNodeVersionFileExists | Neither .nvmrc nor .node-version file found in repo root.    |
| SettingsFilesCheck:blt-settings      | BLT settings are not included in settings file.              |
| SettingsFilesCheck:local-settings    | Could not find local settings file.                          |
|                                      | Your local settings file should exist at                     |
|                                      | /project/app/sites/default/settings/local.settings.php.      |
| WebUriCheck:checkUriResponse         | Did not get a response from http://default                   |
|                                      | Is your *AMP stack running?                                  |
|                                      | Is your /etc/hosts file correctly configured?                |
|                                      | Is your web server configured to serve this URI from         |
|                                      | /project/app?                                                |
|                                      | Is options.uri set correctly in                              |
|                                      | /project/app/sites/default/local.drush.yml?                  |
+--------------------------------------+--------------------------------------------------------------+
[error]  BLT Doctor discovered one or more critical issues.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/ 

System information

  • Operating system type: Linux
  • Operating system version: Debian 10 / Docker
  • BLT version: 13.1.0.0
@FlorentTorregrosa FlorentTorregrosa added the Support A support request label Nov 3, 2021
@Alexander-Cairns
Copy link

This seems to be happening since when calling getFilesets() if no file sets are loaded it will make a call to registerFilesets() which causes all the file sets commands to be run.

A possible solution would be to lazy load only the requested file sets.

With something like this:

diff --git a/src/Robo/Filesets/FilesetManager.php b/src/Robo/Filesets/FilesetManager.php
   public function getFilesets($fileset_ids = [], $resetFinder = FALSE) {
-    if (!$this->filesets || $resetFinder) {
-      $this->registerFilesets();
-    }
-
     if ($fileset_ids) {
       foreach ($fileset_ids as $fileset_id) {
         if (!in_array($fileset_id, array_keys($this->filesets))) {
-          throw new BltException("Unable to find fileset $fileset_id!");
+          if (!$this->registerFileset($fileset_id)) {
+            throw new BltException("Unable to find fileset $fileset_id!");
+          }
         }
         $filesets[$fileset_id] = $this->filesets[$fileset_id];
       }

Where registerFileset($fileset_id) would register only the selected fileset, and return whether it succeeded or not.

@patrickcate
Copy link

+1
I ran into this as well with the missing tests folder causing the validate command to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support A support request
Projects
None yet
Development

No branches or pull requests

3 participants