Skip to content

Commit

Permalink
10.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Feb 21, 2024
2 parents 70a9001 + 6eeb1ab commit e930da0
Show file tree
Hide file tree
Showing 102 changed files with 1,471 additions and 3,090 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ defaults: &defaults
restore_cache: &restore_cache
# We use the composer.lock as a way to determine if we can cache our build.
keys:
- cache-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-{{ .Environment.CACHE_VERSION }}
- cache-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-
- cache-{{ checksum "blt/blt.yml" }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-{{ .Environment.CACHE_VERSION }}
- cache-{{ checksum "blt/blt.yml" }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-
# fallback to using the latest cache if no exact match is found
- cache-{{ checksum "composer.json" }}
- cache-{{ checksum "blt/blt.yml" }}-{{ checksum "composer.json" }}

## Defines the cache saving mechanism.
save_cache: &save_cache
Expand All @@ -50,7 +50,7 @@ save_cache: &save_cache
- ./docroot/modules/contrib
- ./docroot/modules/custom
- ./docroot/themes/contrib
key: cache-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-{{ .Environment.CACHE_VERSION }}
key: cache-{{ checksum "blt/blt.yml" }}-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }}-{{ .Environment.CACHE_VERSION }}

disable_telemetry: &disable_telemetry
run:
Expand Down
25 changes: 5 additions & 20 deletions blt/blt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,29 @@ drush:
default_alias: '${drush.aliases.local}'
modules:
local:
enable: { }
enable: { }
uninstall:
- google_analytics
- acquia_connector
- purge
- shield
- config_readonly
ci:
enable:
- hs_config_readonly
enable: { }
uninstall:
- google_analytics
- purge
- acquia_connector
- shield
dev:
enable:
- acquia_connector
- shield
- stage_file_proxy
uninstall:
- google_analytics
- config_readonly
uninstall: { }
test:
enable:
- acquia_connector
- shield
- stage_file_proxy
uninstall:
- google_analytics
- config_readonly
uninstall: { }
prod:
enable:
- google_analytics
- acquia_connector
- hs_config_readonly
uninstall:
- shield
- stage_file_proxy
multisites:
- aaai
Expand Down Expand Up @@ -145,13 +130,13 @@ multisites:
- linguistics
- lowe
- mathematics
- mathematics2023
- mathematics2024
- mcs
- mcs2023
- mediterraneanstudies
- memorylab
- morrisoninstitute
- mrc
- mtl
- music
- oconnell
Expand Down
11 changes: 11 additions & 0 deletions blt/src/Blt/Plugin/Commands/HsCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ protected function askQuestion($question, $default = '', $required = FALSE) {
return $response;
}

/**
* Return BLT.
*
* @return \Robo\Task\Base\Exec
* A drush exec command.
*/
protected function blt() {
return $this->taskExec($this->getConfigValue('repo.root') . '/vendor/bin/blt')
->option('no-interaction');
}

}
61 changes: 60 additions & 1 deletion blt/src/Blt/Plugin/Commands/HsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Serialization\Yaml;
use GuzzleHttp\Client;
use Robo\Exception\TaskException;
use Sws\BltSws\Blt\Plugin\Commands\SwsCommandTrait;

/**
* Various BLT commands for H&S stack.
Expand All @@ -16,6 +17,65 @@ class HsCommands extends BltTasks {

use HsCommandTrait;

/**
* After code deployed, update all sites on the stack.
*
* @command humsci:post-code-deploy
*
* @aliases humsci:post-code-update
*/
public function postCodeDeployUpdate() {
$sites = $this->getConfigValue('multisites');
$parallel_executions = 10;
$site_chunks = array_chunk($sites, ceil(count($sites) / $parallel_executions));
$commands = [];
foreach ($site_chunks as $sites) {
$commands[] = $this->blt()
->arg('humsci:update-sites')
->arg(implode(',', $sites))
->getCommand();
}
file_put_contents(sys_get_temp_dir() . '/update-report.txt', '');
$this->taskExec(implode(" &\n", $commands) . PHP_EOL . 'wait')->run();
$report = array_filter(explode("\n", file_get_contents(sys_get_temp_dir() . '/update-report.txt')));

$success = [];
$failed = [];
foreach ($report as $line) {
[$site, $status] = explode(':', $line);
if ((int) $status) {
$success[] = $site;
}
else {
$failed[] = $site;
}
}
$this->yell(sprintf('Updated %s sites successfully.', count($success)), 100);
if ($failed) {
$this->yell(sprintf("Update failed for the following sites:\n%s", implode("\n", $failed)), 100, 'red');
}
unlink(sys_get_temp_dir() . '/update-report.txt');
}

/**
* @command humsci:update-sites
*
* @var string $sites
* List of sites to update.
*/
public function updateSites($sites = NULL) {
$sites = $sites ? explode(',', $sites) : $this->getConfigValue('multisites');
foreach ($sites as $site_name) {
$this->switchSiteContext($site_name);
$result = $this->taskDrush()
->drush('updb')
->drush('config:import')
->option('partial')
->run();
file_put_contents(sys_get_temp_dir() . '/update-report.txt', $site_name . ($result->wasSuccessful() ? ':1' : ':0') . PHP_EOL, FILE_APPEND);
}
}

/**
* Generate a list of emails for the given role on all sites.
*
Expand All @@ -34,7 +94,6 @@ public function roleReport($role) {

$site_url = str_replace('_', '-', str_replace('__', '.', $site));


if (str_contains($site_url, '.')) {
[$first, $last] = explode('.', $site_url);
$site_url = "$first-prod.$last";
Expand Down
4 changes: 0 additions & 4 deletions blt/src/Blt/Plugin/Commands/HsHooksCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public function postMultiSiteInit() {
preg_match('/sites\/(.*)\.site\.yml/', $site_file, $matches);
$site_name = $matches[1];

if ($site_name == 'mrc') {
continue;
}

$multisites[] = $site_name;
if (count($alias) != count($default_alias)) {
foreach ($default_alias as $environment => $env_alias) {
Expand Down
4 changes: 4 additions & 0 deletions blt/src/Blt/Plugin/Commands/ToggleModulesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ protected function doToggleModules($command, $config_key) {
$modules_list = implode(' ', $modules);
$result = $this->taskDrush()
->drush("$command $modules_list")
->drush('eval')
->arg('\Drupal::moduleHandler()->loadInclude("user", "install");user_update_10000();')
->run();
// Unable to uninstall all modules at the same time, try one at a time.
if (!$result->wasSuccessful()) {
Expand All @@ -68,6 +70,8 @@ protected function doToggleModules($command, $config_key) {
// command will throw an error. Ignore that.
$this->taskDrush()
->drush("$command $module")
->drush('eval')
->arg('\Drupal::moduleHandler()->loadInclude("user", "install");user_update_10000();')
->printOutput(FALSE)
->run();
}
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
"drupal/focal_point": {
"https://www.drupal.org/project/focal_point/issues/3328807": "https://www.drupal.org/files/issues/2023-01-06/3328807-focal_point-image_width_when_no_image_to_crop.patch"
},
"drupal/google_analytics": {
"https://www.drupal.org/project/google_analytics/issues/3373921": "https://www.drupal.org/files/issues/2023-08-07/google-analytics-issues-3373921-cannot-install-from-existing-config-11.patch"
},
"drupal/hook_event_dispatcher": {
"https://www.drupal.org/project/hook_event_dispatcher/issues/3354751": "https://www.drupal.org/files/issues/2023-04-17/hook_event_dispatcher-4.x-3354751.patch"
},
Expand Down
Loading

0 comments on commit e930da0

Please sign in to comment.