Skip to content

Commit

Permalink
remove all references to simulatenous building using current pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfinnarn committed Feb 6, 2024
1 parent 29038f6 commit 868f7d8
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
2 changes: 0 additions & 2 deletions scripts/build-frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 2 additions & 3 deletions scripts/queue_runner/queue_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 868f7d8

Please sign in to comment.