From 868f7d8db5ec0bc04ce1a13e340169ae55884b07 Mon Sep 17 00:00:00 2001 From: Alex Finnarn Date: Tue, 6 Feb 2024 10:04:24 -0500 Subject: [PATCH] remove all references to simulatenous building using current pattern --- .../src/Environment/EnvironmentDiscovery.php | 4 ++-- .../src/Environment/EnvironmentInterface.php | 2 +- .../src/Environment/EnvironmentPluginBase.php | 7 ++----- .../src/EventSubscriber/ContinuousReleaseSubscriber.php | 2 +- .../src/Plugin/AdvancedQueue/JobType/ReleaseDispatch.php | 3 +-- .../src/Plugin/AdvancedQueue/JobType/ReleaseRequest.php | 9 +-------- .../src/Plugin/VAGov/Environment/BRD.php | 2 +- .../src/Commands/RequestCommands.php | 2 +- .../src/EventSubscriber/EntityEventSubscriber.php | 2 +- .../custom/va_gov_content_release/src/Form/BaseForm.php | 4 +--- .../va_gov_content_release/src/Request/Request.php | 3 +-- .../src/Request/RequestInterface.php | 6 +----- scripts/build-frontend.sh | 2 -- scripts/queue_runner/queue_runner.sh | 5 ++--- 14 files changed, 16 insertions(+), 37 deletions(-) diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentDiscovery.php b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentDiscovery.php index 52f75ef6d4..55d099bec3 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentDiscovery.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentDiscovery.php @@ -136,8 +136,8 @@ public function contentEditsShouldTriggerFrontendBuild() : bool { * * @throws \Drupal\Component\Plugin\Exception\PluginException */ - public function triggerFrontendBuild(array $payload) : void { - $this->getEnvironment()->triggerFrontendBuild($payload); + public function triggerFrontendBuild() : void { + $this->getEnvironment()->triggerFrontendBuild(); } /** diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentInterface.php b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentInterface.php index b249bb5635..798e823978 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentInterface.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentInterface.php @@ -20,7 +20,7 @@ public function getWebUrl() : string; /** * Trigger the frontend web build. */ - public function triggerFrontendBuild(array $payload) : void; + public function triggerFrontendBuild() : void; /** * Should this environment trigger a frontend content deploy? diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentPluginBase.php b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentPluginBase.php index b861158108..fd6d8ae2a1 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentPluginBase.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Environment/EnvironmentPluginBase.php @@ -58,13 +58,10 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritDoc} */ - public function triggerFrontendBuild(array $payload) : void { - // Write different files based on the frontend. - $destination = $payload['frontend'] === 'next_build' ? 'public://.next-buildrequest' : 'public://.buildrequest'; - + public function triggerFrontendBuild() : void { // The existence of this file triggers a content release. // See scripts/queue_runner/queue_runner.sh. - $this->filesystem->saveData('build plz', $destination, FileSystemInterface::EXISTS_REPLACE); + $this->filesystem->saveData('build plz', 'public://.buildrequest', FileSystemInterface::EXISTS_REPLACE); $this->messenger()->addStatus('A request to rebuild the front end has been submitted.'); } diff --git a/docroot/modules/custom/va_gov_build_trigger/src/EventSubscriber/ContinuousReleaseSubscriber.php b/docroot/modules/custom/va_gov_build_trigger/src/EventSubscriber/ContinuousReleaseSubscriber.php index d69b8a9a73..4038d7aa60 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/EventSubscriber/ContinuousReleaseSubscriber.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/EventSubscriber/ContinuousReleaseSubscriber.php @@ -72,7 +72,7 @@ public function releaseContinuously(ReleaseStateTransitionEvent $event) { if ($is_complete && $is_enabled) { $this->runDuringBusinessHours(function () { - $this->requestService->submitRequest('Continuous release', ['frontend' => 'content_build']); + $this->requestService->submitRequest('Continuous release'); }); } } diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseDispatch.php b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseDispatch.php index 469f58d47a..eb9ccb5832 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseDispatch.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseDispatch.php @@ -100,8 +100,7 @@ public function process(Job $job) { switch ($this->releaseStateManager->canAdvanceStateTo(ReleaseStateManager::STATE_DISPATCHED)) { case ReleaseStateManager::STATE_TRANSITION_OK: try { - $payload = $job->getPayload(); - $this->environmentDiscovery->triggerFrontendBuild($payload); + $this->environmentDiscovery->triggerFrontendBuild(); } catch (\Exception $e) { return JobResult::failure('Release dispatch failed with error: ' . $e->getMessage()); diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseRequest.php b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseRequest.php index 46745c183a..8361be6dd8 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseRequest.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/AdvancedQueue/JobType/ReleaseRequest.php @@ -104,14 +104,7 @@ public function process(Job $job) { switch ($this->releaseStateManager->canAdvanceStateTo(ReleaseStateManager::STATE_REQUESTED)) { case ReleaseStateManager::STATE_TRANSITION_OK: $payload = $job->getPayload(); - - // Log the frontend being requested. - $this->logger->info('Frontend build requested for @frontend', ['@frontend' => $payload['frontend']]); - - $dispatch_job = Job::create('va_gov_content_release_dispatch', [ - 'placeholder' => 'placeholder', - 'frontend' => $payload['frontend'], - ]); + $dispatch_job = Job::create('va_gov_content_release_dispatch', ['placeholder' => 'placeholder']); $this->dispatchQueue->enqueueJob($dispatch_job); $this->releaseStateManager->advanceStateTo(ReleaseStateManager::STATE_REQUESTED); $message = 'Content release dispatch has been queued. Reason: @reason'; diff --git a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/VAGov/Environment/BRD.php b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/VAGov/Environment/BRD.php index ccbbbd191f..04d51f7fd1 100644 --- a/docroot/modules/custom/va_gov_build_trigger/src/Plugin/VAGov/Environment/BRD.php +++ b/docroot/modules/custom/va_gov_build_trigger/src/Plugin/VAGov/Environment/BRD.php @@ -77,7 +77,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritDoc} */ - public function triggerFrontendBuild(array $payload) : void { + public function triggerFrontendBuild() : void { try { if ($this->pendingWorkflowRunExists()) { $vars = [ diff --git a/docroot/modules/custom/va_gov_content_release/src/Commands/RequestCommands.php b/docroot/modules/custom/va_gov_content_release/src/Commands/RequestCommands.php index b91dc4d570..865d6d0312 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Commands/RequestCommands.php +++ b/docroot/modules/custom/va_gov_content_release/src/Commands/RequestCommands.php @@ -40,7 +40,7 @@ public function __construct( * va-gov-content-release-request-submit */ public function submitRequest(string $reason = 'Build requested via Drush.') { - $this->requestService->submitRequest($reason, ['frontend' => 'content_build']); + $this->requestService->submitRequest($reason); $this->io()->success('Content Release requested; check the queue for status.'); } diff --git a/docroot/modules/custom/va_gov_content_release/src/EventSubscriber/EntityEventSubscriber.php b/docroot/modules/custom/va_gov_content_release/src/EventSubscriber/EntityEventSubscriber.php index 401c0470b6..52842f737c 100644 --- a/docroot/modules/custom/va_gov_content_release/src/EventSubscriber/EntityEventSubscriber.php +++ b/docroot/modules/custom/va_gov_content_release/src/EventSubscriber/EntityEventSubscriber.php @@ -104,7 +104,7 @@ public function handleNodeUpdate(VaNodeInterface $node) : void { $strategy = $this->strategyPluginManager->getStrategy($strategyId); if ($strategy->shouldTriggerContentRelease($node)) { $reason = $strategy->getReasonMessage($node); - $this->request->submitRequest($reason, ['frontend' => 'content_build']); + $this->request->submitRequest($reason); } } diff --git a/docroot/modules/custom/va_gov_content_release/src/Form/BaseForm.php b/docroot/modules/custom/va_gov_content_release/src/Form/BaseForm.php index c8d43d686f..4ceeff6869 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Form/BaseForm.php +++ b/docroot/modules/custom/va_gov_content_release/src/Form/BaseForm.php @@ -163,9 +163,7 @@ public function isUnderTest(FormStateInterface $form_state): bool { public function submitForm(array &$form, FormStateInterface $form_state) { $this->reporter->reportInfo($this->t('Content release requested successfully.')); if (!$this->isUnderTest($form_state)) { - // Determine which frontend submitted the request based on field presence. - $frontend = isset($form["build_request"]["next_build_selection"]) ? 'next_build' : 'content_build'; - $this->request->submitRequest('Build requested via form.', ['frontend' => $frontend]); + $this->request->submitRequest('Build requested via form.'); } else { $this->reporter->reportInfo($this->t('Build request skipped; form is under test.')); diff --git a/docroot/modules/custom/va_gov_content_release/src/Request/Request.php b/docroot/modules/custom/va_gov_content_release/src/Request/Request.php index 475198fd96..50df919898 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Request/Request.php +++ b/docroot/modules/custom/va_gov_content_release/src/Request/Request.php @@ -32,11 +32,10 @@ public function __construct(EntityTypeManagerInterface $entityTypeManager) { /** * {@inheritDoc} */ - public function submitRequest(string $reason, array $options) : void { + public function submitRequest(string $reason) : void { try { $job = Job::create(static::JOB_TYPE, [ 'reason' => $reason, - 'frontend' => $options['frontend'] ?? 'content_build', ]); $this->queue->enqueueJob($job); } diff --git a/docroot/modules/custom/va_gov_content_release/src/Request/RequestInterface.php b/docroot/modules/custom/va_gov_content_release/src/Request/RequestInterface.php index 6b83835a30..48ea999481 100644 --- a/docroot/modules/custom/va_gov_content_release/src/Request/RequestInterface.php +++ b/docroot/modules/custom/va_gov_content_release/src/Request/RequestInterface.php @@ -18,14 +18,10 @@ interface RequestInterface { * @param string $reason * The reason for the content release. This is logged, so it should be * human-readable but can be fairly detailed. - * @param array $options - * An array of options to pass to the job. - * - 'frontend' (string): The frontend to release content for, either - * 'content_build' or 'next_build'. * * @throws \Drupal\va_gov_content_release\Exception\RequestException * If the request could not be submitted. */ - public function submitRequest(string $reason, array $options) : void; + public function submitRequest(string $reason) : void; } diff --git a/scripts/build-frontend.sh b/scripts/build-frontend.sh index 82a9e6655e..e23e6b1d23 100755 --- a/scripts/build-frontend.sh +++ b/scripts/build-frontend.sh @@ -54,8 +54,6 @@ date >> ${logfile} echo "content-build version: ${content_build_version}" >> ${logfile} echo "vets-website version: ${vets_website_version}" >> ${logfile} -exit 1 - # 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} diff --git a/scripts/queue_runner/queue_runner.sh b/scripts/queue_runner/queue_runner.sh index 7070b2c5d8..16fd886e5b 100644 --- a/scripts/queue_runner/queue_runner.sh +++ b/scripts/queue_runner/queue_runner.sh @@ -3,6 +3,5 @@ cd "${TUGBOAT_ROOT}" ./bin/drush advancedqueue:queue:process command_runner 2>&1 ./bin/drush advancedqueue:queue:process content_release 2>&1 -#[ -f "./docroot/sites/default/files/.buildrequest" ] && ( ./scripts/build-frontend.sh > /dev/null 2>&1 && rm ./docroot/sites/default/files/.buildrequest ) & -#[ -f "./docroot/sites/default/files/.next-buildrequest" ] && ( ./scripts/next-build-frontend.sh && rm ./docroot/sites/default/files/.next-buildrequest ) & -sleep 6s +[ -f "./docroot/sites/default/files/.buildrequest" ] && ./scripts/build-frontend.sh && rm ./docroot/sites/default/files/.buildrequest +sleep 60s