From 54a87cebfded60f422cb72dd5e800fc5cf2a625b Mon Sep 17 00:00:00 2001 From: Steve Wirt Date: Mon, 12 Feb 2024 12:29:02 -0500 Subject: [PATCH 01/13] VACMS-16233 Reorder VAMC menus (#17189) * VACMS-4943 Remove VA Leavenworh menu. It is empty and not used. * VACMS-4943 Remove VA Topeka menu. It is empty and not used. * VACMS-14683 Bring in scripts changes from 14683. * VACMS-16233 Add reorder VAMC System menu items. --- ...ent.va-leavenworth-health-care.changed.yml | 18 -- ...va-leavenworth-health-care.description.yml | 18 -- ...ent.va-leavenworth-health-care.metatag.yml | 18 -- ...ntent.va-leavenworth-health-care.title.yml | 18 -- ...t.va-leavenworth-health-care.view_mode.yml | 20 -- ..._content.va-topeka-health-care.changed.yml | 18 -- ...tent.va-topeka-health-care.description.yml | 18 -- ..._content.va-topeka-health-care.metatag.yml | 18 -- ...nk_content.va-topeka-health-care.title.yml | 18 -- ...ontent.va-topeka-health-care.view_mode.yml | 20 -- ...ink_content.va-leavenworth-health-care.yml | 18 -- ...enu_link_content.va-topeka-health-care.yml | 18 -- ...system.menu.va-leavenworth-health-care.yml | 14 -- .../system.menu.va-topeka-health-care.yml | 14 -- .../VACMS-16233-reorder-vamc-menu-items.php | 99 ++++++++++ scripts/content/script-library.php | 174 +++++++++++++++++- 16 files changed, 268 insertions(+), 253 deletions(-) delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.changed.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.description.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.metatag.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.title.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.view_mode.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.changed.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.description.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.metatag.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.title.yml delete mode 100644 config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.view_mode.yml delete mode 100644 config/sync/language.content_settings.menu_link_content.va-leavenworth-health-care.yml delete mode 100644 config/sync/language.content_settings.menu_link_content.va-topeka-health-care.yml delete mode 100644 config/sync/system.menu.va-leavenworth-health-care.yml delete mode 100644 config/sync/system.menu.va-topeka-health-care.yml create mode 100644 scripts/content/VACMS-16233-reorder-vamc-menu-items.php diff --git a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.changed.yml b/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.changed.yml deleted file mode 100644 index 3d4cd89268..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.changed.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 3f2d2ec2-879e-47d8-a8cc-5d09217436e4 -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care -id: menu_link_content.va-leavenworth-health-care.changed -field_name: changed -entity_type: menu_link_content -bundle: va-leavenworth-health-care -label: Changed -description: 'The time that the menu link was last edited.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: changed diff --git a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.description.yml b/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.description.yml deleted file mode 100644 index a222be04cf..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.description.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: ef139ac8-8c31-4da1-86f0-8af6d9749032 -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care -id: menu_link_content.va-leavenworth-health-care.description -field_name: description -entity_type: menu_link_content -bundle: va-leavenworth-health-care -label: Description -description: 'Shown when hovering over the menu link.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.metatag.yml b/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.metatag.yml deleted file mode 100644 index 8b4f04fae8..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.metatag.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: f8faf9ea-96fb-49b4-89a1-85f599800efc -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care -id: menu_link_content.va-leavenworth-health-care.metatag -field_name: metatag -entity_type: menu_link_content -bundle: va-leavenworth-health-care -label: 'Metatags (Hidden field for JSON support)' -description: 'The meta tags for the entity.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: map diff --git a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.title.yml b/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.title.yml deleted file mode 100644 index 3651823a04..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.title.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 45771ebb-ff9f-4d41-8091-199095f6980c -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care -id: menu_link_content.va-leavenworth-health-care.title -field_name: title -entity_type: menu_link_content -bundle: va-leavenworth-health-care -label: 'Menu link title' -description: 'The text to be used for this link in the menu.' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.view_mode.yml b/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.view_mode.yml deleted file mode 100644 index f847dbe409..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-leavenworth-health-care.view_mode.yml +++ /dev/null @@ -1,20 +0,0 @@ -uuid: b967b3f4-3b6a-4952-8bdd-1e29215e7d8b -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care - module: - - menu_item_extras -id: menu_link_content.va-leavenworth-health-care.view_mode -field_name: view_mode -entity_type: menu_link_content -bundle: va-leavenworth-health-care -label: 'View mode' -description: 'Per item view mode selector.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.changed.yml b/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.changed.yml deleted file mode 100644 index ec451acb13..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.changed.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 53d9a2c1-1088-4094-b3bb-abc9e2385fe5 -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care -id: menu_link_content.va-topeka-health-care.changed -field_name: changed -entity_type: menu_link_content -bundle: va-topeka-health-care -label: Changed -description: 'The time that the menu link was last edited.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: changed diff --git a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.description.yml b/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.description.yml deleted file mode 100644 index 51dc51476b..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.description.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 87dd9f31-45a2-47e2-af3a-eb37a7f620d2 -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care -id: menu_link_content.va-topeka-health-care.description -field_name: description -entity_type: menu_link_content -bundle: va-topeka-health-care -label: Description -description: 'Shown when hovering over the menu link.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.metatag.yml b/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.metatag.yml deleted file mode 100644 index dd4a79ef27..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.metatag.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: da6103a5-de28-41dd-b4f0-53087bee2889 -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care -id: menu_link_content.va-topeka-health-care.metatag -field_name: metatag -entity_type: menu_link_content -bundle: va-topeka-health-care -label: 'Metatags (Hidden field for JSON support)' -description: 'The meta tags for the entity.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: map diff --git a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.title.yml b/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.title.yml deleted file mode 100644 index 78836b9b2a..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.title.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: bf001922-b5fd-479d-acab-a25fb32ebca6 -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care -id: menu_link_content.va-topeka-health-care.title -field_name: title -entity_type: menu_link_content -bundle: va-topeka-health-care -label: 'Menu link title' -description: 'The text to be used for this link in the menu.' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.view_mode.yml b/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.view_mode.yml deleted file mode 100644 index 219cb08a5e..0000000000 --- a/config/sync/core.base_field_override.menu_link_content.va-topeka-health-care.view_mode.yml +++ /dev/null @@ -1,20 +0,0 @@ -uuid: 24007f4e-cbb3-4b84-a87f-1416ee0818fb -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care - module: - - menu_item_extras -id: menu_link_content.va-topeka-health-care.view_mode -field_name: view_mode -entity_type: menu_link_content -bundle: va-topeka-health-care -label: 'View mode' -description: 'Per item view mode selector.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/config/sync/language.content_settings.menu_link_content.va-leavenworth-health-care.yml b/config/sync/language.content_settings.menu_link_content.va-leavenworth-health-care.yml deleted file mode 100644 index ea070a35f9..0000000000 --- a/config/sync/language.content_settings.menu_link_content.va-leavenworth-health-care.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 79299311-302d-4d60-a3ef-cecf4524d356 -langcode: en -status: true -dependencies: - config: - - system.menu.va-leavenworth-health-care - module: - - content_translation -third_party_settings: - content_translation: - enabled: false - bundle_settings: - untranslatable_fields_hide: '0' -id: menu_link_content.va-leavenworth-health-care -target_entity_type_id: menu_link_content -target_bundle: va-leavenworth-health-care -default_langcode: site_default -language_alterable: false diff --git a/config/sync/language.content_settings.menu_link_content.va-topeka-health-care.yml b/config/sync/language.content_settings.menu_link_content.va-topeka-health-care.yml deleted file mode 100644 index bbf25f9eaf..0000000000 --- a/config/sync/language.content_settings.menu_link_content.va-topeka-health-care.yml +++ /dev/null @@ -1,18 +0,0 @@ -uuid: 22aacb56-0220-4aaa-9a8f-f999dd970e91 -langcode: en -status: true -dependencies: - config: - - system.menu.va-topeka-health-care - module: - - content_translation -third_party_settings: - content_translation: - enabled: false - bundle_settings: - untranslatable_fields_hide: '0' -id: menu_link_content.va-topeka-health-care -target_entity_type_id: menu_link_content -target_bundle: va-topeka-health-care -default_langcode: site_default -language_alterable: false diff --git a/config/sync/system.menu.va-leavenworth-health-care.yml b/config/sync/system.menu.va-leavenworth-health-care.yml deleted file mode 100644 index f982dc911b..0000000000 --- a/config/sync/system.menu.va-leavenworth-health-care.yml +++ /dev/null @@ -1,14 +0,0 @@ -uuid: efdadc4b-3464-454c-975d-0cd0a83b883a -langcode: en -status: true -dependencies: - module: - - workbench_menu_access -third_party_settings: - workbench_menu_access: - access_scheme: - 356: '356' -id: va-leavenworth-health-care -label: 'VA Leavenworth health care' -description: 'VISN 15 | va.gov/leavenworth-health-care' -locked: false diff --git a/config/sync/system.menu.va-topeka-health-care.yml b/config/sync/system.menu.va-topeka-health-care.yml deleted file mode 100644 index 117c10a37d..0000000000 --- a/config/sync/system.menu.va-topeka-health-care.yml +++ /dev/null @@ -1,14 +0,0 @@ -uuid: 07a6a9a5-dfe2-4b02-8466-526d27a5d24d -langcode: en -status: true -dependencies: - module: - - workbench_menu_access -third_party_settings: - workbench_menu_access: - access_scheme: - 360: '360' -id: va-topeka-health-care -label: 'VA Topeka health care' -description: 'VISN 15 | va.gov/topeka-health-care' -locked: false diff --git a/scripts/content/VACMS-16233-reorder-vamc-menu-items.php b/scripts/content/VACMS-16233-reorder-vamc-menu-items.php new file mode 100644 index 0000000000..41123b2247 --- /dev/null +++ b/scripts/content/VACMS-16233-reorder-vamc-menu-items.php @@ -0,0 +1,99 @@ + 0]; + do { + print(va_gov_vamc_deploy_resort_vamc_menus($sandbox)); + } while ($sandbox['#finished'] < 1); + + return "Script run complete. All menus should have been updated. "; +} + +/** + * Re-sort VAMC menus. + * + * @param mixed $sandbox + * Batch sandbox to keep state during multiple runs. + * + * @return string + * The message to be output. + */ +function va_gov_vamc_deploy_resort_vamc_menus(&$sandbox) { + script_library_sandbox_init($sandbox, '_va_gov_vamc_get_system_menus', []); + _va_gov_vamc_arrange_menus($sandbox); + return script_library_sandbox_complete($sandbox, "Re-arranged @total VAMC System Menus."); +} + +/** + * Get all VAMC system menus. + * + * @return array + * An array of VAMC system menus ['machine_name' => 'Human Name']. + */ +function _va_gov_vamc_get_system_menus(): array { + // Load the menus. + $vamc_menus = MenuManipulator::getAllMenuNames('-health-'); + $non_name_compliant_menus = [ + 'va-central-western-massachusetts' => 'VA Central Western Massachusetts health care', + 'va-columbia-south-carolina-healt' => 'VA Columbia South Carolina health care', + 'va-lebanon' => 'VA Lebanon health care', + ]; + + return array_merge($vamc_menus, $non_name_compliant_menus); +} + +/** + * Re-arranges existing VAMC menus to match a pattern. + * + * @param mixed $sandbox + * Batch sandbox to keep state during multiple runs. + * + * @return string + * A message to be output. + */ +function _va_gov_vamc_arrange_menus(&$sandbox) { + $menu_name = array_key_first($sandbox['items_to_process']); + $pattern = [ + 'About us', + 'Programs', + 'Research', + 'Policies', + 'VA police', + 'Work with us', + 'Contact us', + ]; + $menu_arranger = new MenuManipulator($menu_name); + $menu_arranger->matchPattern($pattern); + $message = "The menu {$sandbox['items_to_process'][$menu_name]} had been rearranged."; + unset($sandbox['items_to_process'][$menu_name]); + $sandbox['current']++; + + return $message; +} diff --git a/scripts/content/script-library.php b/scripts/content/script-library.php index b78c6799ec..6363a152b9 100644 --- a/scripts/content/script-library.php +++ b/scripts/content/script-library.php @@ -3,13 +3,21 @@ /** * @file * Common code related to drupal content scripts. + * + * This file can also be included in other things that run during non-full + * bootstrap processes like hook_update_n, post update, and deploy. + * Put the following line wherever you want to use this library. + * require_once __DIR__ . '/script-library.php'; */ +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Utility\UpdateException; use Drupal\node\NodeInterface; use Drupal\node\NodeStorageInterface; use Drupal\taxonomy\Entity\Term; use Drupal\user\UserStorageInterface; +use Psr\Log\LogLevel; const CMS_MIGRATOR_ID = 1317; @@ -152,6 +160,37 @@ function normalize_crisis_number($input, $plain = FALSE): string { return $output; } +/** + * Get an array of node ids for batch processing. + * + * @param string $node_bundle + * The bundle name of the nodes to lookup. + * @param bool $published_only + * TRUE if you need only published nodes. + * + * @return array + * An array of nids for for the requested bundle. + */ +function get_nids_of_type($node_bundle, $published_only = FALSE): array { + $query = \Drupal::entityQuery('node') + ->condition('type', $node_bundle) + ->accessCheck(FALSE); + if ($published_only) { + $query->condition('status', 1); + } + + $nids = $query->execute(); + // Having a node ids as a numeric keyed array is problematic when it comes + // to removing things from the array. As soon as you unset one, the array + // becomes renumbered. So we create string keys, with numeric values. + // [35, 75, 20] becomes + // ['node_35' => 35, 'node_75' => 75, 'node_20' => 20]. + $node_ids = array_combine( + array_map('_va_gov_stringifynid', array_values($nids)), + array_values($nids)); + return $node_ids; +} + /** * Saves a node revision with log messaging. * @@ -170,16 +209,18 @@ function save_node_revision(NodeInterface $node, $message = '', $new = TRUE): in $node->setNewRevision($new); $node->setSyncing(TRUE); $node->setValidationRequired(FALSE); + $node->enforceIsNew(FALSE); // New revisions deserve special treatment. if ($new) { - $node->enforceIsNew(TRUE); $node->setChangedTime(time()); $node->setRevisionCreationTime(time()); $uid = CMS_MIGRATOR_ID; } else { - $node->enforceIsNew(FALSE); $uid = $node->getRevisionUserId(); + // Append new log message to previous log message. + $prefix = !empty($message) ? $node->getRevisionLogMessage() . ' - ' : ''; + $message = $prefix . $message; } $node->setRevisionUserId($uid); $revision_time = $node->getRevisionCreationTime(); @@ -188,9 +229,7 @@ function save_node_revision(NodeInterface $node, $message = '', $new = TRUE): in // the value is not different from the original value. $revision_time++; $node->setRevisionCreationTime($revision_time); - // Append new log message to previous log message. - $prefix = !empty($message) ? $node->getRevisionLogMessage() . ' - ' : ''; - $node->setRevisionLogMessage($prefix . $message); + $node->setRevisionLogMessage($message); $node->set('moderation_state', $moderation_state); return $node->save(); @@ -258,6 +297,131 @@ function save_new_terms($vocabulary_id, array $terms): int { return $terms_created; } +/** + * Initializes the basic sandbox values. + * + * @param array $sandbox + * Standard drupal $sandbox var to keep state in hook_update_N. + * @param string $counter_callback + * A function name to call to get the items to process. Must return an array. + * @param array $callback_args + * A flat array of arguments to pass to the counter_callback. + * + * @throws Drupal\Core\Utility\UpdateException + * If the counter callback can not be found. + */ +function script_library_sandbox_init(array &$sandbox, $counter_callback, array $callback_args = []) { + if (empty($sandbox['total'])) { + // Sandbox has not been initiated. + if (is_callable($counter_callback)) { + $sandbox['items_to_process'] = call_user_func_array($counter_callback, $callback_args); + $sandbox['total'] = count($sandbox['items_to_process']); + $sandbox['current'] = 0; + } + else { + // Something went wrong could not use callback. Throw exception. + throw new UpdateException( + "Counter callback {$counter_callback} provided in script_library_sandbox_init() is not callable. Can not proceed." + ); + } + } +} + +/** + * Updates the counts and log if complete. + * + * @param array $sandbox + * Hook_update_n sandbox for keeping state. + * @param string $completed_message + * Message to log when completed. Can use '@completed' and '@total' as tokens. + * + * @return string + * String to be used as update hook messages. + */ +function script_library_sandbox_complete(array &$sandbox, $completed_message) { + // Determine when to stop batching. + $sandbox['current'] = ($sandbox['total'] - count($sandbox['items_to_process'])); + $sandbox['#finished'] = (empty($sandbox['total'])) ? 1 : ($sandbox['current'] / $sandbox['total']); + $vars = [ + '@completed' => $sandbox['current'], + '@total' => $sandbox['total'], + ]; + $message = t('Processing... @completed/@total.', $vars) . PHP_EOL; + // Log the all finished notice. + if ($sandbox['#finished'] === 1) { + Drupal::logger('va_gov_vamc')->log(LogLevel::INFO, $completed_message, $vars); + $logged_message = new FormattableMarkup($completed_message, $vars); + $message = t('Process completed:') . " {$logged_message}" . PHP_EOL; + } + return $message; +} + +/** + * Lookup a key in a map array and return the value from the map. + * + * @param string|null $lookup + * A map key to lookup. Do not lookup int as indexes can shift. + * @param array $map + * An array containing string key value pairs. [lookup => value]. + * @param bool $strict + * TRUE = only want a value from the array, FALSE = want your lookup back. + * + * @return mixed + * Whatever the value associated with the key. + */ +function script_libary_map_to_value(string|null $lookup, array $map, bool $strict = TRUE) : mixed { + if (empty($lookup)) { + if (isset($map['default'])) { + // There is a default set, so use it. + return $map['default']; + } + elseif ($strict) { + return NULL; + } + else { + return $lookup; + } + } + if ($strict) { + // Strict, so either it is there, or nothing. + return $map[$lookup] ?? NULL; + } + else { + // Not strict, so pass back what given it its not in the map. + return $map[$lookup] ?? $lookup; + } +} + +/** + * Turns on or off queueing of items to the post_api. + * + * CAUTION: The only time we would want to fully disable queueing is during a + * deploy when editors can not save anything. + * + * @param bool $state + * TRUE to toggle the settings on, FALSE to toggle them off. + */ +function script_library_disable_post_api_queueing(bool $state): void { + $on = ($state) ? 1 : 0; + $config_post_api = \Drupal::configFactory()->getEditable('post_api.settings'); + $config_post_api->set('disable_queueing', $on) + ->save(FALSE); + script_library_skip_post_api_data_check($state); +} + +/** + * Turns on or off data checks and deduping for adding items to post_api queue. + * + * @param bool $state + * TRUE to toggle the settings on, FALSE to toggle them off. + */ +function script_library_skip_post_api_data_check(bool $state): void { + $on = ($state) ? 1 : 0; + $config_va_gov_post_api = \Drupal::configFactory()->getEditable('va_gov_post_api.settings'); + $config_va_gov_post_api->set('bypass_data_check', $on) + ->save(FALSE); +} + /** * Callback function to concat node ids with string. * From 7eaf876f786498358a3de279b1d3f20e81431672 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 11:30:32 -0800 Subject: [PATCH 02/13] Bump va-gov/content-build from 0.0.3437 to 0.0.3438 (#17180) Bumps [va-gov/content-build](https://github.com/department-of-veterans-affairs/content-build) from 0.0.3437 to 0.0.3438. - [Release notes](https://github.com/department-of-veterans-affairs/content-build/releases) - [Commits](https://github.com/department-of-veterans-affairs/content-build/compare/v0.0.3437...v0.0.3438) --- updated-dependencies: - dependency-name: va-gov/content-build dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Edmund Dunn <109987005+edmund-dunn@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9e9478136f..ca884a10c7 100644 --- a/composer.json +++ b/composer.json @@ -221,7 +221,7 @@ "symfony/phpunit-bridge": "^5.1", "symfony/process": "^6.3", "symfony/routing": "^6.3", - "va-gov/content-build": "^0.0.3437", + "va-gov/content-build": "^0.0.3438", "vlucas/phpdotenv": "^5.3", "webflo/drupal-finder": "^1.0.0", "webmozart/path-util": "^2.3", diff --git a/composer.lock b/composer.lock index 30afbf6c26..0da326200d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5a2e47403b810bc18a1b3c3793555a6a", + "content-hash": "6ca07aefb604394deced04a91e7826c7", "packages": [ { "name": "asm89/stack-cors", @@ -25807,7 +25807,7 @@ }, { "name": "va-gov/content-build", - "version": "v0.0.3437", + "version": "v0.0.3438", "source": { "type": "git", "url": "https://github.com/department-of-veterans-affairs/content-build.git", @@ -25843,7 +25843,7 @@ "description": "Front-end for VA.gov. This repository contains the code that generates the www.va.gov website. It contains a Metalsmith static site builder that uses a Drupal CMS for content. This file is here to publish releases to https://packagist.org/packages/va-gov/content-build, so that the CMS CI system can install it and update it using standard composer processes, and so that we can run tests across both systems. See https://github.com/department-of-veterans-affairs/va.gov-cms for the CMS repo, and stand by for more documentation.", "support": { "issues": "https://github.com/department-of-veterans-affairs/content-build/issues", - "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3437" + "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3438" }, "time": "2024-02-06T20:33:35+00:00" }, From 3bebdbd0b2fb86fad62af6788b8ec642ef1986c5 Mon Sep 17 00:00:00 2001 From: Nate Douglas Date: Mon, 12 Feb 2024 16:11:17 -0500 Subject: [PATCH 03/13] Update tugboat.md --- READMES/devops/tugboat.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/READMES/devops/tugboat.md b/READMES/devops/tugboat.md index de0332abaa..e0551b3ef6 100644 --- a/READMES/devops/tugboat.md +++ b/READMES/devops/tugboat.md @@ -36,6 +36,8 @@ Can only update CPU and memory at a project level, not repository level. ## Tugboat Crisis Intervention +Shelling into the Tugboat server can be accomplished with `ssm-session tugboat utility`. + ### Overload **Symptoms**: Tugboat is slow, requests to Tugboat dashboard return 502/504 status codes, previews disappear and reappear, etc. From 6293b563505044c05f318d767e0b0fd34ba62e41 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:01:05 -0800 Subject: [PATCH 04/13] Bump va-gov/content-build from 0.0.3438 to 0.0.3439 (#17217) Bumps [va-gov/content-build](https://github.com/department-of-veterans-affairs/content-build) from 0.0.3438 to 0.0.3439. - [Release notes](https://github.com/department-of-veterans-affairs/content-build/releases) - [Commits](https://github.com/department-of-veterans-affairs/content-build/compare/v0.0.3438...v0.0.3439) --- updated-dependencies: - dependency-name: va-gov/content-build dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index ca884a10c7..e131258609 100644 --- a/composer.json +++ b/composer.json @@ -221,7 +221,7 @@ "symfony/phpunit-bridge": "^5.1", "symfony/process": "^6.3", "symfony/routing": "^6.3", - "va-gov/content-build": "^0.0.3438", + "va-gov/content-build": "^0.0.3439", "vlucas/phpdotenv": "^5.3", "webflo/drupal-finder": "^1.0.0", "webmozart/path-util": "^2.3", diff --git a/composer.lock b/composer.lock index 0da326200d..f24c39f1c6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6ca07aefb604394deced04a91e7826c7", + "content-hash": "15c7c7fba07e61d6be8de41d94c2619f", "packages": [ { "name": "asm89/stack-cors", @@ -25807,16 +25807,16 @@ }, { "name": "va-gov/content-build", - "version": "v0.0.3438", + "version": "v0.0.3439", "source": { "type": "git", "url": "https://github.com/department-of-veterans-affairs/content-build.git", - "reference": "7e1bb61b6bb656124410196ee2bb9933417c8db5" + "reference": "ef743f09f6c05b78d40bfb01730aac12f3d35988" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/department-of-veterans-affairs/content-build/zipball/7e1bb61b6bb656124410196ee2bb9933417c8db5", - "reference": "7e1bb61b6bb656124410196ee2bb9933417c8db5", + "url": "https://api.github.com/repos/department-of-veterans-affairs/content-build/zipball/ef743f09f6c05b78d40bfb01730aac12f3d35988", + "reference": "ef743f09f6c05b78d40bfb01730aac12f3d35988", "shasum": "" }, "type": "node-project", @@ -25843,9 +25843,9 @@ "description": "Front-end for VA.gov. This repository contains the code that generates the www.va.gov website. It contains a Metalsmith static site builder that uses a Drupal CMS for content. This file is here to publish releases to https://packagist.org/packages/va-gov/content-build, so that the CMS CI system can install it and update it using standard composer processes, and so that we can run tests across both systems. See https://github.com/department-of-veterans-affairs/va.gov-cms for the CMS repo, and stand by for more documentation.", "support": { "issues": "https://github.com/department-of-veterans-affairs/content-build/issues", - "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3438" + "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3439" }, - "time": "2024-02-06T20:33:35+00:00" + "time": "2024-02-08T21:53:11+00:00" }, { "name": "vlucas/phpdotenv", @@ -26816,6 +26816,7 @@ "drupal/cer": 10, "drupal/change_labels": 20, "drupal/ckeditor_abbreviation": 15, + "drupal/codit_menu_tools": 15, "drupal/components": 10, "drupal/danse_content_moderation": 10, "drupal/entity_block": 10, From abbd25885e5e944629d45d698a292efa445a869f Mon Sep 17 00:00:00 2001 From: Christian Burk Date: Tue, 13 Feb 2024 14:52:57 -0600 Subject: [PATCH 05/13] VACMS-17221: Restore field_intro_text (#17222) * Restores field.field.node.vba_facility.field_intro_text.yml * Restores field.field.node.vba_facility.field_intro_text.yml * Delete config/sync/config/sync directory Remove accidentally created directory --- ...eld.node.vba_facility.field_intro_text.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 config/sync/field.field.node.vba_facility.field_intro_text.yml diff --git a/config/sync/field.field.node.vba_facility.field_intro_text.yml b/config/sync/field.field.node.vba_facility.field_intro_text.yml new file mode 100644 index 0000000000..5a7e2cdc54 --- /dev/null +++ b/config/sync/field.field.node.vba_facility.field_intro_text.yml @@ -0,0 +1,19 @@ +uuid: 541dfb7a-95a2-44eb-9ac7-6d266d6a8345 +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_intro_text + - node.type.vba_facility +id: node.vba_facility.field_intro_text +field_name: field_intro_text +entity_type: node +bundle: vba_facility +label: 'Page introduction' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: string_long From 829e12ffcc33f440d62a4e5c38af5f5ae771c68f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 17:40:04 -0800 Subject: [PATCH 06/13] Bump drupal/codit_menu_tools from 1.0.1 to 1.0.3 (#17233) Bumps drupal/codit_menu_tools from 1.0.1 to 1.0.3. --- updated-dependencies: - dependency-name: drupal/codit_menu_tools dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index f24c39f1c6..433eed340e 100644 --- a/composer.lock +++ b/composer.lock @@ -3055,17 +3055,17 @@ }, { "name": "drupal/codit_menu_tools", - "version": "1.0.1", + "version": "1.0.3", "source": { "type": "git", "url": "https://git.drupalcode.org/project/codit_menu_tools.git", - "reference": "1.0.1" + "reference": "1.0.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/codit_menu_tools-1.0.1.zip", - "reference": "1.0.1", - "shasum": "06327db394d467cf1dcb40db4328364d32822a7a" + "url": "https://ftp.drupal.org/files/projects/codit_menu_tools-1.0.3.zip", + "reference": "1.0.3", + "shasum": "090d85ecc45291e72da636ff2d51cd226f4366b7" }, "require": { "drupal/core": "^10" @@ -3073,8 +3073,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "1.0.1", - "datestamp": "1707535222", + "version": "1.0.3", + "datestamp": "1707873156", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -26816,7 +26816,6 @@ "drupal/cer": 10, "drupal/change_labels": 20, "drupal/ckeditor_abbreviation": 15, - "drupal/codit_menu_tools": 15, "drupal/components": 10, "drupal/danse_content_moderation": 10, "drupal/entity_block": 10, From 3ffc27a6ba33c6285465aaddd4e713badb5c8fe0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:37:03 -0800 Subject: [PATCH 07/13] Bump va-gov/content-build from 0.0.3439 to 0.0.3440 (#17246) Bumps [va-gov/content-build](https://github.com/department-of-veterans-affairs/content-build) from 0.0.3439 to 0.0.3440. - [Release notes](https://github.com/department-of-veterans-affairs/content-build/releases) - [Commits](https://github.com/department-of-veterans-affairs/content-build/compare/v0.0.3439...v0.0.3440) --- updated-dependencies: - dependency-name: va-gov/content-build dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index e131258609..74ad0e308e 100644 --- a/composer.json +++ b/composer.json @@ -221,7 +221,7 @@ "symfony/phpunit-bridge": "^5.1", "symfony/process": "^6.3", "symfony/routing": "^6.3", - "va-gov/content-build": "^0.0.3439", + "va-gov/content-build": "^0.0.3440", "vlucas/phpdotenv": "^5.3", "webflo/drupal-finder": "^1.0.0", "webmozart/path-util": "^2.3", diff --git a/composer.lock b/composer.lock index 433eed340e..cc3f1ee783 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "15c7c7fba07e61d6be8de41d94c2619f", + "content-hash": "3972bf23590490ac39137ab6b269c754", "packages": [ { "name": "asm89/stack-cors", @@ -25807,16 +25807,16 @@ }, { "name": "va-gov/content-build", - "version": "v0.0.3439", + "version": "v0.0.3440", "source": { "type": "git", "url": "https://github.com/department-of-veterans-affairs/content-build.git", - "reference": "ef743f09f6c05b78d40bfb01730aac12f3d35988" + "reference": "4ff558516c6af0270ce577b42127f5cd413ddf8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/department-of-veterans-affairs/content-build/zipball/ef743f09f6c05b78d40bfb01730aac12f3d35988", - "reference": "ef743f09f6c05b78d40bfb01730aac12f3d35988", + "url": "https://api.github.com/repos/department-of-veterans-affairs/content-build/zipball/4ff558516c6af0270ce577b42127f5cd413ddf8f", + "reference": "4ff558516c6af0270ce577b42127f5cd413ddf8f", "shasum": "" }, "type": "node-project", @@ -25843,9 +25843,9 @@ "description": "Front-end for VA.gov. This repository contains the code that generates the www.va.gov website. It contains a Metalsmith static site builder that uses a Drupal CMS for content. This file is here to publish releases to https://packagist.org/packages/va-gov/content-build, so that the CMS CI system can install it and update it using standard composer processes, and so that we can run tests across both systems. See https://github.com/department-of-veterans-affairs/va.gov-cms for the CMS repo, and stand by for more documentation.", "support": { "issues": "https://github.com/department-of-veterans-affairs/content-build/issues", - "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3439" + "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3440" }, - "time": "2024-02-08T21:53:11+00:00" + "time": "2024-02-14T14:09:01+00:00" }, { "name": "vlucas/phpdotenv", @@ -26816,6 +26816,7 @@ "drupal/cer": 10, "drupal/change_labels": 20, "drupal/ckeditor_abbreviation": 15, + "drupal/codit_menu_tools": 15, "drupal/components": 10, "drupal/danse_content_moderation": 10, "drupal/entity_block": 10, From 6d4696e536768da0ae5e40508ffc43f7158c6cb1 Mon Sep 17 00:00:00 2001 From: Steve Wirt Date: Thu, 15 Feb 2024 12:26:44 -0500 Subject: [PATCH 08/13] VACMS-16233 make script batches pick up where they left off (#17236) * VACMS-16233 Make script-library sandbox keep track of the last success and resume. * VACMS-16233 Make menu script report progress more specific. * Fix logging category. --- .../VACMS-16233-reorder-vamc-menu-items.php | 13 ++++++----- scripts/content/script-library.php | 22 +++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/scripts/content/VACMS-16233-reorder-vamc-menu-items.php b/scripts/content/VACMS-16233-reorder-vamc-menu-items.php index 41123b2247..15c50e79c8 100644 --- a/scripts/content/VACMS-16233-reorder-vamc-menu-items.php +++ b/scripts/content/VACMS-16233-reorder-vamc-menu-items.php @@ -12,7 +12,10 @@ * If for some reason the run crashes before it is complete: * - Check CMS recent log messages for cause * /admin/reports/dblog?type%5B%5D=codit_menu_tools - * - Simply re-run the script. + * - Simply re-run the script, it will pick up where it left off. + * - If for some reason you need to start it at a different number, you can use + * `drush php:eval '\Drupal::state()->set("script_library__va_gov_vamc_get_system_menus", DESIRED_NUMBER);'` + * to set the last number that ran successfully. */ use Drupal\codit_menu_tools\MenuManipulator; @@ -47,8 +50,8 @@ function run(): string { */ function va_gov_vamc_deploy_resort_vamc_menus(&$sandbox) { script_library_sandbox_init($sandbox, '_va_gov_vamc_get_system_menus', []); - _va_gov_vamc_arrange_menus($sandbox); - return script_library_sandbox_complete($sandbox, "Re-arranged @total VAMC System Menus."); + $message = _va_gov_vamc_arrange_menus($sandbox); + return $message . script_library_sandbox_complete($sandbox, "Re-arranged @total VAMC System Menus."); } /** @@ -91,9 +94,9 @@ function _va_gov_vamc_arrange_menus(&$sandbox) { ]; $menu_arranger = new MenuManipulator($menu_name); $menu_arranger->matchPattern($pattern); - $message = "The menu {$sandbox['items_to_process'][$menu_name]} had been rearranged."; + $message = "The menu {$sandbox['items_to_process'][$menu_name]} had been rearranged. "; + // It has been run successfully, so remove it. unset($sandbox['items_to_process'][$menu_name]); - $sandbox['current']++; return $message; } diff --git a/scripts/content/script-library.php b/scripts/content/script-library.php index 6363a152b9..ac00016965 100644 --- a/scripts/content/script-library.php +++ b/scripts/content/script-library.php @@ -317,6 +317,17 @@ function script_library_sandbox_init(array &$sandbox, $counter_callback, array $ $sandbox['items_to_process'] = call_user_func_array($counter_callback, $callback_args); $sandbox['total'] = count($sandbox['items_to_process']); $sandbox['current'] = 0; + $sandbox['multi_run_state_key'] = "script_library_$counter_callback"; + + // This seems like the first run, see if there is already a state saved + // from a previous attempt. + $last_run_completed = \Drupal::state()->get($sandbox['multi_run_state_key']); + if (!is_null($last_run_completed)) { + // A state exists, so alter the 'current' and 'items_to_process'. + $sandbox['current'] = $last_run_completed + 1; + // Remove the last successful run, and all that came before it. + $sandbox['items_to_process'] = array_slice($sandbox['items_to_process'], $last_run_completed); + } } else { // Something went wrong could not use callback. Throw exception. @@ -325,6 +336,7 @@ function script_library_sandbox_init(array &$sandbox, $counter_callback, array $ ); } } + $sandbox['element'] = array_key_first($sandbox['items_to_process']); } /** @@ -341,17 +353,23 @@ function script_library_sandbox_init(array &$sandbox, $counter_callback, array $ function script_library_sandbox_complete(array &$sandbox, $completed_message) { // Determine when to stop batching. $sandbox['current'] = ($sandbox['total'] - count($sandbox['items_to_process'])); + // Save the 'current' value to state, to record a successful run. + \Drupal::state()->set($sandbox['multi_run_state_key'], $sandbox['current']); $sandbox['#finished'] = (empty($sandbox['total'])) ? 1 : ($sandbox['current'] / $sandbox['total']); $vars = [ '@completed' => $sandbox['current'], + '@element' => $sandbox['element'], '@total' => $sandbox['total'], ]; - $message = t('Processing... @completed/@total.', $vars) . PHP_EOL; + + $message = t('Processed @element. @completed/@total.', $vars) . PHP_EOL; // Log the all finished notice. if ($sandbox['#finished'] === 1) { - Drupal::logger('va_gov_vamc')->log(LogLevel::INFO, $completed_message, $vars); + Drupal::logger('script_library')->log(LogLevel::INFO, $completed_message, $vars); $logged_message = new FormattableMarkup($completed_message, $vars); $message = t('Process completed:') . " {$logged_message}" . PHP_EOL; + // Delete the state as it is no longer needed. + \Drupal::state()->delete($sandbox['multi_run_state_key']); } return $message; } From 828acc9b9adad7361649f454bc1e6e4a2756b46a Mon Sep 17 00:00:00 2001 From: Alex Finnarn Date: Thu, 15 Feb 2024 15:26:28 -0500 Subject: [PATCH 09/13] VACMS-16853: next build branches ftw (#17154) * add next-build as an option for requesting a content release * only override needed form fields for content release form * be more specific with repo roots in settings for different envs * fix broken unit test * fix broken integration test * add api client for next-build * try different file root location * add frontend information to payload, pass info to build trigger * add start to next-build frontend script * update next-build-frontend.sh script * further separate content release state machines * remove seperate release state manager * remove all references to simulatenous building using current pattern * simpler build trigger within form submission * debug Tugboat * filename change for queue runner * try kicking off script via cron * add more debugging to cron run * correct git location for next-build * make build script executable * cleanup code * add documentation * more code cleanup * update docs to trigger after failed tugboat * cleanup code * Update scripts/next-build-frontend.sh Co-authored-by: Tanner Heffner * Update scripts/next-build-frontend.sh Co-authored-by: Tanner Heffner * Update scripts/next-build-frontend.sh Co-authored-by: Tanner Heffner * fixes from code review --------- Co-authored-by: Tanner Heffner --- .tugboat/config.yml | 7 + READMES/cms-content-release.md | 30 +- ...xt.next_site.next_build_preview_server.yml | 4 +- .../custom/va_gov_content_release/README.md | 13 + .../src/Form/NextGitForm.php | 399 ++++++++++++++++++ .../FrontendVersionSearch.php | 30 +- .../va_gov_content_release.module | 6 - .../va_gov_content_release.routing.yml | 8 + .../va_gov_content_release.services.yml | 2 + .../Factory/BranchSearchFactory.php | 8 + .../Factory/BranchSearchFactoryInterface.php | 8 + .../Repository/Factory/RepositoryFactory.php | 7 + .../Factory/RepositoryFactoryInterface.php | 11 +- .../Settings/RepositorySettings.php | 2 +- .../Settings/RepositorySettingsInterface.php | 5 + .../custom/va_gov_git/va_gov_git.services.yml | 4 + .../Api/Client/Factory/ApiClientFactory.php | 9 + .../Factory/ApiClientFactoryInterface.php | 11 + .../va_gov_github/va_gov_github.services.yml | 4 + docroot/sites/default/settings.php | 1 + .../default/settings/settings.tugboat.php | 1 + scripts/next-build-frontend.sh | 120 ++++++ scripts/next-build.sh | 13 +- scripts/next-install.sh | 14 +- scripts/queue_runner/next_queue_runner.sh | 6 + .../Settings/RepositorySettingsTest.php | 5 + .../Settings/RepositorySettingsTest.php | 7 + 27 files changed, 717 insertions(+), 18 deletions(-) create mode 100644 docroot/modules/custom/va_gov_content_release/README.md create mode 100644 docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php delete mode 100644 docroot/modules/custom/va_gov_content_release/va_gov_content_release.module create mode 100644 scripts/next-build-frontend.sh create mode 100644 scripts/queue_runner/next_queue_runner.sh diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 6e628ef6c4..e1f37c407e 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -226,6 +226,13 @@ services: - mv "${TUGBOAT_ROOT}/scripts/queue_runner/queue_runner.sh" /etc/service/drupal_events/run - chmod +x /etc/service/drupal_events/run + # Separate process for next-build preview. + - mkdir -p /etc/service/next_build + - mv "${TUGBOAT_ROOT}/scripts/queue_runner/next_queue_runner.sh" /etc/service/next_build/run + - chmod +x /etc/service/next_build/run + # Need to make build script executable so the runner can run it. + - chmod +x "${TUGBOAT_ROOT}/scripts/next-build-frontend.sh" + clone: # This j2 command is shared in both the build & clone stages. If modifying, change the other too. - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" diff --git a/READMES/cms-content-release.md b/READMES/cms-content-release.md index 8d9119600e..0c8c93e598 100644 --- a/READMES/cms-content-release.md +++ b/READMES/cms-content-release.md @@ -116,7 +116,6 @@ sequenceDiagram Complete->>+Ready: Content release workflow has completed ``` - # Environment specific details ## BRD Production @@ -144,6 +143,35 @@ The Tugboat and local development versions of the release content page do not tr For more information on creating or releasing content from a preview environment, see [Environments](./environments.md). +### Next Build Releases + +The upcoming static frontend "next-build" can be rebuilt using different versions of next-build and vets-website. It +is a simpler process than the current content-build workflow. + +1. Go to "/admin/content/deploy/next". +2. If the form elements are disabled, then a lock file exists preventing another build from being triggered. You + can skip to step #6. +2. Choose a version for next-build or leave at default. +3. Choose a version for vets-website or leave at default. When content-build is releasing, these form fields might + be disabled. We can't change the vets-website version while another frontend build is running. +4. Click "Release Content" to set the versions of next-build and vets-website as well as write a "buildrequest" file. +5. A `scripts/queue_runner/next_queue_runner.sh` script continuously runs in the background looking for the + "buildrequest" file and then start a build if found. Locally, the script has to be triggered manually. See the + [caveats](#caveats) section for more information. +6. Back on "/admin/content/deploy/next" you can view the build log via a link in the "Status" section of the + "Next Build Information" block. +7. Once the build completes no new build will be triggered until you click to release content again. +8. View the frontend at the provided "View Preview" link in the "Next Build Information" block. + +#### Caveats + +There are some caveats to the process outlined above. + +- **Manually running the background script** - On `ddev` the `queue_runner` scripts aren't running continuously in + background jobs. So you must `ddev ssh && ./scripts/queue_runner/` to kick off the content build or next build + release locally. In the future, it might be a good idea to use `system.d` or `supervisor` or something else to + keep the background jobs going locally just like on Tugoboat. + ## Troubleshooting Sometimes the state gets stuck and needs to be reset. It can be done with a drush command diff --git a/config/sync/next.next_site.next_build_preview_server.yml b/config/sync/next.next_site.next_build_preview_server.yml index 3e3a99c8bb..caf6c88f5d 100644 --- a/config/sync/next.next_site.next_build_preview_server.yml +++ b/config/sync/next.next_site.next_build_preview_server.yml @@ -4,8 +4,8 @@ status: true dependencies: { } id: next_build_preview_server label: 'Next Build Preview Server' -base_url: 'http://localhost:3000' -preview_url: 'http://localhost:3000/api/preview' +base_url: 'http://localhost:3999' +preview_url: 'http://localhost:3999/api/preview' preview_secret: secret revalidate_url: '' revalidate_secret: '' diff --git a/docroot/modules/custom/va_gov_content_release/README.md b/docroot/modules/custom/va_gov_content_release/README.md new file mode 100644 index 0000000000..226790fb81 --- /dev/null +++ b/docroot/modules/custom/va_gov_content_release/README.md @@ -0,0 +1,13 @@ +# VA.gov Content Release + +va.gov is built using two separate frontend systems with a third being built: + +- content-build - This is the frontend for generating static content files. You can read more about the project here: + https://github.com/department-of-veterans-affairs/content-build +- vets-website - This is the frontend for integrating React widgets. You can read more about the project here: + https://github.com/department-of-veterans-affairs/vets-website +- next-build - This is the new frontend for generating static content files. You can read more about the project here: + https://github.com/department-of-veterans-affairs/next-build + +More detailed documentation about how these frontends are build and released can be found in the main READMEs +directory on the [CMS Content Release](../../../../READMES/cms-content-release.md) page. diff --git a/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php b/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php new file mode 100644 index 0000000000..e20b3870b9 --- /dev/null +++ b/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php @@ -0,0 +1,399 @@ +frontendVersion = $frontendVersion; + $this->fileSystem = $fileSystem; + $this->config = $config; + $this->state = $state; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('va_gov_content_release.frontend_version'), + $container->get('file_system'), + $container->get('config.factory'), + $container->get('state') + ); + } + + /** + * Build the form. + * + * @param array $form + * Default form array structure. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + */ + public function buildForm(array $form, FormStateInterface $form_state) { + $form['build_request']['description'] = [ + '#prefix' => '

', + '#markup' => $this->t('Release content to update the front end of this environment with the latest published content changes.'), + '#suffix' => '

', + ]; + + $form['build_request']['next_build_selection'] = [ + '#title' => $this->t('Which version of next-build would you like to use?'), + '#type' => 'radios', + '#options' => [ + 'default' => $this->t('Use default - the next-build version from the time this demo environment was created.'), + 'choose' => $this->t('Select a different next-build branch/pull request - for example, to see your content in a newer frontend design.'), + ], + '#default_value' => 'default', + ]; + + $form['build_request']['next_build_git_ref'] = [ + '#type' => 'textfield', + '#title' => $this->t('Select branch/pull request'), + '#description' => $this->t('Start typing to select a branch for the next-build version you want to use.'), + '#autocomplete_route_name' => 'va_gov_content_release.frontend_version_autocomplete', + '#autocomplete_route_parameters' => [ + 'frontend' => 'next_build', + 'count' => 10, + ], + '#size' => 72, + '#maxlength' => 1024, + '#hidden' => TRUE, + '#states' => [ + 'visible' => [':input[name="next_build_selection"]' => ['value' => 'choose']], + ], + ]; + + $form['build_request']['vets_website_selection'] = [ + '#title' => $this->t('Which version of vets-website would you like to use?'), + '#type' => 'radios', + '#options' => [ + 'default' => $this->t('Use default - the vets-website version from the time this demo environment was created.'), + 'choose' => $this->t('Select a different vets-website branch/pull request - for example, to see your content in a newer frontend design.'), + ], + '#default_value' => 'default', + ]; + + $form['build_request']['vets_website_git_ref'] = [ + '#type' => 'textfield', + '#title' => $this->t('Select branch/pull request'), + '#description' => $this->t('Start typing to select a branch for the vets-website version you want to use.'), + '#autocomplete_route_name' => 'va_gov_content_release.frontend_version_autocomplete', + '#autocomplete_route_parameters' => [ + 'frontend' => 'vets_website', + 'count' => 10, + ], + '#size' => 72, + '#maxlength' => 1024, + '#hidden' => TRUE, + '#states' => [ + 'visible' => [':input[name="vets_website_selection"]' => ['value' => 'choose']], + ], + ]; + + $form['build_request']['actions']['#type'] = 'actions'; + $form['build_request']['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Release Content'), + '#button_type' => 'primary', + ]; + + // Lock the vets-website form fields if a content-build is in progress. + $build_status = $this->state->get('va_gov_build_trigger.release_state'); + if ($build_status !== ReleaseStateManager::STATE_READY) { + $form['build_request']['vets_website_selection']['#disabled'] = TRUE; + $form['build_request']['vets_website_git_ref']['#disabled'] = TRUE; + } + + // Disable form changes and submission if a build is in progress. + if (file_exists($this->fileSystem->realpath('public://' . self::LOCK_FILE_NAME))) { + $form['build_request']['next_build_selection']['#disabled'] = TRUE; + $form['build_request']['next_build_git_ref']['#disabled'] = TRUE; + $form['build_request']['vets_website_selection']['#disabled'] = TRUE; + $form['build_request']['vets_website_git_ref']['#disabled'] = TRUE; + $form['build_request']['actions']['submit']['#disabled'] = TRUE; + + $target_url = Url::fromUserInput("/sites/default/files/next-build.txt"); + $build_log_text = Link::fromTextAndUrl('Build is in progress. View log file', $target_url); + } + else { + $build_log_text = 'Build is not in progress.'; + } + + // Set variables needed for build status information. + $lock_file_text = $this->getFileLink(self::LOCK_FILE_NAME); + $request_file_text = $this->getFileLink(self::REQUEST_FILE_NAME); + $next_build_version = $this->frontendVersion->getVersion(Frontend::NextBuild); + $vets_website_version = $this->frontendVersion->getVersion(Frontend::VetsWebsite); + $view_preview = $this->getPreviewLink(); + $last_build_time = $this->state->get('next_build.status.last_build_date', 'N/A'); + $form['content_release_status_block'] = [ + '#theme' => 'status_report_grouped', + '#grouped_requirements' => [ + [ + 'title' => $this->t('Next Build Information'), + 'type' => 'content-release-status', + 'items' => [ + 'status' => [ + 'title' => $this->t('Status'), + 'value' => $build_log_text, + ], + 'lock_file' => [ + 'title' => $this->t('Lock File'), + 'value' => $lock_file_text, + ], + 'request_file' => [ + 'title' => $this->t('Request File'), + 'value' => $request_file_text, + ], + 'next_build_version' => [ + 'title' => $this->t('Next-build Version'), + 'value' => $next_build_version, + ], + 'vets_website_version' => [ + 'title' => $this->t('Vets-website Version'), + 'value' => $vets_website_version, + ], + 'view_preview' => [ + 'title' => $this->t('View Preview'), + 'value' => $view_preview, + ], + 'last_build_time' => [ + 'title' => $this->t('Last Build Time'), + 'value' => $last_build_time, + ], + ], + ], + ], + ]; + + return $form; + } + + /** + * Get the text for a file. + * + * @param string $file_name + * The name of the file. + * + * @return \Drupal\Core\Link|string + * The file link. + */ + private function getFileLink(string $file_name): Link|string { + $file_path = $this->fileSystem->realpath("public://$file_name"); + if (file_exists($file_path)) { + $target_url = Url::fromUserInput("/sites/default/files/$file_name"); + return Link::fromTextAndUrl($file_name, $target_url); + } + else { + return 'does not exist'; + } + } + + /** + * Get the preview link. + * + * @return \Drupal\Core\Link + * The preview link. + */ + private function getPreviewLink(): Link { + $frontend_base_url = $this->config + ->get('next.next_site.next_build_preview_server') + ->get('base_url'); + $target_url = Url::fromUri($frontend_base_url, ['attributes' => ['target' => '_blank']]); + return Link::fromTextAndUrl($this->t('View front end'), $target_url); + } + + /** + * Submit the build trigger form. + * + * @param array $form + * Default form array structure. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $this->submitFormForFrontend(Frontend::NextBuild, $form_state); + $this->submitFormForFrontend(Frontend::VetsWebsite, $form_state); + + $lock_file = $this->fileSystem->realpath('public://' . self::LOCK_FILE_NAME); + if (file_exists($lock_file)) { + $this->messenger() + ->addMessage($this->t('The build is in progress. Please wait for the build to complete.')); + } + else { + $this->fileSystem->saveData( + 'Build me, Seymour!', + 'public://' . self::REQUEST_FILE_NAME, + 1); + $this->messenger()->addMessage($this->t('Build request file set.')); + } + } + + /** + * Submit the form. + * + * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend + * The frontend whose version we are managing. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + */ + protected function submitFormForFrontend( + FrontendInterface $frontend, + FormStateInterface $form_state + ) { + $selectionName = $frontend->getRawValue() . '_selection'; + if ($form_state->getValue($selectionName) === 'default') { + $this->resetFrontendVersion($frontend, $form_state); + } + else { + $this->setFrontendVersion($frontend, $form_state); + } + } + + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + $this->validateFormForFrontend(Frontend::NextBuild, $form_state); + $this->validateFormForFrontend(Frontend::VetsWebsite, $form_state); + } + + /** + * Validate the form. + * + * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend + * The frontend whose version we are managing. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + */ + protected function validateFormForFrontend( + FrontendInterface $frontend, + FormStateInterface $form_state + ) { + $selectionName = $frontend->getRawValue() . '_selection'; + $gitRefName = $frontend->getRawValue() . '_git_ref'; + if ($form_state->getValue($selectionName) !== 'default') { + if (empty($this->getGitRef($frontend, $form_state))) { + $form_state->setErrorByName($gitRefName, + $this->t('Invalid selection.')); + } + } + } + + /** + * Reset the frontend version. + * + * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend + * The frontend whose version we are resetting. + */ + public function resetFrontendVersion(FrontendInterface $frontend) { + $this->frontendVersion->resetVersion($frontend); + } + + /** + * Set the frontend version according to the form. + * + * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend + * The frontend whose version we are setting. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + */ + public function setFrontendVersion( + FrontendInterface $frontend, + FormStateInterface $form_state + ) { + $this->frontendVersion->setVersion($frontend, + $this->getGitRef($frontend, $form_state)); + } + + /** + * Parse a git ref out of the `git_ref` field value. + * + * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend + * The frontend whose version we are setting. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Object containing current form state. + * + * @return string + * A standalone git ref, or an empty string. + */ + public function getGitRef( + FrontendInterface $frontend, + FormStateInterface $form_state + ): string { + // If they selected a specific git ref, use that. + $gitRefName = $frontend->getRawValue() . '_git_ref'; + $formValue = $form_state->getValue($gitRefName); + $result = ''; + if (preg_match("/.+\\s\\(([^\\)]+)\\)/", $formValue, $matches)) { + $result = $matches[1]; + } + return $result; + } + + /** + * {@inheritdoc} + */ + public function getFormId(): string { + return 'va_gov_content_release_next_git_form'; + } + +} diff --git a/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php b/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php index d2d6145d39..1420453091 100644 --- a/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php +++ b/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php @@ -50,6 +50,20 @@ class FrontendVersionSearch implements FrontendVersionSearchInterface { */ protected $logger; + /** + * The branch search service for `vets-website`. + * + * @var \Drupal\va_gov_git\BranchSearch\BranchSearchInterface + */ + protected $nbBranchSearch; + + /** + * The API client for `vets-website`. + * + * @var \Drupal\va_gov_github\Api\Client\ApiClientInterface + */ + protected $nbApiClient; + /** * Constructor. * @@ -63,19 +77,27 @@ class FrontendVersionSearch implements FrontendVersionSearchInterface { * The API client for `vets-website`. * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory * The logger factory service. + * @param \Drupal\va_gov_git\BranchSearch\BranchSearchInterface $nbBranchSearch + * The branch search service for `next-build`. + * @param \Drupal\va_gov_github\Api\Client\ApiClientInterface $nbApiClient + * The API client for `next-build`. */ public function __construct( BranchSearchInterface $cbBranchSearch, ApiClientInterface $cbApiClient, BranchSearchInterface $vwBranchSearch, ApiClientInterface $vwApiClient, - LoggerChannelFactoryInterface $loggerFactory + LoggerChannelFactoryInterface $loggerFactory, + BranchSearchInterface $nbBranchSearch, + ApiClientInterface $nbApiClient, ) { $this->cbBranchSearch = $cbBranchSearch; $this->cbApiClient = $cbApiClient; $this->vwBranchSearch = $vwBranchSearch; $this->vwApiClient = $vwApiClient; $this->logger = $loggerFactory->get('va_gov_content_release'); + $this->nbBranchSearch = $nbBranchSearch; + $this->nbApiClient = $nbApiClient; } /** @@ -95,6 +117,9 @@ protected function getBranchSearch(FrontendInterface $frontend) : BranchSearchIn case $frontend->isVetsWebsite(): return $this->vwBranchSearch; + case $frontend->isNextBuild(): + return $this->nbBranchSearch; + default: throw new \InvalidArgumentException('Invalid frontend: ' . $frontend->getRawValue()); } @@ -117,6 +142,9 @@ protected function getApiClient(FrontendInterface $frontend) : ApiClientInterfac case $frontend->isVetsWebsite(): return $this->vwApiClient; + case $frontend->isNextBuild(): + return $this->nbApiClient; + default: throw new \InvalidArgumentException('Invalid frontend: ' . $frontend->getRawValue()); } diff --git a/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module b/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module deleted file mode 100644 index 35beaf8b98..0000000000 --- a/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module +++ /dev/null @@ -1,6 +0,0 @@ -repositoryFactory->getVetsWebsite(), $this->loggerFactory); } + /** + * {@inheritDoc} + */ + public function getNextBuild(): BranchSearchInterface { + return new BranchSearch($this->repositoryFactory->getNextBuild(), + $this->loggerFactory); + } + } diff --git a/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php b/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php index 8d67cb0b1f..616cc686ce 100644 --- a/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php +++ b/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php @@ -55,4 +55,12 @@ public function getContentBuild(): BranchSearchInterface; */ public function getVetsWebsite(): BranchSearchInterface; + /** + * Get the next-build branch search service. + * + * @return \Drupal\va_gov_git\BranchSearch\BranchSearchInterface + * The next-build branch search object. + */ + public function getNextBuild(): BranchSearchInterface; + } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php index fe70477b26..4a1f8a93d4 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php @@ -65,4 +65,11 @@ public function getVetsWebsite(): RepositoryInterface { return $this->get(RepositorySettingsInterface::VETS_WEBSITE); } + /** + * {@inheritDoc} + */ + public function getNextBuild(): RepositoryInterface { + return $this->get(RepositorySettingsInterface::NEXT_BUILD); + } + } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php index 3e0a3350f2..877b59e3ae 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php @@ -10,10 +10,11 @@ * This service provides a way to create services corresponding to specific Git * repositories. * - * At this time, we're primarily interested in three repositories: + * At this time, we're primarily interested in four repositories: * - The `va.gov-cms` repository. * - The `content-build` repository. * - The `vets-website` repository. + * - The `next-build` repository. */ interface RepositoryFactoryInterface { @@ -55,4 +56,12 @@ public function getContentBuild(): RepositoryInterface; */ public function getVetsWebsite(): RepositoryInterface; + /** + * Get the next-build repository. + * + * @return \Drupal\va_gov_git\Repository\RepositoryInterface + * The next-build repository. + */ + public function getNextBuild(): RepositoryInterface; + } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php index 4d131e6043..c2f09cbdea 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php @@ -59,7 +59,7 @@ public function getPath(string $name): string { } $path = $this->settings->get($pathKey); if (empty($path)) { - throw new RepositoryPathNotSetException('Path not set for repository: ' . $name); + throw new RepositoryPathNotSetException('Path not set for repository: ' . $name . ' (' . $pathKey . ')'); } return $path; } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php index 15615705cc..dfcfbbca84 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php @@ -14,10 +14,12 @@ interface RepositorySettingsInterface { const VA_GOV_CMS = 'va.gov-cms'; const CONTENT_BUILD = 'content-build'; const VETS_WEBSITE = 'vets-website'; + const NEXT_BUILD = 'next-build'; const REPOSITORY_NAMES = [ self::VA_GOV_CMS, self::CONTENT_BUILD, self::VETS_WEBSITE, + self::NEXT_BUILD, ]; // Settings keys for the repositories' filesystem paths. @@ -26,10 +28,13 @@ interface RepositorySettingsInterface { const VA_GOV_CMS_PATH_KEY = 'va_gov_app_root'; const CONTENT_BUILD_PATH_KEY = 'va_gov_web_root'; const VETS_WEBSITE_PATH_KEY = 'va_gov_vets_website_root'; + const NEXT_BUILD_PATH_KEY = 'va_gov_next_build_root'; + const PATH_KEYS = [ self::VA_GOV_CMS => self::VA_GOV_CMS_PATH_KEY, self::CONTENT_BUILD => self::CONTENT_BUILD_PATH_KEY, self::VETS_WEBSITE => self::VETS_WEBSITE_PATH_KEY, + self::NEXT_BUILD => self::NEXT_BUILD_PATH_KEY, ]; /** diff --git a/docroot/modules/custom/va_gov_git/va_gov_git.services.yml b/docroot/modules/custom/va_gov_git/va_gov_git.services.yml index bd4757fffe..3d02a62691 100644 --- a/docroot/modules/custom/va_gov_git/va_gov_git.services.yml +++ b/docroot/modules/custom/va_gov_git/va_gov_git.services.yml @@ -32,4 +32,8 @@ services: class: Drupal\va_gov_git\BranchSearch\BranchSearch factory: ['@va_gov_git.branch_search_factory', 'getVetsWebsite'] arguments: [] + va_gov_git.branch_search.next_build: + class: Drupal\va_gov_git\BranchSearch\BranchSearch + factory: [ '@va_gov_git.branch_search_factory', 'getNextBuild' ] + arguments: [] diff --git a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php index f4f59cc7ed..5244d41b29 100644 --- a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php +++ b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php @@ -18,6 +18,7 @@ class ApiClientFactory implements ApiClientFactoryInterface { const VA_GOV_CMS = 'va.gov-cms'; const CONTENT_BUILD = 'content-build'; const VETS_WEBSITE = 'vets-website'; + const NEXT_BUILD = 'next-build'; /** * The settings service. @@ -64,4 +65,12 @@ public function getVetsWebsite(): ApiClientInterface { return $this->get(static::OWNER, static::VETS_WEBSITE, $this->settings->getApiToken()); } + /** + * {@inheritDoc} + */ + public function getNextBuild(): ApiClientInterface { + return $this->get(static::OWNER, static::NEXT_BUILD, + $this->settings->getApiToken()); + } + } diff --git a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php index 4dbd126985..e97d8c7ae0 100644 --- a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php +++ b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php @@ -67,4 +67,15 @@ public function getContentBuild(): ApiClientInterface; */ public function getVetsWebsite(): ApiClientInterface; + /** + * Retrieve an API client for the Next Build repository. + * + * @return \Drupal\va_gov_github\Api\Client\ApiClientInterface + * The GitHub Api Client instance. + * + * @throws \Drupal\va_gov_github\Exception\InvalidApiTokenException + * If the GitHub API token is provided, but is invalid. + */ + public function getNextBuild(): ApiClientInterface; + } diff --git a/docroot/modules/custom/va_gov_github/va_gov_github.services.yml b/docroot/modules/custom/va_gov_github/va_gov_github.services.yml index 60aa99976c..f881f35ab4 100644 --- a/docroot/modules/custom/va_gov_github/va_gov_github.services.yml +++ b/docroot/modules/custom/va_gov_github/va_gov_github.services.yml @@ -17,3 +17,7 @@ services: class: Drupal\va_gov_github\Api\Client\ApiClientInterface factory: ['@va_gov_github.api_client_factory', 'getVetsWebsite'] arguments: [] + va_gov_github.api_client.next_build: + class: Drupal\va_gov_github\Api\Client\ApiClientInterface + factory: [ '@va_gov_github.api_client_factory', 'getNextBuild' ] + arguments: [] diff --git a/docroot/sites/default/settings.php b/docroot/sites/default/settings.php index b22fa5300e..99271a5dd2 100755 --- a/docroot/sites/default/settings.php +++ b/docroot/sites/default/settings.php @@ -126,6 +126,7 @@ $settings['va_gov_web_root'] = '/var/www/cms/web'; $settings['va_gov_app_root'] = '/var/www/cms'; $settings['va_gov_vets_website_root'] = '/var/www/cms/docroot/vendor/va-gov/vets-website'; +$settings['va_gov_next_build_root'] = '../next'; // Defaults (should only be local that doesn't set these), default to dev for config_split $config['config_split.config_split.dev']['status'] = TRUE; diff --git a/docroot/sites/default/settings/settings.tugboat.php b/docroot/sites/default/settings/settings.tugboat.php index 5bcd14b1e3..c6ab9b0c63 100644 --- a/docroot/sites/default/settings/settings.tugboat.php +++ b/docroot/sites/default/settings/settings.tugboat.php @@ -64,6 +64,7 @@ $settings['va_gov_app_root'] = getenv('TUGBOAT_ROOT'); $settings['va_gov_web_root'] = getenv('TUGBOAT_ROOT') . '/web'; $settings['va_gov_vets_website_root'] = getenv('TUGBOAT_ROOT') . '/docroot/vendor/va-gov/vets-website'; +$settings['va_gov_next_build_root'] = getenv('TUGBOAT_ROOT') . '/next'; $settings['memcache']['servers'] = [ 'memcache:11211' => 'default', diff --git a/scripts/next-build-frontend.sh b/scripts/next-build-frontend.sh new file mode 100644 index 0000000000..c6e32d1d4a --- /dev/null +++ b/scripts/next-build-frontend.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +# Exit if a command fails with a non-zero status code. +set -ex + +# Find repo root -> $reporoot +reporoot="unknown" +if [ ! -z "$IS_DDEV_PROJECT" ]; then + reporoot="/var/www/html" +fi +if [ ! -z "$TUGBOAT_ROOT" ]; then + reporoot="$TUGBOAT_ROOT" +fi +if [ "$reporoot" == "unknown" ]; then + echo "[!] Could not determine the environment type. Aborting!" + exit 1 +fi + +# For convenience. +cd $reporoot + +# Store path to site default files directory. +filesdir="${reporoot}/docroot/sites/default/files" + +# We really only want one build running at a time on any given environment. +if [ -f "${filesdir}/next-buildlock.txt" ]; then + echo "[!] There is already a build in progress. Aborting!" + exit 1 +fi +touch ${filesdir}/next-buildlock.txt + +# Make sure we clean up the build lock file if an error occurs or the build is killed. +trap "rm -f ${filesdir}/next-buildlock.txt && rm -f ${filesdir}/next-buildrequest.txt" INT TERM EXIT + +# Just because the path is really long: +logfile="${filesdir}/next-build.txt" + +# The currently selected version of next-build (may be "__default", a PR#, or a git ref) +next_build_version=$(drush va-gov-content-release:frontend-version:get next_build | tail -1) + +# The currently selected version of vets-website (may be "__default", a PR#, or a git ref) +vets_website_version=$(drush va-gov-content-release:frontend-version:get vets_website | tail -1) + +# Create a fresh log file. +[ -f "${logfile}" ] && rm ${logfile} +touch ${logfile} + +date >> ${logfile} + +echo "next-build version: ${next_build_version}" >> ${logfile} +echo "vets-website version: ${vets_website_version}" >> ${logfile} + +# Tell the frontend (and the user) that we're starting. +#drush va-gov:content-release:advance-state starting +echo "==> Starting a frontend build. This file will be updated as the build progresses." >> ${logfile} + +# Reset the repos to defaults. +#echo "==> Resetting VA repos to default versions" >> ${logfile} +#rm -rf ${reporoot}/docroot/vendor/va-gov +#composer install --no-scripts &>> ${logfile} + +# Get the requested next-build version +if [ "${next_build_version}" != "__default" ]; then + echo "==> Checking out the requested frontend version" >> ${logfile} + pushd ${reporoot}/next + if echo "${next_build_version}" | grep -qE '^[0-9]+$' > /dev/null; then + echo "==> Checking out PR #${next_build_version}" + git fetch origin pull/${next_build_version}/head &>> ${logfile} + else + echo "==> Checking out git ref ${next_build_version}" + git fetch origin ${next_build_version} &>> ${logfile} + fi + git checkout FETCH_HEAD &>> ${logfile} + popd +else + echo "==> Using default next-build version" >> ${logfile} +fi + +# Install 3rd party deps. +echo "==> Installing yarn dependencies" >> ${logfile} +composer va:next:install &>> ${logfile} + +# Get the requested vets-website version +if [ "${vets_website_version}" != "__default" ]; then + echo "==> Checking out the requested vets-website version" >> ${logfile} + pushd ${reporoot}/docroot/vendor/va-gov/vets-website + if echo "$vets_website_version" | grep -qE '^[0-9]+$' > /dev/null; then + echo "==> Checking out PR #${vets_website_version}" + git fetch origin pull/${vets_website_version}/head &>> ${logfile} + else + echo "==> Checking out git ref ${vets_website_version}" + git fetch origin ${vets_website_version} &>> ${logfile} + fi + git checkout FETCH_HEAD &>> ${logfile} + popd +else + echo "==> Using default vets-website version" >> ${logfile} +fi + +# Run the build. +echo "==> Starting build" >> ${logfile} +#drush va-gov:content-release:advance-state inprogress +composer va:next:build &>> ${logfile} + +# Advance the state in the frontend so another build can start. +echo "==> Build complete" >> ${logfile} +#drush va-gov:content-release:advance-state complete +#drush va-gov:content-release:advance-state ready + +# After this point, we are less concerned with errors; the build has completed. +set +e + +# Switch to the docroot to run drush commands. +cd "${reporoot}/docroot" + +# Log the timestamp of the build for reporting purposes. +drush state:set next_build.status.last_build_date "$(date)" + +# Just in case it wasn't clear :) +echo "==> Done" >> ${logfile} diff --git a/scripts/next-build.sh b/scripts/next-build.sh index ff134cf6fe..f322083dbf 100755 --- a/scripts/next-build.sh +++ b/scripts/next-build.sh @@ -1,11 +1,20 @@ #!/usr/bin/env bash #preview +ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}} +if [ -n "${IS_DDEV_PROJECT}" ]; then + APP_ENV="local" +elif [ -n "${TUGBOAT_ROOT}" ]; then + APP_ENV="tugboat" +else + APP_ENV="tugboat" +fi + export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" source ~/.bashrc -cd next +cd "${ROOT}/next" -APP_ENV=tugboat yarn build:preview \ No newline at end of file +APP_ENV=${APP_ENV} yarn build:preview diff --git a/scripts/next-install.sh b/scripts/next-install.sh index e7063b52c2..11f3ba5c85 100755 --- a/scripts/next-install.sh +++ b/scripts/next-install.sh @@ -8,7 +8,10 @@ source ~/.bashrc # Installs the content-build dependencies. if [ ! -d next ]; then - git clone --single-branch --depth 1 https://github.com/department-of-veterans-affairs/next-build.git next + # Clone full so git information is available for content release form. + # I don't think this should be necessary, but branch information was not + # available in the content release form until I pulled down all information. + git clone https://github.com/department-of-veterans-affairs/next-build.git next else echo "Repo next-build already cloned." fi @@ -17,10 +20,13 @@ cd next #repo_root="$(git rev-parse --show-toplevel)" #pushd "${repo_root}" > /dev/null -nvm install 18.17.0 +nvm install 18.17.0 nvm use 18.17.0 -corepack enable -corepack prepare yarn@stable --activate + +# These steps caused the build to fail for me so I disabled temporarily. +#corepack enable +#corepack prepare yarn@stable --activate + echo "Node $(node -v)" echo "NPM $(npm -v)" echo "Yarn $(yarn -v)" diff --git a/scripts/queue_runner/next_queue_runner.sh b/scripts/queue_runner/next_queue_runner.sh new file mode 100644 index 0000000000..b636f6c686 --- /dev/null +++ b/scripts/queue_runner/next_queue_runner.sh @@ -0,0 +1,6 @@ +#!/bin/bash -l + +ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}} +cd "${ROOT}" +[ -f "./docroot/sites/default/files/next-buildrequest.txt" ] && ./scripts/next-build-frontend.sh +sleep 10s diff --git a/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php b/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php index b50b2de832..ba8fc95b2d 100644 --- a/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php +++ b/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php @@ -47,6 +47,7 @@ public function testGetPathKey() { $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['va.gov-cms'], $repositorySettings->getPathKey('va.gov-cms')); $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['content-build'], $repositorySettings->getPathKey('content-build')); $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['vets-website'], $repositorySettings->getPathKey('vets-website')); + $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['next-build'], $repositorySettings->getPathKey('next-build')); } /** @@ -69,6 +70,10 @@ public function testList() { 'name' => RepositorySettingsInterface::VETS_WEBSITE, 'path' => Settings::get('va_gov_vets_website_root'), ], + [ + 'name' => RepositorySettingsInterface::NEXT_BUILD, + 'path' => Settings::get('va_gov_next_build_root'), + ], ], $repositorySettings->list()); } diff --git a/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php b/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php index 20b5d104d3..b0b3813dc8 100644 --- a/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php +++ b/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php @@ -30,6 +30,7 @@ public function getRepositorySettings() { 'va_gov_app_root' => '/srv/cms', 'va_gov_web_root' => '/srv/web', 'va_gov_vets_website_root' => '/srv/vets-website', + 'va_gov_next_build_root' => '/srv/next', ]); return new RepositorySettings($settings); } @@ -68,6 +69,7 @@ public function getPathKeyDataProvider() { ['va.gov-cms', RepositorySettings::VA_GOV_CMS_PATH_KEY], ['content-build', RepositorySettings::CONTENT_BUILD_PATH_KEY], ['vets-website', RepositorySettings::VETS_WEBSITE_PATH_KEY], + ['next-build', RepositorySettings::NEXT_BUILD_PATH_KEY], ]; } @@ -97,6 +99,7 @@ public function getPathDataProvider() { ['va.gov-cms', '/srv/cms'], ['content-build', '/srv/web'], ['vets-website', '/srv/vets-website'], + ['next-build', '/srv/next'], ]; } @@ -146,6 +149,10 @@ public function testList() { 'name' => RepositorySettingsInterface::VETS_WEBSITE, 'path' => '/srv/vets-website', ], + [ + 'name' => RepositorySettingsInterface::NEXT_BUILD, + 'path' => '/srv/next', + ], ], $repositorySettings->list()); } From c008ca2706418907f810f79e588d2f38636e545d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:01:04 -0800 Subject: [PATCH 10/13] Bump va-gov/content-build from 0.0.3440 to 0.0.3441 (#17259) Bumps [va-gov/content-build](https://github.com/department-of-veterans-affairs/content-build) from 0.0.3440 to 0.0.3441. - [Release notes](https://github.com/department-of-veterans-affairs/content-build/releases) - [Commits](https://github.com/department-of-veterans-affairs/content-build/compare/v0.0.3440...v0.0.3441) --- updated-dependencies: - dependency-name: va-gov/content-build dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 74ad0e308e..658c1118bd 100644 --- a/composer.json +++ b/composer.json @@ -221,7 +221,7 @@ "symfony/phpunit-bridge": "^5.1", "symfony/process": "^6.3", "symfony/routing": "^6.3", - "va-gov/content-build": "^0.0.3440", + "va-gov/content-build": "^0.0.3441", "vlucas/phpdotenv": "^5.3", "webflo/drupal-finder": "^1.0.0", "webmozart/path-util": "^2.3", diff --git a/composer.lock b/composer.lock index cc3f1ee783..35509b265c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3972bf23590490ac39137ab6b269c754", + "content-hash": "0aafdc84754d748d9a73e8856c353b95", "packages": [ { "name": "asm89/stack-cors", @@ -25807,7 +25807,7 @@ }, { "name": "va-gov/content-build", - "version": "v0.0.3440", + "version": "v0.0.3441", "source": { "type": "git", "url": "https://github.com/department-of-veterans-affairs/content-build.git", @@ -25843,7 +25843,7 @@ "description": "Front-end for VA.gov. This repository contains the code that generates the www.va.gov website. It contains a Metalsmith static site builder that uses a Drupal CMS for content. This file is here to publish releases to https://packagist.org/packages/va-gov/content-build, so that the CMS CI system can install it and update it using standard composer processes, and so that we can run tests across both systems. See https://github.com/department-of-veterans-affairs/va.gov-cms for the CMS repo, and stand by for more documentation.", "support": { "issues": "https://github.com/department-of-veterans-affairs/content-build/issues", - "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3440" + "source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3441" }, "time": "2024-02-14T14:09:01+00:00" }, From dfc8eec8290e98894c7aa35f2374b1208204ee72 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 16 Feb 2024 09:50:49 -0800 Subject: [PATCH 11/13] Revert "VACMS-16853: next build branches ftw (#17154)" (#17261) This reverts commit 828acc9b9adad7361649f454bc1e6e4a2756b46a. --- .tugboat/config.yml | 7 - READMES/cms-content-release.md | 30 +- ...xt.next_site.next_build_preview_server.yml | 4 +- .../custom/va_gov_content_release/README.md | 13 - .../src/Form/NextGitForm.php | 399 ------------------ .../FrontendVersionSearch.php | 30 +- .../va_gov_content_release.module | 6 + .../va_gov_content_release.routing.yml | 8 - .../va_gov_content_release.services.yml | 2 - .../Factory/BranchSearchFactory.php | 8 - .../Factory/BranchSearchFactoryInterface.php | 8 - .../Repository/Factory/RepositoryFactory.php | 7 - .../Factory/RepositoryFactoryInterface.php | 11 +- .../Settings/RepositorySettings.php | 2 +- .../Settings/RepositorySettingsInterface.php | 5 - .../custom/va_gov_git/va_gov_git.services.yml | 4 - .../Api/Client/Factory/ApiClientFactory.php | 9 - .../Factory/ApiClientFactoryInterface.php | 11 - .../va_gov_github/va_gov_github.services.yml | 4 - docroot/sites/default/settings.php | 1 - .../default/settings/settings.tugboat.php | 1 - scripts/next-build-frontend.sh | 120 ------ scripts/next-build.sh | 13 +- scripts/next-install.sh | 14 +- scripts/queue_runner/next_queue_runner.sh | 6 - .../Settings/RepositorySettingsTest.php | 5 - .../Settings/RepositorySettingsTest.php | 7 - 27 files changed, 18 insertions(+), 717 deletions(-) delete mode 100644 docroot/modules/custom/va_gov_content_release/README.md delete mode 100644 docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php create mode 100644 docroot/modules/custom/va_gov_content_release/va_gov_content_release.module delete mode 100644 scripts/next-build-frontend.sh delete mode 100644 scripts/queue_runner/next_queue_runner.sh diff --git a/.tugboat/config.yml b/.tugboat/config.yml index e1f37c407e..6e628ef6c4 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -226,13 +226,6 @@ services: - mv "${TUGBOAT_ROOT}/scripts/queue_runner/queue_runner.sh" /etc/service/drupal_events/run - chmod +x /etc/service/drupal_events/run - # Separate process for next-build preview. - - mkdir -p /etc/service/next_build - - mv "${TUGBOAT_ROOT}/scripts/queue_runner/next_queue_runner.sh" /etc/service/next_build/run - - chmod +x /etc/service/next_build/run - # Need to make build script executable so the runner can run it. - - chmod +x "${TUGBOAT_ROOT}/scripts/next-build-frontend.sh" - clone: # This j2 command is shared in both the build & clone stages. If modifying, change the other too. - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" diff --git a/READMES/cms-content-release.md b/READMES/cms-content-release.md index 0c8c93e598..8d9119600e 100644 --- a/READMES/cms-content-release.md +++ b/READMES/cms-content-release.md @@ -116,6 +116,7 @@ sequenceDiagram Complete->>+Ready: Content release workflow has completed ``` + # Environment specific details ## BRD Production @@ -143,35 +144,6 @@ The Tugboat and local development versions of the release content page do not tr For more information on creating or releasing content from a preview environment, see [Environments](./environments.md). -### Next Build Releases - -The upcoming static frontend "next-build" can be rebuilt using different versions of next-build and vets-website. It -is a simpler process than the current content-build workflow. - -1. Go to "/admin/content/deploy/next". -2. If the form elements are disabled, then a lock file exists preventing another build from being triggered. You - can skip to step #6. -2. Choose a version for next-build or leave at default. -3. Choose a version for vets-website or leave at default. When content-build is releasing, these form fields might - be disabled. We can't change the vets-website version while another frontend build is running. -4. Click "Release Content" to set the versions of next-build and vets-website as well as write a "buildrequest" file. -5. A `scripts/queue_runner/next_queue_runner.sh` script continuously runs in the background looking for the - "buildrequest" file and then start a build if found. Locally, the script has to be triggered manually. See the - [caveats](#caveats) section for more information. -6. Back on "/admin/content/deploy/next" you can view the build log via a link in the "Status" section of the - "Next Build Information" block. -7. Once the build completes no new build will be triggered until you click to release content again. -8. View the frontend at the provided "View Preview" link in the "Next Build Information" block. - -#### Caveats - -There are some caveats to the process outlined above. - -- **Manually running the background script** - On `ddev` the `queue_runner` scripts aren't running continuously in - background jobs. So you must `ddev ssh && ./scripts/queue_runner/` to kick off the content build or next build - release locally. In the future, it might be a good idea to use `system.d` or `supervisor` or something else to - keep the background jobs going locally just like on Tugoboat. - ## Troubleshooting Sometimes the state gets stuck and needs to be reset. It can be done with a drush command diff --git a/config/sync/next.next_site.next_build_preview_server.yml b/config/sync/next.next_site.next_build_preview_server.yml index caf6c88f5d..3e3a99c8bb 100644 --- a/config/sync/next.next_site.next_build_preview_server.yml +++ b/config/sync/next.next_site.next_build_preview_server.yml @@ -4,8 +4,8 @@ status: true dependencies: { } id: next_build_preview_server label: 'Next Build Preview Server' -base_url: 'http://localhost:3999' -preview_url: 'http://localhost:3999/api/preview' +base_url: 'http://localhost:3000' +preview_url: 'http://localhost:3000/api/preview' preview_secret: secret revalidate_url: '' revalidate_secret: '' diff --git a/docroot/modules/custom/va_gov_content_release/README.md b/docroot/modules/custom/va_gov_content_release/README.md deleted file mode 100644 index 226790fb81..0000000000 --- a/docroot/modules/custom/va_gov_content_release/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# VA.gov Content Release - -va.gov is built using two separate frontend systems with a third being built: - -- content-build - This is the frontend for generating static content files. You can read more about the project here: - https://github.com/department-of-veterans-affairs/content-build -- vets-website - This is the frontend for integrating React widgets. You can read more about the project here: - https://github.com/department-of-veterans-affairs/vets-website -- next-build - This is the new frontend for generating static content files. You can read more about the project here: - https://github.com/department-of-veterans-affairs/next-build - -More detailed documentation about how these frontends are build and released can be found in the main READMEs -directory on the [CMS Content Release](../../../../READMES/cms-content-release.md) page. diff --git a/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php b/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php deleted file mode 100644 index e20b3870b9..0000000000 --- a/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php +++ /dev/null @@ -1,399 +0,0 @@ -frontendVersion = $frontendVersion; - $this->fileSystem = $fileSystem; - $this->config = $config; - $this->state = $state; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('va_gov_content_release.frontend_version'), - $container->get('file_system'), - $container->get('config.factory'), - $container->get('state') - ); - } - - /** - * Build the form. - * - * @param array $form - * Default form array structure. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - */ - public function buildForm(array $form, FormStateInterface $form_state) { - $form['build_request']['description'] = [ - '#prefix' => '

', - '#markup' => $this->t('Release content to update the front end of this environment with the latest published content changes.'), - '#suffix' => '

', - ]; - - $form['build_request']['next_build_selection'] = [ - '#title' => $this->t('Which version of next-build would you like to use?'), - '#type' => 'radios', - '#options' => [ - 'default' => $this->t('Use default - the next-build version from the time this demo environment was created.'), - 'choose' => $this->t('Select a different next-build branch/pull request - for example, to see your content in a newer frontend design.'), - ], - '#default_value' => 'default', - ]; - - $form['build_request']['next_build_git_ref'] = [ - '#type' => 'textfield', - '#title' => $this->t('Select branch/pull request'), - '#description' => $this->t('Start typing to select a branch for the next-build version you want to use.'), - '#autocomplete_route_name' => 'va_gov_content_release.frontend_version_autocomplete', - '#autocomplete_route_parameters' => [ - 'frontend' => 'next_build', - 'count' => 10, - ], - '#size' => 72, - '#maxlength' => 1024, - '#hidden' => TRUE, - '#states' => [ - 'visible' => [':input[name="next_build_selection"]' => ['value' => 'choose']], - ], - ]; - - $form['build_request']['vets_website_selection'] = [ - '#title' => $this->t('Which version of vets-website would you like to use?'), - '#type' => 'radios', - '#options' => [ - 'default' => $this->t('Use default - the vets-website version from the time this demo environment was created.'), - 'choose' => $this->t('Select a different vets-website branch/pull request - for example, to see your content in a newer frontend design.'), - ], - '#default_value' => 'default', - ]; - - $form['build_request']['vets_website_git_ref'] = [ - '#type' => 'textfield', - '#title' => $this->t('Select branch/pull request'), - '#description' => $this->t('Start typing to select a branch for the vets-website version you want to use.'), - '#autocomplete_route_name' => 'va_gov_content_release.frontend_version_autocomplete', - '#autocomplete_route_parameters' => [ - 'frontend' => 'vets_website', - 'count' => 10, - ], - '#size' => 72, - '#maxlength' => 1024, - '#hidden' => TRUE, - '#states' => [ - 'visible' => [':input[name="vets_website_selection"]' => ['value' => 'choose']], - ], - ]; - - $form['build_request']['actions']['#type'] = 'actions'; - $form['build_request']['actions']['submit'] = [ - '#type' => 'submit', - '#value' => $this->t('Release Content'), - '#button_type' => 'primary', - ]; - - // Lock the vets-website form fields if a content-build is in progress. - $build_status = $this->state->get('va_gov_build_trigger.release_state'); - if ($build_status !== ReleaseStateManager::STATE_READY) { - $form['build_request']['vets_website_selection']['#disabled'] = TRUE; - $form['build_request']['vets_website_git_ref']['#disabled'] = TRUE; - } - - // Disable form changes and submission if a build is in progress. - if (file_exists($this->fileSystem->realpath('public://' . self::LOCK_FILE_NAME))) { - $form['build_request']['next_build_selection']['#disabled'] = TRUE; - $form['build_request']['next_build_git_ref']['#disabled'] = TRUE; - $form['build_request']['vets_website_selection']['#disabled'] = TRUE; - $form['build_request']['vets_website_git_ref']['#disabled'] = TRUE; - $form['build_request']['actions']['submit']['#disabled'] = TRUE; - - $target_url = Url::fromUserInput("/sites/default/files/next-build.txt"); - $build_log_text = Link::fromTextAndUrl('Build is in progress. View log file', $target_url); - } - else { - $build_log_text = 'Build is not in progress.'; - } - - // Set variables needed for build status information. - $lock_file_text = $this->getFileLink(self::LOCK_FILE_NAME); - $request_file_text = $this->getFileLink(self::REQUEST_FILE_NAME); - $next_build_version = $this->frontendVersion->getVersion(Frontend::NextBuild); - $vets_website_version = $this->frontendVersion->getVersion(Frontend::VetsWebsite); - $view_preview = $this->getPreviewLink(); - $last_build_time = $this->state->get('next_build.status.last_build_date', 'N/A'); - $form['content_release_status_block'] = [ - '#theme' => 'status_report_grouped', - '#grouped_requirements' => [ - [ - 'title' => $this->t('Next Build Information'), - 'type' => 'content-release-status', - 'items' => [ - 'status' => [ - 'title' => $this->t('Status'), - 'value' => $build_log_text, - ], - 'lock_file' => [ - 'title' => $this->t('Lock File'), - 'value' => $lock_file_text, - ], - 'request_file' => [ - 'title' => $this->t('Request File'), - 'value' => $request_file_text, - ], - 'next_build_version' => [ - 'title' => $this->t('Next-build Version'), - 'value' => $next_build_version, - ], - 'vets_website_version' => [ - 'title' => $this->t('Vets-website Version'), - 'value' => $vets_website_version, - ], - 'view_preview' => [ - 'title' => $this->t('View Preview'), - 'value' => $view_preview, - ], - 'last_build_time' => [ - 'title' => $this->t('Last Build Time'), - 'value' => $last_build_time, - ], - ], - ], - ], - ]; - - return $form; - } - - /** - * Get the text for a file. - * - * @param string $file_name - * The name of the file. - * - * @return \Drupal\Core\Link|string - * The file link. - */ - private function getFileLink(string $file_name): Link|string { - $file_path = $this->fileSystem->realpath("public://$file_name"); - if (file_exists($file_path)) { - $target_url = Url::fromUserInput("/sites/default/files/$file_name"); - return Link::fromTextAndUrl($file_name, $target_url); - } - else { - return 'does not exist'; - } - } - - /** - * Get the preview link. - * - * @return \Drupal\Core\Link - * The preview link. - */ - private function getPreviewLink(): Link { - $frontend_base_url = $this->config - ->get('next.next_site.next_build_preview_server') - ->get('base_url'); - $target_url = Url::fromUri($frontend_base_url, ['attributes' => ['target' => '_blank']]); - return Link::fromTextAndUrl($this->t('View front end'), $target_url); - } - - /** - * Submit the build trigger form. - * - * @param array $form - * Default form array structure. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $this->submitFormForFrontend(Frontend::NextBuild, $form_state); - $this->submitFormForFrontend(Frontend::VetsWebsite, $form_state); - - $lock_file = $this->fileSystem->realpath('public://' . self::LOCK_FILE_NAME); - if (file_exists($lock_file)) { - $this->messenger() - ->addMessage($this->t('The build is in progress. Please wait for the build to complete.')); - } - else { - $this->fileSystem->saveData( - 'Build me, Seymour!', - 'public://' . self::REQUEST_FILE_NAME, - 1); - $this->messenger()->addMessage($this->t('Build request file set.')); - } - } - - /** - * Submit the form. - * - * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend - * The frontend whose version we are managing. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - */ - protected function submitFormForFrontend( - FrontendInterface $frontend, - FormStateInterface $form_state - ) { - $selectionName = $frontend->getRawValue() . '_selection'; - if ($form_state->getValue($selectionName) === 'default') { - $this->resetFrontendVersion($frontend, $form_state); - } - else { - $this->setFrontendVersion($frontend, $form_state); - } - } - - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - $this->validateFormForFrontend(Frontend::NextBuild, $form_state); - $this->validateFormForFrontend(Frontend::VetsWebsite, $form_state); - } - - /** - * Validate the form. - * - * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend - * The frontend whose version we are managing. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - */ - protected function validateFormForFrontend( - FrontendInterface $frontend, - FormStateInterface $form_state - ) { - $selectionName = $frontend->getRawValue() . '_selection'; - $gitRefName = $frontend->getRawValue() . '_git_ref'; - if ($form_state->getValue($selectionName) !== 'default') { - if (empty($this->getGitRef($frontend, $form_state))) { - $form_state->setErrorByName($gitRefName, - $this->t('Invalid selection.')); - } - } - } - - /** - * Reset the frontend version. - * - * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend - * The frontend whose version we are resetting. - */ - public function resetFrontendVersion(FrontendInterface $frontend) { - $this->frontendVersion->resetVersion($frontend); - } - - /** - * Set the frontend version according to the form. - * - * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend - * The frontend whose version we are setting. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - */ - public function setFrontendVersion( - FrontendInterface $frontend, - FormStateInterface $form_state - ) { - $this->frontendVersion->setVersion($frontend, - $this->getGitRef($frontend, $form_state)); - } - - /** - * Parse a git ref out of the `git_ref` field value. - * - * @param \Drupal\va_gov_content_release\Frontend\FrontendInterface $frontend - * The frontend whose version we are setting. - * @param \Drupal\Core\Form\FormStateInterface $form_state - * Object containing current form state. - * - * @return string - * A standalone git ref, or an empty string. - */ - public function getGitRef( - FrontendInterface $frontend, - FormStateInterface $form_state - ): string { - // If they selected a specific git ref, use that. - $gitRefName = $frontend->getRawValue() . '_git_ref'; - $formValue = $form_state->getValue($gitRefName); - $result = ''; - if (preg_match("/.+\\s\\(([^\\)]+)\\)/", $formValue, $matches)) { - $result = $matches[1]; - } - return $result; - } - - /** - * {@inheritdoc} - */ - public function getFormId(): string { - return 'va_gov_content_release_next_git_form'; - } - -} diff --git a/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php b/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php index 1420453091..d2d6145d39 100644 --- a/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php +++ b/docroot/modules/custom/va_gov_content_release/src/FrontendVersionSearch/FrontendVersionSearch.php @@ -50,20 +50,6 @@ class FrontendVersionSearch implements FrontendVersionSearchInterface { */ protected $logger; - /** - * The branch search service for `vets-website`. - * - * @var \Drupal\va_gov_git\BranchSearch\BranchSearchInterface - */ - protected $nbBranchSearch; - - /** - * The API client for `vets-website`. - * - * @var \Drupal\va_gov_github\Api\Client\ApiClientInterface - */ - protected $nbApiClient; - /** * Constructor. * @@ -77,27 +63,19 @@ class FrontendVersionSearch implements FrontendVersionSearchInterface { * The API client for `vets-website`. * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory * The logger factory service. - * @param \Drupal\va_gov_git\BranchSearch\BranchSearchInterface $nbBranchSearch - * The branch search service for `next-build`. - * @param \Drupal\va_gov_github\Api\Client\ApiClientInterface $nbApiClient - * The API client for `next-build`. */ public function __construct( BranchSearchInterface $cbBranchSearch, ApiClientInterface $cbApiClient, BranchSearchInterface $vwBranchSearch, ApiClientInterface $vwApiClient, - LoggerChannelFactoryInterface $loggerFactory, - BranchSearchInterface $nbBranchSearch, - ApiClientInterface $nbApiClient, + LoggerChannelFactoryInterface $loggerFactory ) { $this->cbBranchSearch = $cbBranchSearch; $this->cbApiClient = $cbApiClient; $this->vwBranchSearch = $vwBranchSearch; $this->vwApiClient = $vwApiClient; $this->logger = $loggerFactory->get('va_gov_content_release'); - $this->nbBranchSearch = $nbBranchSearch; - $this->nbApiClient = $nbApiClient; } /** @@ -117,9 +95,6 @@ protected function getBranchSearch(FrontendInterface $frontend) : BranchSearchIn case $frontend->isVetsWebsite(): return $this->vwBranchSearch; - case $frontend->isNextBuild(): - return $this->nbBranchSearch; - default: throw new \InvalidArgumentException('Invalid frontend: ' . $frontend->getRawValue()); } @@ -142,9 +117,6 @@ protected function getApiClient(FrontendInterface $frontend) : ApiClientInterfac case $frontend->isVetsWebsite(): return $this->vwApiClient; - case $frontend->isNextBuild(): - return $this->nbApiClient; - default: throw new \InvalidArgumentException('Invalid frontend: ' . $frontend->getRawValue()); } diff --git a/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module b/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module new file mode 100644 index 0000000000..35beaf8b98 --- /dev/null +++ b/docroot/modules/custom/va_gov_content_release/va_gov_content_release.module @@ -0,0 +1,6 @@ +repositoryFactory->getVetsWebsite(), $this->loggerFactory); } - /** - * {@inheritDoc} - */ - public function getNextBuild(): BranchSearchInterface { - return new BranchSearch($this->repositoryFactory->getNextBuild(), - $this->loggerFactory); - } - } diff --git a/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php b/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php index 616cc686ce..8d67cb0b1f 100644 --- a/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php +++ b/docroot/modules/custom/va_gov_git/src/BranchSearch/Factory/BranchSearchFactoryInterface.php @@ -55,12 +55,4 @@ public function getContentBuild(): BranchSearchInterface; */ public function getVetsWebsite(): BranchSearchInterface; - /** - * Get the next-build branch search service. - * - * @return \Drupal\va_gov_git\BranchSearch\BranchSearchInterface - * The next-build branch search object. - */ - public function getNextBuild(): BranchSearchInterface; - } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php index 4a1f8a93d4..fe70477b26 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactory.php @@ -65,11 +65,4 @@ public function getVetsWebsite(): RepositoryInterface { return $this->get(RepositorySettingsInterface::VETS_WEBSITE); } - /** - * {@inheritDoc} - */ - public function getNextBuild(): RepositoryInterface { - return $this->get(RepositorySettingsInterface::NEXT_BUILD); - } - } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php index 877b59e3ae..3e0a3350f2 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Factory/RepositoryFactoryInterface.php @@ -10,11 +10,10 @@ * This service provides a way to create services corresponding to specific Git * repositories. * - * At this time, we're primarily interested in four repositories: + * At this time, we're primarily interested in three repositories: * - The `va.gov-cms` repository. * - The `content-build` repository. * - The `vets-website` repository. - * - The `next-build` repository. */ interface RepositoryFactoryInterface { @@ -56,12 +55,4 @@ public function getContentBuild(): RepositoryInterface; */ public function getVetsWebsite(): RepositoryInterface; - /** - * Get the next-build repository. - * - * @return \Drupal\va_gov_git\Repository\RepositoryInterface - * The next-build repository. - */ - public function getNextBuild(): RepositoryInterface; - } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php index c2f09cbdea..4d131e6043 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettings.php @@ -59,7 +59,7 @@ public function getPath(string $name): string { } $path = $this->settings->get($pathKey); if (empty($path)) { - throw new RepositoryPathNotSetException('Path not set for repository: ' . $name . ' (' . $pathKey . ')'); + throw new RepositoryPathNotSetException('Path not set for repository: ' . $name); } return $path; } diff --git a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php index dfcfbbca84..15615705cc 100644 --- a/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php +++ b/docroot/modules/custom/va_gov_git/src/Repository/Settings/RepositorySettingsInterface.php @@ -14,12 +14,10 @@ interface RepositorySettingsInterface { const VA_GOV_CMS = 'va.gov-cms'; const CONTENT_BUILD = 'content-build'; const VETS_WEBSITE = 'vets-website'; - const NEXT_BUILD = 'next-build'; const REPOSITORY_NAMES = [ self::VA_GOV_CMS, self::CONTENT_BUILD, self::VETS_WEBSITE, - self::NEXT_BUILD, ]; // Settings keys for the repositories' filesystem paths. @@ -28,13 +26,10 @@ interface RepositorySettingsInterface { const VA_GOV_CMS_PATH_KEY = 'va_gov_app_root'; const CONTENT_BUILD_PATH_KEY = 'va_gov_web_root'; const VETS_WEBSITE_PATH_KEY = 'va_gov_vets_website_root'; - const NEXT_BUILD_PATH_KEY = 'va_gov_next_build_root'; - const PATH_KEYS = [ self::VA_GOV_CMS => self::VA_GOV_CMS_PATH_KEY, self::CONTENT_BUILD => self::CONTENT_BUILD_PATH_KEY, self::VETS_WEBSITE => self::VETS_WEBSITE_PATH_KEY, - self::NEXT_BUILD => self::NEXT_BUILD_PATH_KEY, ]; /** diff --git a/docroot/modules/custom/va_gov_git/va_gov_git.services.yml b/docroot/modules/custom/va_gov_git/va_gov_git.services.yml index 3d02a62691..bd4757fffe 100644 --- a/docroot/modules/custom/va_gov_git/va_gov_git.services.yml +++ b/docroot/modules/custom/va_gov_git/va_gov_git.services.yml @@ -32,8 +32,4 @@ services: class: Drupal\va_gov_git\BranchSearch\BranchSearch factory: ['@va_gov_git.branch_search_factory', 'getVetsWebsite'] arguments: [] - va_gov_git.branch_search.next_build: - class: Drupal\va_gov_git\BranchSearch\BranchSearch - factory: [ '@va_gov_git.branch_search_factory', 'getNextBuild' ] - arguments: [] diff --git a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php index 5244d41b29..f4f59cc7ed 100644 --- a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php +++ b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactory.php @@ -18,7 +18,6 @@ class ApiClientFactory implements ApiClientFactoryInterface { const VA_GOV_CMS = 'va.gov-cms'; const CONTENT_BUILD = 'content-build'; const VETS_WEBSITE = 'vets-website'; - const NEXT_BUILD = 'next-build'; /** * The settings service. @@ -65,12 +64,4 @@ public function getVetsWebsite(): ApiClientInterface { return $this->get(static::OWNER, static::VETS_WEBSITE, $this->settings->getApiToken()); } - /** - * {@inheritDoc} - */ - public function getNextBuild(): ApiClientInterface { - return $this->get(static::OWNER, static::NEXT_BUILD, - $this->settings->getApiToken()); - } - } diff --git a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php index e97d8c7ae0..4dbd126985 100644 --- a/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php +++ b/docroot/modules/custom/va_gov_github/src/Api/Client/Factory/ApiClientFactoryInterface.php @@ -67,15 +67,4 @@ public function getContentBuild(): ApiClientInterface; */ public function getVetsWebsite(): ApiClientInterface; - /** - * Retrieve an API client for the Next Build repository. - * - * @return \Drupal\va_gov_github\Api\Client\ApiClientInterface - * The GitHub Api Client instance. - * - * @throws \Drupal\va_gov_github\Exception\InvalidApiTokenException - * If the GitHub API token is provided, but is invalid. - */ - public function getNextBuild(): ApiClientInterface; - } diff --git a/docroot/modules/custom/va_gov_github/va_gov_github.services.yml b/docroot/modules/custom/va_gov_github/va_gov_github.services.yml index f881f35ab4..60aa99976c 100644 --- a/docroot/modules/custom/va_gov_github/va_gov_github.services.yml +++ b/docroot/modules/custom/va_gov_github/va_gov_github.services.yml @@ -17,7 +17,3 @@ services: class: Drupal\va_gov_github\Api\Client\ApiClientInterface factory: ['@va_gov_github.api_client_factory', 'getVetsWebsite'] arguments: [] - va_gov_github.api_client.next_build: - class: Drupal\va_gov_github\Api\Client\ApiClientInterface - factory: [ '@va_gov_github.api_client_factory', 'getNextBuild' ] - arguments: [] diff --git a/docroot/sites/default/settings.php b/docroot/sites/default/settings.php index 99271a5dd2..b22fa5300e 100755 --- a/docroot/sites/default/settings.php +++ b/docroot/sites/default/settings.php @@ -126,7 +126,6 @@ $settings['va_gov_web_root'] = '/var/www/cms/web'; $settings['va_gov_app_root'] = '/var/www/cms'; $settings['va_gov_vets_website_root'] = '/var/www/cms/docroot/vendor/va-gov/vets-website'; -$settings['va_gov_next_build_root'] = '../next'; // Defaults (should only be local that doesn't set these), default to dev for config_split $config['config_split.config_split.dev']['status'] = TRUE; diff --git a/docroot/sites/default/settings/settings.tugboat.php b/docroot/sites/default/settings/settings.tugboat.php index c6ab9b0c63..5bcd14b1e3 100644 --- a/docroot/sites/default/settings/settings.tugboat.php +++ b/docroot/sites/default/settings/settings.tugboat.php @@ -64,7 +64,6 @@ $settings['va_gov_app_root'] = getenv('TUGBOAT_ROOT'); $settings['va_gov_web_root'] = getenv('TUGBOAT_ROOT') . '/web'; $settings['va_gov_vets_website_root'] = getenv('TUGBOAT_ROOT') . '/docroot/vendor/va-gov/vets-website'; -$settings['va_gov_next_build_root'] = getenv('TUGBOAT_ROOT') . '/next'; $settings['memcache']['servers'] = [ 'memcache:11211' => 'default', diff --git a/scripts/next-build-frontend.sh b/scripts/next-build-frontend.sh deleted file mode 100644 index c6e32d1d4a..0000000000 --- a/scripts/next-build-frontend.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env bash - -# Exit if a command fails with a non-zero status code. -set -ex - -# Find repo root -> $reporoot -reporoot="unknown" -if [ ! -z "$IS_DDEV_PROJECT" ]; then - reporoot="/var/www/html" -fi -if [ ! -z "$TUGBOAT_ROOT" ]; then - reporoot="$TUGBOAT_ROOT" -fi -if [ "$reporoot" == "unknown" ]; then - echo "[!] Could not determine the environment type. Aborting!" - exit 1 -fi - -# For convenience. -cd $reporoot - -# Store path to site default files directory. -filesdir="${reporoot}/docroot/sites/default/files" - -# We really only want one build running at a time on any given environment. -if [ -f "${filesdir}/next-buildlock.txt" ]; then - echo "[!] There is already a build in progress. Aborting!" - exit 1 -fi -touch ${filesdir}/next-buildlock.txt - -# Make sure we clean up the build lock file if an error occurs or the build is killed. -trap "rm -f ${filesdir}/next-buildlock.txt && rm -f ${filesdir}/next-buildrequest.txt" INT TERM EXIT - -# Just because the path is really long: -logfile="${filesdir}/next-build.txt" - -# The currently selected version of next-build (may be "__default", a PR#, or a git ref) -next_build_version=$(drush va-gov-content-release:frontend-version:get next_build | tail -1) - -# The currently selected version of vets-website (may be "__default", a PR#, or a git ref) -vets_website_version=$(drush va-gov-content-release:frontend-version:get vets_website | tail -1) - -# Create a fresh log file. -[ -f "${logfile}" ] && rm ${logfile} -touch ${logfile} - -date >> ${logfile} - -echo "next-build version: ${next_build_version}" >> ${logfile} -echo "vets-website version: ${vets_website_version}" >> ${logfile} - -# Tell the frontend (and the user) that we're starting. -#drush va-gov:content-release:advance-state starting -echo "==> Starting a frontend build. This file will be updated as the build progresses." >> ${logfile} - -# Reset the repos to defaults. -#echo "==> Resetting VA repos to default versions" >> ${logfile} -#rm -rf ${reporoot}/docroot/vendor/va-gov -#composer install --no-scripts &>> ${logfile} - -# Get the requested next-build version -if [ "${next_build_version}" != "__default" ]; then - echo "==> Checking out the requested frontend version" >> ${logfile} - pushd ${reporoot}/next - if echo "${next_build_version}" | grep -qE '^[0-9]+$' > /dev/null; then - echo "==> Checking out PR #${next_build_version}" - git fetch origin pull/${next_build_version}/head &>> ${logfile} - else - echo "==> Checking out git ref ${next_build_version}" - git fetch origin ${next_build_version} &>> ${logfile} - fi - git checkout FETCH_HEAD &>> ${logfile} - popd -else - echo "==> Using default next-build version" >> ${logfile} -fi - -# Install 3rd party deps. -echo "==> Installing yarn dependencies" >> ${logfile} -composer va:next:install &>> ${logfile} - -# Get the requested vets-website version -if [ "${vets_website_version}" != "__default" ]; then - echo "==> Checking out the requested vets-website version" >> ${logfile} - pushd ${reporoot}/docroot/vendor/va-gov/vets-website - if echo "$vets_website_version" | grep -qE '^[0-9]+$' > /dev/null; then - echo "==> Checking out PR #${vets_website_version}" - git fetch origin pull/${vets_website_version}/head &>> ${logfile} - else - echo "==> Checking out git ref ${vets_website_version}" - git fetch origin ${vets_website_version} &>> ${logfile} - fi - git checkout FETCH_HEAD &>> ${logfile} - popd -else - echo "==> Using default vets-website version" >> ${logfile} -fi - -# Run the build. -echo "==> Starting build" >> ${logfile} -#drush va-gov:content-release:advance-state inprogress -composer va:next:build &>> ${logfile} - -# Advance the state in the frontend so another build can start. -echo "==> Build complete" >> ${logfile} -#drush va-gov:content-release:advance-state complete -#drush va-gov:content-release:advance-state ready - -# After this point, we are less concerned with errors; the build has completed. -set +e - -# Switch to the docroot to run drush commands. -cd "${reporoot}/docroot" - -# Log the timestamp of the build for reporting purposes. -drush state:set next_build.status.last_build_date "$(date)" - -# Just in case it wasn't clear :) -echo "==> Done" >> ${logfile} diff --git a/scripts/next-build.sh b/scripts/next-build.sh index f322083dbf..ff134cf6fe 100755 --- a/scripts/next-build.sh +++ b/scripts/next-build.sh @@ -1,20 +1,11 @@ #!/usr/bin/env bash #preview -ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}} -if [ -n "${IS_DDEV_PROJECT}" ]; then - APP_ENV="local" -elif [ -n "${TUGBOAT_ROOT}" ]; then - APP_ENV="tugboat" -else - APP_ENV="tugboat" -fi - export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" source ~/.bashrc -cd "${ROOT}/next" +cd next -APP_ENV=${APP_ENV} yarn build:preview +APP_ENV=tugboat yarn build:preview \ No newline at end of file diff --git a/scripts/next-install.sh b/scripts/next-install.sh index 11f3ba5c85..e7063b52c2 100755 --- a/scripts/next-install.sh +++ b/scripts/next-install.sh @@ -8,10 +8,7 @@ source ~/.bashrc # Installs the content-build dependencies. if [ ! -d next ]; then - # Clone full so git information is available for content release form. - # I don't think this should be necessary, but branch information was not - # available in the content release form until I pulled down all information. - git clone https://github.com/department-of-veterans-affairs/next-build.git next + git clone --single-branch --depth 1 https://github.com/department-of-veterans-affairs/next-build.git next else echo "Repo next-build already cloned." fi @@ -20,13 +17,10 @@ cd next #repo_root="$(git rev-parse --show-toplevel)" #pushd "${repo_root}" > /dev/null -nvm install 18.17.0 +nvm install 18.17.0 nvm use 18.17.0 - -# These steps caused the build to fail for me so I disabled temporarily. -#corepack enable -#corepack prepare yarn@stable --activate - +corepack enable +corepack prepare yarn@stable --activate echo "Node $(node -v)" echo "NPM $(npm -v)" echo "Yarn $(yarn -v)" diff --git a/scripts/queue_runner/next_queue_runner.sh b/scripts/queue_runner/next_queue_runner.sh deleted file mode 100644 index b636f6c686..0000000000 --- a/scripts/queue_runner/next_queue_runner.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -l - -ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}} -cd "${ROOT}" -[ -f "./docroot/sites/default/files/next-buildrequest.txt" ] && ./scripts/next-build-frontend.sh -sleep 10s diff --git a/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php b/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php index ba8fc95b2d..b50b2de832 100644 --- a/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php +++ b/tests/phpunit/va_gov_git/functional/Repository/Settings/RepositorySettingsTest.php @@ -47,7 +47,6 @@ public function testGetPathKey() { $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['va.gov-cms'], $repositorySettings->getPathKey('va.gov-cms')); $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['content-build'], $repositorySettings->getPathKey('content-build')); $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['vets-website'], $repositorySettings->getPathKey('vets-website')); - $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['next-build'], $repositorySettings->getPathKey('next-build')); } /** @@ -70,10 +69,6 @@ public function testList() { 'name' => RepositorySettingsInterface::VETS_WEBSITE, 'path' => Settings::get('va_gov_vets_website_root'), ], - [ - 'name' => RepositorySettingsInterface::NEXT_BUILD, - 'path' => Settings::get('va_gov_next_build_root'), - ], ], $repositorySettings->list()); } diff --git a/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php b/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php index b0b3813dc8..20b5d104d3 100644 --- a/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php +++ b/tests/phpunit/va_gov_git/unit/Repository/Settings/RepositorySettingsTest.php @@ -30,7 +30,6 @@ public function getRepositorySettings() { 'va_gov_app_root' => '/srv/cms', 'va_gov_web_root' => '/srv/web', 'va_gov_vets_website_root' => '/srv/vets-website', - 'va_gov_next_build_root' => '/srv/next', ]); return new RepositorySettings($settings); } @@ -69,7 +68,6 @@ public function getPathKeyDataProvider() { ['va.gov-cms', RepositorySettings::VA_GOV_CMS_PATH_KEY], ['content-build', RepositorySettings::CONTENT_BUILD_PATH_KEY], ['vets-website', RepositorySettings::VETS_WEBSITE_PATH_KEY], - ['next-build', RepositorySettings::NEXT_BUILD_PATH_KEY], ]; } @@ -99,7 +97,6 @@ public function getPathDataProvider() { ['va.gov-cms', '/srv/cms'], ['content-build', '/srv/web'], ['vets-website', '/srv/vets-website'], - ['next-build', '/srv/next'], ]; } @@ -149,10 +146,6 @@ public function testList() { 'name' => RepositorySettingsInterface::VETS_WEBSITE, 'path' => '/srv/vets-website', ], - [ - 'name' => RepositorySettingsInterface::NEXT_BUILD, - 'path' => '/srv/next', - ], ], $repositorySettings->list()); } From 1d0f61eef7ba3707407a115392082e1c2a517b56 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:11:34 -0800 Subject: [PATCH 12/13] Bump drupal/office_hours from 1.12.0 to 1.15.0 (#17258) Bumps drupal/office_hours from 1.12.0 to 1.15.0. --- updated-dependencies: - dependency-name: drupal/office_hours dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Edmund Dunn <109987005+edmund-dunn@users.noreply.github.com> --- composer.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 35509b265c..791abacddd 100644 --- a/composer.lock +++ b/composer.lock @@ -10282,17 +10282,17 @@ }, { "name": "drupal/office_hours", - "version": "1.12.0", + "version": "1.15.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/office_hours.git", - "reference": "8.x-1.12" + "reference": "8.x-1.15" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/office_hours-8.x-1.12.zip", - "reference": "8.x-1.12", - "shasum": "e6b88520935adffc0361ab3a80dd44b76b77b9a9" + "url": "https://ftp.drupal.org/files/projects/office_hours-8.x-1.15.zip", + "reference": "8.x-1.15", + "shasum": "3cc5c51420d60fcd45648b823f6b8e0ff9079af9" }, "require": { "drupal/core": "^8 || ^9 || ^10" @@ -10300,8 +10300,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.12", - "datestamp": "1696706142", + "version": "8.x-1.15", + "datestamp": "1708001336", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" From ee7ba407e0c51f84b4bf31472fd354bc62537501 Mon Sep 17 00:00:00 2001 From: Tanner Heffner Date: Fri, 16 Feb 2024 12:00:19 -0800 Subject: [PATCH 13/13] add next preview server route for brd (#17264) --- docroot/sites/default/settings/settings.brd_common.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docroot/sites/default/settings/settings.brd_common.php b/docroot/sites/default/settings/settings.brd_common.php index 3c4f454962..a66ecd139b 100644 --- a/docroot/sites/default/settings/settings.brd_common.php +++ b/docroot/sites/default/settings/settings.brd_common.php @@ -16,3 +16,7 @@ } $settings['cms_datadog_api_key'] = getenv('CMS_DATADOG_API_KEY'); + +// Update next-build site endpoint to the appropriate preview alias +$config['next.next_site.next_build_preview_server']['base_url'] = getenv('NEXT_BUILD_PREVIEW_HOSTNAME'); +$config['next.next_site.next_build_preview_server']['preview_url'] = getenv('NEXT_BUILD_PREVIEW_HOSTNAME') . 'api/preview';