-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VACMS-16853: next-build git information for content release #16923
Closed
Closed
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6506bb1
add next-build as an option for requesting a content release
alexfinnarn 98a3e8b
only override needed form fields for content release form
alexfinnarn 46df63d
be more specific with repo roots in settings for different envs
alexfinnarn dd57f8a
fix broken unit test
alexfinnarn 292d9ff
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn 7b18c78
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn aae5d7a
fix broken integration test
alexfinnarn b20cdb8
add api client for next-build
alexfinnarn b231592
try different file root location
alexfinnarn aa141fe
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn d67212c
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn fc01fe3
add frontend information to payload, pass info to build trigger
alexfinnarn 83590d0
add start to next-build frontend script
alexfinnarn 4eca737
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn 1cd8eb8
update next-build-frontend.sh script
alexfinnarn 6b837d0
further separate content release state machines
alexfinnarn 07d1e93
Merge branch 'main' into VACMS-16853-next-build-branches
alexfinnarn fb68187
more bifurcating goodness
alexfinnarn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
docroot/modules/custom/va_gov_build_trigger/src/Commands/NextContentReleaseCommands.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
namespace Drupal\va_gov_build_trigger\Commands; | ||
|
||
use Drupal\Core\Logger\LoggerChannelFactoryInterface; | ||
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\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; | ||
|
||
/** | ||
* A Drush interface to the content release. | ||
*/ | ||
class NextContentReleaseCommands extends DrushCommands { | ||
/** | ||
* The release state manager. | ||
* | ||
* @var \Drupal\va_gov_build_trigger\Service\ReleaseStateManagerInterface | ||
*/ | ||
protected $releaseStateManager; | ||
|
||
/** | ||
* The build scheduler service. | ||
* | ||
* @var \Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface | ||
*/ | ||
protected $buildScheduler; | ||
|
||
/** | ||
* The content release request service. | ||
* | ||
* @var \Drupal\va_gov_content_release\Request\RequestInterface | ||
*/ | ||
protected $requestService; | ||
|
||
/** | ||
* The state management service. | ||
* | ||
* @var \Drupal\Core\State\StateInterface | ||
*/ | ||
protected $state; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \Drupal\va_gov_build_trigger\Service\ReleaseStateManagerInterface $releaseStateManager | ||
* The release state manager service. | ||
* @param \Drupal\va_gov_build_trigger\Service\BuildSchedulerInterface $buildScheduler | ||
* The build scheduler 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 | ||
* A logger channel factory. | ||
*/ | ||
public function __construct( | ||
ReleaseStateManagerInterface $releaseStateManager, | ||
BuildSchedulerInterface $buildScheduler, | ||
RequestInterface $requestService, | ||
StateInterface $state, | ||
LoggerChannelFactoryInterface $loggerChannelFactory | ||
) { | ||
$this->releaseStateManager = $releaseStateManager; | ||
$this->buildScheduler = $buildScheduler; | ||
$this->requestService = $requestService; | ||
$this->state = $state; | ||
$this->logger = $loggerChannelFactory->get('va_gov_build_trigger'); | ||
} | ||
|
||
/** | ||
* Reset the content release state. | ||
* | ||
* @command va-gov:content-release:next-reset-state | ||
*/ | ||
public function resetState() { | ||
$this->releaseStateManager->resetState(); | ||
$this->logger()->info('Content release state has been reset to \'ready\'.'); | ||
} | ||
|
||
/** | ||
* Advance the state like an external system would do through HTTP. | ||
* | ||
* @param string $state | ||
* Required. Declare which state to advance to. | ||
* | ||
* @command va-gov:content-release:next-advance-state | ||
*/ | ||
public function advanceState($state) { | ||
$is_allowed_notification = in_array($state, ContentReleaseNotificationController::allowedNotifications()); | ||
$can_transition = $this->releaseStateManager->canAdvanceStateTo($state); | ||
$can_transition = ($can_transition === ReleaseStateManager::STATE_TRANSITION_OK); | ||
|
||
if (!$is_allowed_notification || !$can_transition) { | ||
$this->logger()->error('State cannot be advanced to @state', [ | ||
'@state' => $state, | ||
]); | ||
return; | ||
} | ||
|
||
$this->releaseStateManager->advanceStateTo($state); | ||
$this->logger()->info('State has been advanced to @state', [ | ||
'@state' => $state, | ||
]); | ||
} | ||
|
||
/** | ||
* Get the current release state. | ||
* | ||
* @command va-gov:content-release:next-get-state | ||
*/ | ||
public function getReleaseState() { | ||
$state = $this->releaseStateManager->getState(); | ||
$this->io()->write($state); | ||
} | ||
|
||
/** | ||
* Make sure builds are going out at least hourly during business hours. | ||
* | ||
* @command va-gov:content-release:next-check-scheduled | ||
*/ | ||
public function checkScheduledBuild() { | ||
$this->buildScheduler->checkScheduledBuild(); | ||
} | ||
|
||
/** | ||
* If the state is stale, reset the state. | ||
* | ||
* @command va-gov:content-release:next-check-stale | ||
*/ | ||
public function checkStale() { | ||
if ($this->releaseStateManager->releaseStateIsStale()) { | ||
$this->resetState(); | ||
$this->requestService->submitRequest('Submitting new request due to staleness.'); | ||
} | ||
} | ||
|
||
/** | ||
* Check continuous release state. | ||
* | ||
* @command va-gov:content-release:next-is-continuous-release-enabled | ||
*/ | ||
public function checkContinuousReleaseState() { | ||
$this->io()->writeln(print_r($this->state->get(ContinuousReleaseSubscriber::CONTINUOUS_RELEASE_ENABLED, FALSE))); | ||
} | ||
|
||
/** | ||
* Toggle continuous release. | ||
* | ||
* @command va-gov:content-release:next-toggle-continuous | ||
*/ | ||
public function toggleContinuousRelease() { | ||
$current = $this->state->get(ContinuousReleaseSubscriber::CONTINUOUS_RELEASE_ENABLED, FALSE); | ||
$this->state->set(ContinuousReleaseSubscriber::CONTINUOUS_RELEASE_ENABLED, !$current); | ||
$status_text = (!$current === TRUE ? 'enabled' : 'disabled'); | ||
$this->io()->writeln('Continuous release is now ' . $status_text); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
docroot/modules/custom/va_gov_build_trigger/src/Service/NextReleaseStateManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Drupal\va_gov_build_trigger\Service; | ||
|
||
use Drupal\Component\Datetime\TimeInterface; | ||
use Drupal\Core\State\StateInterface; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
||
/** | ||
* A service for managing the state of the next release. | ||
*/ | ||
class NextReleaseStateManager extends ReleaseStateManager { | ||
public const STATE_KEY = 'va_gov_build_trigger.next_release_state'; | ||
|
||
/** | ||
* ReleaseStateManager constructor. | ||
* | ||
* @param \Drupal\Core\State\StateInterface $state | ||
* The site state service. | ||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher | ||
* The site event dispatcher service. | ||
* @param \Drupal\Component\Datetime\TimeInterface $time | ||
* The site time service. | ||
*/ | ||
public function __construct(StateInterface $state, EventDispatcherInterface $dispatcher, TimeInterface $time) { | ||
parent::__construct($state, $dispatcher, $time); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible useless method overriding detected