Skip to content

Commit

Permalink
VACMS-6434: Vets-website content release integration (#15523)
Browse files Browse the repository at this point in the history
* VACMS-6434: Vets-website content release integration

* Missed a method :(

* Checkout vets-website.

* Set `va_gov_vets_website_root` correctly on Tugboat.

* A lot of stuff.

* Fix remove-git-dirs.sh

* Make -or a little clearer.

* Tweak tests.

* Fix status block.

* Fix a couple fails.

* Fix Tugboat path.

* Buncha crap.

* Fix some tests.

* Kinda confused tbh.

* Update Drush commands.

* Improve function name and URL construction for build log link.

* Tweaks to tests, forms, and content release status block.

* Simplify selection a bit.

* Remove code tags.

* Refine logging a bit for clarity.

* Fix typo in commands 😑

* Clarifying comments for log.
  • Loading branch information
ndouglas authored Nov 8, 2023
1 parent 37e4a0d commit f2ee99b
Show file tree
Hide file tree
Showing 78 changed files with 1,702 additions and 969 deletions.
23 changes: 21 additions & 2 deletions READMES/drush.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ See [SiteStatusCommands.php](../docroot/modules/custom/va_gov_build_trigger/src/

### Content Release

There is a gradual migration taking place from the existing system to a refactored version intended to decouple behavior from environment, accomodate multiple frontends, etc.

#### Current

The current system's commands mostly relate to continuous builds and management of the content release state machine:

See [ContentReleaseCommands.php](../docroot/modules/custom/va_gov_build_trigger/src/Commands/ContentReleaseCommands.php).

- `va-gov:content-release:advance-state` -- Advance the state like an external system would do through HTTP.
Expand All @@ -22,19 +28,32 @@ See [ContentReleaseCommands.php](../docroot/modules/custom/va_gov_build_trigger/
- `va-gov:content-release:get-frontend-version` -- Get the frontend version that was requested by the user.
- `va-gov:content-release:get-state` -- Get the current release state.
- `va-gov:content-release:is-continuous-release-enabled` -- Check continuous release state.
- `va-gov:content-release:request-frontend-build` -- Request a frontend build (but do not initiate it).
- `va-gov:content-release:reset-frontend-version` -- Reset the content release frontend version.
- `va-gov:content-release:reset-state` -- Reset the content release state.
- `va-gov:content-release:toggle-continuous` -- Toggle continuous release.

#### New

Housed in the new system:

See [RequestCommands.php](../docroot/modules/custom/va_gov_content_release/src/Commands/RequestCommands.php).

- `va-gov-content-release:request:submit` -- Request a frontend build (but do not initiate it).

See [FrontendVersionCommands.php](../docroot/modules/custom/va_gov_content_release/src/Commands/FrontendVersionCommands.php).

- `va-gov-content-release:frontend-version:get` -- Get the currently selected version of the selected frontend (defaults to `content_build`).
- `va-gov-content-release:frontend-version:reset` -- Reset (to default, or `main`) the currently selected version of the selected frontend (defaults to `content_build`).
- `va-gov-content-release:frontend-version:set` -- Set the currently selected version of the selected frontend (defaults to `content_build`).

### Metrics

See [MetricsCommands.php](../docroot/modules/custom/va_gov_backend/src/Commands/MetricsCommands.php).

- `va-gov:metrics:send` -- Send various application metrics to DataDog.


### Outdated Content

See
[CMS Notification System](https://github.com/department-of-veterans-affairs/va.gov-cms/tree/main/docroot/modules/custom/va_gov_notifications/README.md) for commands to test or
execute the various outdated content sends.
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const path = require("path");
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

const BASE_URL = "http://va-gov-cms.ddev.site";
const BASE_URL = process.env.BASE_URL || "https://va-gov-cms.ddev.site";

async function setupNodeEvents(on, config) {
// This is required for the preprocessor to be able to generate JSON reports after each run, and more,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
arguments:
- '@va_gov_build_trigger.release_state_manager'
- '@va_gov_build_trigger.build_scheduler'
- '@va_gov_build_trigger.build_requester'
- '@va_gov_content_release.request'
- '@state'
- '@logger.factory'
tags:
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
use Drupal\Core\State\StateInterface;
use Drupal\va_gov_build_trigger\Controller\ContentReleaseNotificationController;
use Drupal\va_gov_build_trigger\EventSubscriber\ContinuousReleaseSubscriber;
use Drupal\va_gov_build_trigger\Service\BuildRequester;
use Drupal\va_gov_build_trigger\Service\BuildRequesterInterface;
use Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface;
use Drupal\va_gov_build_trigger\Service\ReleaseStateManager;
use Drupal\va_gov_build_trigger\Service\ReleaseStateManagerInterface;
use Drupal\va_gov_content_release\Request\RequestInterface;
use Drush\Commands\DrushCommands;

/**
Expand All @@ -25,18 +24,18 @@ class ContentReleaseCommands extends DrushCommands {
protected $releaseStateManager;

/**
* The build requester service.
* The build scheduler service.
*
* @var \Drupal\va_gov_build_trigger\Service\BuildRequesterInterface
* @var \Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface
*/
protected $buildRequester;
protected $buildScheduler;

/**
* The build scheduler service.
* The content release request service.
*
* @var \Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface
* @var \Drupal\va_gov_content_release\Request\RequestInterface
*/
protected $buildScheduler;
protected $requestService;

/**
* The state management service.
Expand All @@ -59,8 +58,8 @@ class ContentReleaseCommands extends DrushCommands {
* The release state manager service.
* @param \Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface $buildScheduler
* The build scheduler service.
* @param \Drupal\va_gov_build_trigger\Service\BuildRequesterInterface $buildRequester
* The build requester service.
* @param \Drupal\va_gov_content_release\Request\RequestInterface $requestService
* The request service.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactory
Expand All @@ -69,13 +68,13 @@ class ContentReleaseCommands extends DrushCommands {
public function __construct(
ReleaseStateManagerInterface $releaseStateManager,
BuildSchedulerInterface $buildScheduler,
BuildRequesterInterface $buildRequester,
RequestInterface $requestService,
StateInterface $state,
LoggerChannelFactoryInterface $loggerChannelFactory
) {
$this->releaseStateManager = $releaseStateManager;
$this->buildScheduler = $buildScheduler;
$this->buildRequester = $buildRequester;
$this->requestService = $requestService;
$this->state = $state;
$this->logger = $loggerChannelFactory->get('va_gov_build_trigger');
}
Expand All @@ -91,19 +90,6 @@ public function resetState() {
$this->logger()->info('Content release state has been reset to \'ready\'.');
}

/**
* Reset the content release frontend version.
*
* @command va-gov:content-release:reset-frontend-version
* @aliases va-gov-content-release-reset-frontend-version
*/
public function resetFrontendVersion() {
$this->state->delete(BuildRequester::VA_GOV_FRONTEND_VERSION);
$this->logger()->info('Content release state has been reset to @state.', [
'@state' => ReleaseStateManager::STATE_DEFAULT,
]);
}

/**
* Advance the state like an external system would do through HTTP.
*
Expand Down Expand Up @@ -131,17 +117,6 @@ public function advanceState($state) {
]);
}

/**
* Get the frontend version that was requested by the user.
*
* @command va-gov:content-release:get-frontend-version
* @aliases va-gov-content-release-get-frontend-version
*/
public function getFrontendVersion() {
$state = $this->state->get(BuildRequester::VA_GOV_FRONTEND_VERSION, '__default');
$this->io()->write($state);
}

/**
* Get the current release state.
*
Expand All @@ -153,18 +128,6 @@ public function getReleaseState() {
$this->io()->write($state);
}

/**
* Request a frontend build (but do not initiate it).
*
* @command va-gov:content-release:request-frontend-build
* @aliases va-gov-content-release-request-frontend-build
*/
public function requestFrontendBuild() {
$this->buildRequester->resetFrontendVersion();
$this->buildRequester->requestFrontendBuild('Build requested via Drush.');
$this->io()->writeln('Frontend build has been requested');
}

/**
* Make sure builds are going out at least hourly during business hours.
*
Expand All @@ -184,7 +147,7 @@ public function checkScheduledBuild() {
public function checkStale() {
if ($this->releaseStateManager->releaseStateIsStale()) {
$this->resetState();
$this->requestFrontendBuild();
$this->requestService->submitRequest('Submitting new request due to staleness.');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Drupal\va_gov_build_trigger\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\va_gov_content_release\Request\RequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Drupal\va_gov_build_trigger\Service\BuildRequesterInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

/**
Expand All @@ -15,11 +15,11 @@
class ContentReleaseRequestController extends ControllerBase {

/**
* The release state manager.
* The request service.
*
* @var \Drupal\va_gov_build_trigger\Service\BuildRequesterInterface
* @var \Drupal\va_gov_content_release\Request\RequestInterface
*/
protected $buildRequester;
protected $requestService;

/**
* The current request stack.
Expand All @@ -31,13 +31,13 @@ class ContentReleaseRequestController extends ControllerBase {
/**
* Constructor for the content release request controller.
*
* @param \Drupal\va_gov_build_trigger\Service\BuildRequesterInterface $buildRequester
* @param \Drupal\va_gov_content_release\Request\RequestInterface $requestService
* The build requester service.
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
* The current request stack.
*/
public function __construct(BuildRequesterInterface $buildRequester, RequestStack $requestStack) {
$this->buildRequester = $buildRequester;
public function __construct(RequestInterface $requestService, RequestStack $requestStack) {
$this->requestService = $requestService;
$this->requestStack = $requestStack;
}

Expand All @@ -46,7 +46,7 @@ public function __construct(BuildRequesterInterface $buildRequester, RequestStac
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('va_gov_build_trigger.build_requester'),
$container->get('va_gov_content_release.request'),
$container->get('request_stack')
);
}
Expand All @@ -63,7 +63,7 @@ public function requestBuild() {
throw new BadRequestHttpException('Must provide a reason for requesting a frontend build.');
}

$this->buildRequester->requestFrontendBuild($reason);
$this->requestService->submitRequest($reason);

return new Response('Build requested.');
}
Expand Down
Loading

0 comments on commit f2ee99b

Please sign in to comment.