diff --git a/.gitignore b/.gitignore
index 89b52fc6b7..f71405af45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -104,6 +104,8 @@ datadog-setup.php
# Ignore Next (next-build)
next
+# Ignore vets-wesite that is used for next-build.
+vets-website
# Ignore oauth keys used for validating next-build preview api requests
public.key
private.key
diff --git a/.tugboat/config.yml b/.tugboat/config.yml
index 6e628ef6c4..aafa977986 100644
--- a/.tugboat/config.yml
+++ b/.tugboat/config.yml
@@ -209,7 +209,6 @@ services:
- mkdir -p "${TUGBOAT_ROOT}/next/public"
- ln -snf "${TUGBOAT_ROOT}/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated"
-
# https://www.drush.org/latest/deploycommand/ (updatedb, cache:rebuild, config:import, deploy:hook)
- bash -lc 'drush deploy'
@@ -226,6 +225,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"
@@ -248,11 +254,7 @@ services:
- find "${DOCROOT}/vendor/va-gov/content-build/script" -type f -exec chmod +x {} \+
# Put necessary env variables in place for next's Drupal Preview before building server
- # Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing /
- - echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
- - echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
- - echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
- - echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
+ - ${TUGBOAT_ROOT}/scripts/next-set-tugboat-env-vars.sh
# Build storybook and the frontends (web, next) in parallel
- bash -lc 'time task --taskfile=tugboat.yml'
diff --git a/READMES/cms-content-release.md b/READMES/cms-content-release.md
index 8d9119600e..449fd35c36 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,34 @@ 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.
+4. Click "Restart Next Build Server" 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 server restart log via a link in the "Status" section of the
+ "Next Build Information" block.
+7. Once the restart completes no new restart will be triggered unless you request another restart.
+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/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..f8f996d9cd
--- /dev/null
+++ b/docroot/modules/custom/va_gov_content_release/src/Form/NextGitForm.php
@@ -0,0 +1,386 @@
+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('Choose specific branches for the next-build preview server and restart the server. Note: this does not perform any content-build actions.'), + '#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']['next_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']['next_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. Note: this vets-website branch is not connected to the vets-website branch used by content-build on this Tugboat instance. If you are testing vets-website changes with both next-build and content-build, both will need the branch updated.'), + '#autocomplete_route_name' => 'va_gov_content_release.frontend_version_autocomplete', + '#autocomplete_route_parameters' => [ + 'frontend' => 'next_vets_website', + 'count' => 10, + ], + '#size' => 72, + '#maxlength' => 1024, + '#hidden' => TRUE, + '#states' => [ + 'visible' => [':input[name="next_vets_website_selection"]' => ['value' => 'choose']], + ], + ]; + + $form['build_request']['actions']['#type'] = 'actions'; + $form['build_request']['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Restart Next Build Server'), + '#button_type' => 'primary', + ]; + + // 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']['next_vets_website_selection']['#disabled'] = TRUE; + $form['build_request']['next_vets_website_git_ref']['#disabled'] = TRUE; + $form['build_request']['actions']['submit']['#disabled'] = TRUE; + $build_log_text = 'Build is in progress. View log file below'; + } + else { + $build_log_text = 'Build is not in progress.'; + } + + $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, + ], + 'log_file' => [ + 'title' => $this->t('Log File'), + 'value' => $this->getFileLink('next-build.txt'), + ], + 'lock_file' => [ + 'title' => $this->t('Lock File'), + 'value' => $this->getFileLink(self::LOCK_FILE_NAME), + ], + 'request_file' => [ + 'title' => $this->t('Request File'), + 'value' => $this->getFileLink(self::REQUEST_FILE_NAME), + ], + 'next_build_version' => [ + 'title' => $this->t('Next-build Version'), + 'value' => $this->frontendVersion->getVersion(Frontend::NextBuild), + ], + 'vets_website_version' => [ + 'title' => $this->t('Vets-website Version'), + 'value' => $this->frontendVersion->getVersion(Frontend::NextVetsWebsite), + ], + 'view_preview' => [ + 'title' => $this->t('View Preview'), + 'value' => $this->getPreviewLink(), + ], + 'last_build_time' => [ + 'title' => $this->t('Last Build Time'), + 'value' => $this->state->get('next_build.status.last_build_date', 'N/A'), + ], + ], + ], + ], + ]; + + 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", ['attributes' => ['target' => '_blank']]); + 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::NextVetsWebsite, $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::NextVetsWebsite, $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/Frontend/Frontend.php b/docroot/modules/custom/va_gov_content_release/src/Frontend/Frontend.php index ce935f8188..582f9a0004 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Frontend/Frontend.php +++ b/docroot/modules/custom/va_gov_content_release/src/Frontend/Frontend.php @@ -1,10 +1,5 @@ TRUE, + default => FALSE, + }; + } + } 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..e966e6e854 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,34 @@ 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; + + /** + * The branch search service for `next-vets-website`. + * + * @var \Drupal\va_gov_git\BranchSearch\BranchSearchInterface + */ + protected $nvwBranchSearch; + + /** + * The API client for `next-vets-website`. + * + * @var \Drupal\va_gov_github\Api\Client\ApiClientInterface + */ + protected $nvwApiClient; + /** * Constructor. * @@ -63,19 +91,35 @@ 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`. + * @param \Drupal\va_gov_git\BranchSearch\BranchSearchInterface $nvwBranchSearch + * The branch search service for `next-vets-website`. + * @param \Drupal\va_gov_github\Api\Client\ApiClientInterface $nvwApiClient + * The API client for `next-vets-website`. */ public function __construct( BranchSearchInterface $cbBranchSearch, ApiClientInterface $cbApiClient, BranchSearchInterface $vwBranchSearch, ApiClientInterface $vwApiClient, - LoggerChannelFactoryInterface $loggerFactory + LoggerChannelFactoryInterface $loggerFactory, + BranchSearchInterface $nbBranchSearch, + ApiClientInterface $nbApiClient, + BranchSearchInterface $nvwBranchSearch, + ApiClientInterface $nvwApiClient, ) { $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; + $this->nvwBranchSearch = $nvwBranchSearch; + $this->nvwApiClient = $nvwApiClient; } /** @@ -95,6 +139,12 @@ protected function getBranchSearch(FrontendInterface $frontend) : BranchSearchIn case $frontend->isVetsWebsite(): return $this->vwBranchSearch; + case $frontend->isNextBuild(): + return $this->nbBranchSearch; + + case $frontend->isNextVetsWebsite(): + return $this->nvwBranchSearch; + default: throw new \InvalidArgumentException('Invalid frontend: ' . $frontend->getRawValue()); } @@ -117,6 +167,12 @@ protected function getApiClient(FrontendInterface $frontend) : ApiClientInterfac case $frontend->isVetsWebsite(): return $this->vwApiClient; + case $frontend->isNextBuild(): + return $this->nbApiClient; + + case $frontend->isNextVetsWebsite(): + return $this->nvwApiClient; + 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); + } + + /** + * {@inheritDoc} + */ + public function getNextVetsWebsite(): BranchSearchInterface { + return new BranchSearch($this->repositoryFactory->getNextVetsWebsite(), + $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..788c006954 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,20 @@ 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; + + /** + * Get the next-vets-website branch search service. + * + * @return \Drupal\va_gov_git\BranchSearch\BranchSearchInterface + * The next-vets-website branch search object. + */ + public function getNextVetsWebsite(): 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..53262c10f4 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 @@ -12,10 +12,14 @@ * 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. + * + * Additionally, we have `next-vets-website` key which is a duplicate of + * `vets-website` repository used exclusively with the `next-build` repository. */ class RepositoryFactory implements RepositoryFactoryInterface { @@ -65,4 +69,18 @@ public function getVetsWebsite(): RepositoryInterface { return $this->get(RepositorySettingsInterface::VETS_WEBSITE); } + /** + * {@inheritDoc} + */ + public function getNextBuild(): RepositoryInterface { + return $this->get(RepositorySettingsInterface::NEXT_BUILD); + } + + /** + * {@inheritDoc} + */ + public function getNextVetsWebsite(): RepositoryInterface { + return $this->get(RepositorySettingsInterface::NEXT_VETS_WEBSITE); + } + } 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..0dd646d18f 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,14 @@ * 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. + * + * Additionally, we have `next-vets-website` key which is a duplicate of + * `vets-website` repository used exclusively with the `next-build` repository. */ interface RepositoryFactoryInterface { @@ -55,4 +59,20 @@ 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; + + /** + * Get the next-vets-website repository. + * + * @return \Drupal\va_gov_git\Repository\RepositoryInterface + * The next-vets-website repository. + */ + public function getNextVetsWebsite(): 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..5d9a7203ce 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,15 @@ 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 NEXT_VETS_WEBSITE = 'next-vets-website'; + const REPOSITORY_NAMES = [ self::VA_GOV_CMS, self::CONTENT_BUILD, self::VETS_WEBSITE, + self::NEXT_BUILD, + self::NEXT_VETS_WEBSITE, ]; // Settings keys for the repositories' filesystem paths. @@ -26,10 +31,15 @@ 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 NEXT_VETS_WEBSITE_PATH_KEY = 'va_gov_next_vets_website_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, + self::NEXT_VETS_WEBSITE => self::NEXT_VETS_WEBSITE_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..26436dd130 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,12 @@ 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: [] + va_gov_git.branch_search.next_vets_website: + class: Drupal\va_gov_git\BranchSearch\BranchSearch + factory: [ '@va_gov_git.branch_search_factory', 'getNextVetsWebsite' ] + 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..1565b44c48 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,8 @@ 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'; + const NEXT_VETS_WEBSITE = 'next-vets-website'; /** * The settings service. @@ -64,4 +66,20 @@ 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()); + } + + /** + * {@inheritDoc} + */ + public function getNextVetsWebsite(): ApiClientInterface { + return $this->get(static::OWNER, static::NEXT_VETS_WEBSITE, + $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..c511028cd4 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,26 @@ 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; + + /** + * Retrieve an API client for the Next Vets-Website 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 getNextVetsWebsite(): 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..7369d76f49 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,10 @@ 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: [] + va_gov_github.api_client.next_vets_website: + class: Drupal\va_gov_github\Api\Client\ApiClientInterface + factory: [ '@va_gov_github.api_client_factory', 'getNextVetsWebsite' ] diff --git a/docroot/sites/default/settings/settings.local.php b/docroot/sites/default/settings/settings.local.php index dd715b5550..1542b05f11 100644 --- a/docroot/sites/default/settings/settings.local.php +++ b/docroot/sites/default/settings/settings.local.php @@ -47,6 +47,8 @@ $settings['va_gov_app_root'] = getenv('DDEV_APPROOT'); $settings['va_gov_web_root'] = getenv('DDEV_APPROOT') . '/web'; $settings['va_gov_vets_website_root'] = getenv('DDEV_APPROOT') . '/docroot/vendor/va-gov/vets-website'; +$settings['va_gov_next_build_root'] = getenv('DDEV_APPROOT') . '/next'; +$settings['va_gov_next_vets_website_root'] = getenv('DDEV_APPROOT') . '/vets-website'; $settings['memcache']['servers'] = [ 'memcached:11211' => 'default', diff --git a/docroot/sites/default/settings/settings.tugboat.php b/docroot/sites/default/settings/settings.tugboat.php index e28fdc8a73..7ccd3bfc8b 100644 --- a/docroot/sites/default/settings/settings.tugboat.php +++ b/docroot/sites/default/settings/settings.tugboat.php @@ -64,6 +64,8 @@ $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['va_gov_next_vets_website_root'] = getenv('TUGBOAT_ROOT') . '/vets-website'; $settings['memcache']['servers'] = [ 'memcache:11211' => 'default', diff --git a/scripts/next-build-frontend.sh b/scripts/next-build-frontend.sh new file mode 100755 index 0000000000..e4ba9cb709 --- /dev/null +++ b/scripts/next-build-frontend.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash + +# Exit if a command fails with a non-zero status code. +set -ex + +if [ -n "${IS_DDEV_PROJECT}" ]; then + APP_ENV="local" +elif [ -n "${TUGBOAT_ROOT}" ]; then + APP_ENV="tugboat" +else + APP_ENV="tugboat" +fi + +# Find repo root -> $ROOT +ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-unknown}} +if [ "$ROOT" == "unknown" ]; then + echo "[!] Could not determine the environment type. Aborting!" + exit 1 +fi + +# For convenience. +cd $ROOT + +# Store path to site default files directory. +filesdir="${ROOT}/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 next_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. +echo "==> Starting a frontend build. This file will be updated as the build progresses." >> ${logfile} + +# Get the requested next-build version. +if [ "${next_build_version}" != "__default" ]; then + echo "==> Checking out the requested frontend version" >> ${logfile} + pushd ${ROOT}/next + + # Reset the working directory to the last commit. + # This is necessary because we set some env vars for Tugboat which prevents + # the checkout from working if the working directory is dirty. + git reset --hard &>> ${logfile} + + 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} + + if [ "${APP_ENV}" == "tugboat" ]; then + echo "Setting up Tugboat environment variables for Next.js..." + ${ROOT}/scripts/next-set-tugboat-env-vars.sh + fi + + 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 ${ROOT}/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 + +# Create symlink between vets-website assets and next-build. +mkdir -p "${ROOT}/next/public" +ln -snf "${ROOT}/vets-website/build/localhost/generated" "${ROOT}/next/public/generated" + +# Build vets-website again. +# @todo Do the symlinks need to be re-created? +echo "==> Re-building Vets Website" >> ${logfile} +${ROOT}/scripts/vets-web-setup.sh &>> ${logfile} + +# Run the build. +echo "==> Starting build" >> ${logfile} +composer va:next:build &>> ${logfile} + +# Start next server. +echo "==> Starting next server" >> ${logfile} +composer va:next:start &>> ${logfile} + +# After this point, we are less concerned with errors; the build has completed. +set +e + +# Switch to the docroot to run drush commands. +cd "${ROOT}/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..c7061c424a 100755 --- a/scripts/next-build.sh +++ b/scripts/next-build.sh @@ -1,11 +1,23 @@ #!/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" + +nvm install 18.17.0 +nvm use 18.17.0 -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..e2edfd0146 100755 --- a/scripts/next-install.sh +++ b/scripts/next-install.sh @@ -1,33 +1,43 @@ #!/usr/bin/env bash +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 -# Installs the content-build dependencies. +cd ${ROOT} 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 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)" -#not sure how popd works -#pushd "./next" -yarn install -#popd +# @todo Should the manual steps go here like copying the .env file? or maybe in next-start.sh? -#popd > /dev/null +yarn install diff --git a/scripts/next-set-tugboat-env-vars.sh b/scripts/next-set-tugboat-env-vars.sh new file mode 100755 index 0000000000..624eb93219 --- /dev/null +++ b/scripts/next-set-tugboat-env-vars.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Put necessary env variables in place for next's Drupal Preview before building server +# Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing / +echo "Setting up Tugboat environment variables for Next.js..." +echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat +echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat +echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat +echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat diff --git a/scripts/next-start.sh b/scripts/next-start.sh index 99f1e59994..33d742f881 100755 --- a/scripts/next-start.sh +++ b/scripts/next-start.sh @@ -1,14 +1,33 @@ #!/usr/bin/env bash +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 + +nvm install 18.17.0 +nvm use 18.17.0 -# Start the dev server. Vets-website assets will be available to the preview server after content-build builds them. -# APP_ENV=tugboat yarn dev +# Kill any current running server. +NEXT_SERVER_PIDS=$(ps aux | grep -E '(\.\/scripts\/yarn\/start\.js|next start|next-router-worker)' | awk '{print $2}') +for pid in ${NEXT_SERVER_PIDS}; do + echo "Killing process ${pid}..." + kill $pid +done # Start the dev server. Vets-website assets need to be in place prior to this build. -APP_ENV=tugboat yarn start +# Need to start in the background so the script can exit. +APP_ENV=${APP_ENV} yarn start &> /dev/null & +PID=$! +echo "Started next server with PID: $PID" diff --git a/scripts/queue_runner/next_queue_runner.sh b/scripts/queue_runner/next_queue_runner.sh new file mode 100755 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/scripts/vets-web-setup.sh b/scripts/vets-web-setup.sh index 97234edab9..9c86d3ccf3 100755 --- a/scripts/vets-web-setup.sh +++ b/scripts/vets-web-setup.sh @@ -1,19 +1,31 @@ #!/usr/bin/env bash +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} + # Installs & builds vets-website dependencies for next-build preview. -#if [ ! -d docroot/vendor/va-gov/vets-website ]; then if [ ! -d vets-website ]; then - git clone --single-branch --depth 1 https://github.com/department-of-veterans-affairs/vets-website.git vets-website + # 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/vets-website.git vets-website else echo "Repo vets-website already cloned." fi -#cd docroot/vendor/va-gov/vets-website cd vets-website nvm install 14.15.1 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..24c76adce2 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,8 @@ 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')); + $this->assertEquals(RepositorySettingsInterface::PATH_KEYS['next-vets-website'], $repositorySettings->getPathKey('next-vets-website')); } /** @@ -69,6 +71,14 @@ 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'), + ], + [ + 'name' => RepositorySettingsInterface::NEXT_VETS_WEBSITE, + 'path' => Settings::get('va_gov_next_vets_website_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..39f2191e58 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,8 @@ 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', + 'va_gov_next_vets_website_root' => '/srv/next-vets-website', ]); return new RepositorySettings($settings); } @@ -68,6 +70,8 @@ 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], + ['next-vets-website', RepositorySettings::NEXT_VETS_WEBSITE_PATH_KEY], ]; } @@ -97,6 +101,8 @@ public function getPathDataProvider() { ['va.gov-cms', '/srv/cms'], ['content-build', '/srv/web'], ['vets-website', '/srv/vets-website'], + ['next-build', '/srv/next'], + ['next-vets-website', '/srv/next-vets-website'], ]; } @@ -146,6 +152,14 @@ public function testList() { 'name' => RepositorySettingsInterface::VETS_WEBSITE, 'path' => '/srv/vets-website', ], + [ + 'name' => RepositorySettingsInterface::NEXT_BUILD, + 'path' => '/srv/next', + ], + [ + 'name' => RepositorySettingsInterface::NEXT_VETS_WEBSITE, + 'path' => '/srv/next-vets-website', + ], ], $repositorySettings->list()); }