Skip to content

Commit

Permalink
fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfinnarn committed Feb 9, 2024
1 parent 47920b0 commit 06a669f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 78 deletions.
30 changes: 29 additions & 1 deletion READMES/cms-content-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ sequenceDiagram
Complete->>+Ready: Content release workflow has completed
```


# Environment specific details

## BRD Production
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions config/sync/next.next_site.next_build_preview_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
63 changes: 2 additions & 61 deletions docroot/modules/custom/va_gov_content_release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -50,20 +50,20 @@ 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.
*/
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;
}

Expand All @@ -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')
);
}
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 0 additions & 5 deletions docroot/sites/default/settings/settings.local.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
Expand Down

0 comments on commit 06a669f

Please sign in to comment.