From 06a669fc8570a8eecd683eadbedc4edd1c300cd9 Mon Sep 17 00:00:00 2001 From: Alex Finnarn Date: Fri, 9 Feb 2024 14:16:06 -0500 Subject: [PATCH] fixes from code review --- READMES/cms-content-release.md | 30 ++++++++- ...xt.next_site.next_build_preview_server.yml | 4 +- .../custom/va_gov_content_release/README.md | 63 +------------------ .../src/Form/NextGitForm.php | 20 +++--- .../sites/default/settings/settings.local.php | 5 -- 5 files changed, 44 insertions(+), 78 deletions(-) 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 index c88d3010c3..226790fb81 100644 --- a/docroot/modules/custom/va_gov_content_release/README.md +++ b/docroot/modules/custom/va_gov_content_release/README.md @@ -9,64 +9,5 @@ va.gov is built using two separate frontend systems with a third being built: - 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 -In order to allow developers of the CMS to preview changes with different versions of the frontends, we have -developed an on-demand content release workflow that is primarily used on the Tugboat QA servers. - -## Content Build Releases - -The current static frontend "content-build" can be rebuilt using different versions of content-build and -vets-website. - -1. Go to "/admin/content/deploy/git". -2. Check if the "Release State" in the "Status Details" block is set to "Ready". If it isn't then submitting the - form will do nothing. -2. Choose a version for content-build or leave at default. -3. Choose a version for vets-website or leave at default. -4. Click "Release content" to set the versions of content-build and vets-website as well as queue a - "va_gov_content_release_request" job. -5. The "va_gov_content_release_request" job will be triggered in the background from a service running - `scripts/queue_runner/queue_runner.sh` continuously. Locally, the script has to be triggered manually. See the - [caveats](#caveats) section for more information. -6. The "va_gov_content_release_request" job will create a "va_gov_content_release_dispatch" job that ends up writing - a "buildrequest" file. -7. The continuously running `scripts/queue_runner/queue_runner.sh` script will look for the "buildrequest" file and - start a build if found. -8. Back on "/admin/content/deploy/git" you can view the build log via a link in the "Build log" section of the - "Status Details" block. -9. After the build completes, an event subscriber, `ContinuousReleaseSubscriber`, adds another job to the - "va_gov_content_release_request" queue if the build ran during business hours and continuous release is enabled in - settings. This keeps the build process going indefinitely. -10. View the frontend at the provided "Front end link" link in the "Status Details" block. - -There is a release state manager that can prevent any of these steps from happening, and you should check out the -`ReleaseStateManager` class for more information and details. There's a lot more to the process than what's outlined -above, but the above process should give you a rudimentary understanding of the way an on-demand release happens. - -## 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_git". -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 content-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/git" 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 runnning the background script** - On `ddev` the `queue_runner` scripts aren't runnning 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. +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 index 6eef6993bf..e20b3870b9 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php +++ b/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php @@ -2,11 +2,11 @@ namespace Drupal\va_gov_content_release\Form; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Link; -use Drupal\Core\Site\Settings; use Drupal\Core\State\State; use Drupal\Core\Url; use Drupal\va_gov_build_trigger\Service\ReleaseStateManager; @@ -29,14 +29,14 @@ class NextGitForm extends FormBase { protected FrontendVersionInterface $frontendVersion; /** - * File System Service. + * File system service. */ protected FileSystemInterface $fileSystem; /** - * The settings service. + * The config service. */ - protected Settings $settings; + protected ConfigFactory $config; /** * The state service. @@ -50,7 +50,7 @@ class NextGitForm extends FormBase { * The frontend version service. * @param \Drupal\Core\File\FileSystemInterface $fileSystem * The file system service. - * @param \Drupal\Core\Site\Settings $settings + * @param \Drupal\Core\Config\ConfigFactory $config * The settings service. * @param \Drupal\Core\State\State $state * The state service. @@ -58,12 +58,12 @@ class NextGitForm extends FormBase { public function __construct( FrontendVersionInterface $frontendVersion, FileSystemInterface $fileSystem, - Settings $settings, + ConfigFactory $config, State $state ) { $this->frontendVersion = $frontendVersion; $this->fileSystem = $fileSystem; - $this->settings = $settings; + $this->config = $config; $this->state = $state; } @@ -74,7 +74,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('va_gov_content_release.frontend_version'), $container->get('file_system'), - $container->get('settings'), + $container->get('config.factory'), $container->get('state') ); } @@ -254,7 +254,9 @@ private function getFileLink(string $file_name): Link|string { * The preview link. */ private function getPreviewLink(): Link { - $frontend_base_url = $this->settings->get('next.next_site.next_build_preview_server')['base_url'] ?? 'https://www.va.gov'; + $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); } diff --git a/docroot/sites/default/settings/settings.local.php b/docroot/sites/default/settings/settings.local.php index 3b0cfdaaf3..29610f0852 100644 --- a/docroot/sites/default/settings/settings.local.php +++ b/docroot/sites/default/settings/settings.local.php @@ -48,11 +48,6 @@ $settings['va_gov_web_root'] = getenv('DDEV_APPROOT') . '/web'; $settings['va_gov_vets_website_root'] = getenv('DDEV_APPROOT') . '/docroot/vendor/va-gov/vets-website'; -// Match next frontend variables with Tugboat. -$settings['next.next_site.next_build_preview_server']['base_url'] = 'https://localhost:3000'; -$settings['next.next_site.next_build_preview_server']['preview_url'] = 'https://localhost:3000/api/preview'; - - $settings['memcache']['servers'] = [ 'memcached:11211' => 'default', ];