Skip to content

Commit

Permalink
Added dedicated D9 readiness job. (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCarden authored Mar 13, 2020
1 parent 370511c commit e85fb12
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ jobs:
- { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV }
- { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV }
- { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT }
- { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS }
- { name: "Custom job", env: ORCA_JOB=CUSTOM ORCA_CUSTOM_FIXTURE_INIT_ARGS="--help" ORCA_CUSTOM_TESTS_RUN_ARGS="--help" }
allow_failures:
- { php: "7.3", env: ORCA_JOB=D9_READINESS }

before_install:
- ../orca/bin/travis/self-test/before_install.sh
Expand Down
1 change: 1 addition & 0 deletions bin/travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ case "$ORCA_JOB" in
"ISOLATED_DEV") orca debug:packages CURRENT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --sut-only --core=CURRENT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;;
"INTEGRATED_DEV") orca debug:packages CURRENT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --core=CURRENT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;;
"CORE_NEXT") orca debug:packages NEXT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --core=NEXT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;;
"D9_READINESS") orca debug:packages D9_READINESS; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --sut-only --core='~9' --dev --profile=$ORCA_FIXTURE_PROFILE" ;;
"CUSTOM") eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --profile=$ORCA_FIXTURE_PROFILE ${ORCA_CUSTOM_FIXTURE_INIT_ARGS:=}" ;;
esac
3 changes: 3 additions & 0 deletions example/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
- { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV }
- { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV }
- { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT }
- { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS}
# Custom testing needs involving only minor variations on the standard setup
# can be achieved without custom scripting using the "CUSTOM" ORCA_JOB.
# @see https://github.com/acquia/orca/blob/master/docs/advanced-usage.md#travis-ci-scripts
Expand All @@ -109,6 +110,8 @@ jobs:
- env: ORCA_JOB=ISOLATED_DEV
- env: ORCA_JOB=INTEGRATED_DEV
- env: ORCA_JOB=CORE_NEXT
# You may need to allow the D9 readiness job to fail in the short term.
- { php: "7.3", env: ORCA_JOB=D9_READINESS }

# Install ORCA and prepare the environment.
before_install:
Expand Down
1 change: 1 addition & 0 deletions example/example.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ type: module
description: "Provides an example module for testing and illustration purposes."
package: Other
core: 8.x
core_version_requirement: '^8 || ^9'
5 changes: 3 additions & 2 deletions src/Command/Debug/DebugPackagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function execute(InputInterface $input, OutputInterface $output): int {
}

(new Table($output))
->setHeaderTitle("Drupal {$this->coreVersion}")
->setHeaders($this->getHeaders())
->setRows($this->getRows())
->render();
Expand All @@ -120,8 +121,8 @@ public function execute(InputInterface $input, OutputInterface $output): int {
* @SuppressWarnings(PHPMD.StaticAccess)
*/
private function handleCoreArgument($argument): void {
if (is_null($argument)) {
return;
if ($argument === NULL) {
$argument = '*';
}

if (!is_string($argument)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Enum/DrupalCoreVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ final class DrupalCoreVersion extends Enum {

public const NEXT_DEV = 'NEXT_DEV';

public const D9_READINESS = 'D9_READINESS';

/**
* Provides help text for commands that accept Drupal core version input.
*
Expand All @@ -35,6 +37,7 @@ public static function commandHelp() {
sprintf('- %s: The current development version, e.g., "8.6.x-dev"', self::CURRENT_DEV),
sprintf('- %s: The next release version if available, e.g., "8.7.0-beta2"', self::NEXT_RELEASE),
sprintf('- %s: The next development version, e.g., "8.7.x-dev"', self::NEXT_DEV),
sprintf('- %s: The current development version of Drupal 9, e.g., "9.0.x-dev"', self::D9_READINESS),
];
}

Expand Down
24 changes: 21 additions & 3 deletions src/Utility/DrupalCoreVersionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public function get(DrupalCoreVersion $version): string {
case DrupalCoreVersion::NEXT_DEV:
return $this->getNextDevVersion();

case DrupalCoreVersion::D9_READINESS:
return $this->getD9DevVersion();

default:
throw new \LogicException(sprintf('Unknown version. Update %s:%s.', __CLASS__, __FUNCTION__));
}
Expand Down Expand Up @@ -97,17 +100,20 @@ public function getPretty(DrupalCoreVersion $version): string {
* @param string $minimum_stability
* The minimum stability. Available options (in order of stability) are
* dev, alpha, beta, RC, and stable.
* @param string $preferred_stability
* The preferred stability. Available options (in order of stability) are
* dev, alpha, beta, RC, and stable.
*
* @return string
* The version string.
*/
public function find(string $target_package_version = NULL, string $minimum_stability = 'stable'): string {
public function find(string $target_package_version = NULL, string $minimum_stability = 'stable', string $preferred_stability = 'stable'): string {
$best_candidate = $this->getVersionSelector($minimum_stability)
->findBestCandidate('drupal/core', $target_package_version);
->findBestCandidate('drupal/core', $target_package_version, NULL, $preferred_stability);
if (!$best_candidate) {
throw new \RuntimeException(sprintf('No Drupal core version satisfies the given constraints: version=%s, minimum stability=%s', $target_package_version, $minimum_stability));
}
return $best_candidate->getVersion();
return $best_candidate->getPrettyVersion();
}

/**
Expand Down Expand Up @@ -196,6 +202,18 @@ private function getNextDevVersion(): string {
return "{$previous_minor_version}.x-dev";
}

/**
* Gets the next D9 dev version.
*
* @return string
* The version string, e.g., "9.0.x-dev".
*
* @see \Acquia\Orca\Enum\DrupalCoreVersion::D9_READINESS
*/
private function getD9DevVersion(): string {
return $this->find('~9', 'dev', 'dev');
}

/**
* Gets a Composer version selector.
*
Expand Down
30 changes: 8 additions & 22 deletions tests/Command/Debug/DebugPackagesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Acquia\Orca\Tests\Command\CommandTestBase;
use Acquia\Orca\Utility\DrupalCoreVersionFinder;
use Composer\Semver\VersionParser;
use Prophecy\Argument;
use Symfony\Component\Console\Command\Command;

/**
Expand Down Expand Up @@ -43,8 +42,8 @@ public function testBasicExecution() {
$package->getType()->willReturn('drupal-module');
$package->getInstallPathRelative()->willReturn('docroot/modules/contrib/example1', 'docroot/modules/contrib/example2');
$package->getRepositoryUrlRaw()->willReturn('../example1', '../example2');
$package->getVersionRecommended(NULL)->willReturn('~1.0');
$package->getVersionDev(NULL)->willReturn('1.x-dev');
$package->getVersionRecommended('*')->willReturn('~1.0');
$package->getVersionDev('*')->willReturn('1.x-dev');
$package->shouldGetEnabled()->willReturn(TRUE);
$this->packageManager
->getAll()
Expand All @@ -53,14 +52,14 @@ public function testBasicExecution() {

$this->executeCommand();

$this->assertEquals(ltrim("
+-----------+---------------+----------------------------------+-------------+---------+-------------+--------+
$this->assertEquals(ltrim('
+-----------+---------------+--------------------- Drupal * ---+-------------+---------+-------------+--------+
| Package | type | install_path | url | version | version_dev | enable |
+-----------+---------------+----------------------------------+-------------+---------+-------------+--------+
| Example 1 | drupal-module | docroot/modules/contrib/example1 | ../example1 | ~1.0 | 1.x-dev | yes |
| Example 2 | drupal-module | docroot/modules/contrib/example2 | ../example2 | ~1.0 | 1.x-dev | yes |
+-----------+---------------+----------------------------------+-------------+---------+-------------+--------+
"), $this->getDisplay(), 'Displayed correct output.');
'), $this->getDisplay(), 'Displayed correct output.');
$this->assertEquals(StatusCode::OK, $this->getStatusCode(), 'Returned correct status code.');
}

Expand All @@ -70,26 +69,13 @@ public function testBasicExecution() {
public function testValidArguments($argument) {
$version = '8.7.0.0';
$this->drupalCoreVersionFinder
->get(Argument::any())
->get(new DrupalCoreVersion($argument))
->shouldBeCalledOnce()
->willReturn($version);
$package = $this->prophesize(Package::class);
$package->getPackageName()->willReturn('Example 1');
$package->getType()->willReturn('drupal-module');
$package->getInstallPathRelative()->willReturn('docroot/modules/contrib/example1');
$package->getRepositoryUrlRaw()->willReturn('../example1');
$package->getVersionRecommended($version)
->shouldBeCalledOnce();
$package->getVersionDev($version)
->shouldBeCalledOnce();
$this->packageManager
->getAll()
->shouldBeCalledOnce()
->willReturn([$package]);
$package->shouldGetEnabled()->willReturn(TRUE);

$this->executeCommand(['core' => $argument]);

$this->assertContains(ltrim("- Drupal {$version} -"), $this->getDisplay(), 'Displayed correct output.');
$this->assertEquals(StatusCode::OK, $this->getStatusCode(), 'Returned correct status code.');
}

Expand All @@ -108,7 +94,7 @@ public function testInvalidArguments($version) {
$this->executeCommand(['core' => $version]);

$error_message = sprintf('Error: Invalid value for "core" option: "%s".', $version) . PHP_EOL
. 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", or any version string Composer understands.' . PHP_EOL;
. 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", "D9_READINESS", or any version string Composer understands.' . PHP_EOL;
$this->assertEquals($error_message, $this->getDisplay(), 'Displayed correct output.');
$this->assertEquals(StatusCode::ERROR, $this->getStatusCode(), 'Returned correct status code.');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/Fixture/FixtureInitCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function testCoreOptionVersionParsing($status_code, $value, $display) {

public function providerCoreOptionVersionParsing() {
$error_message = 'Error: Invalid value for "--core" option: "%s".' . PHP_EOL
. 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", or any version string Composer understands.' . PHP_EOL;
. 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", "D9_READINESS", or any version string Composer understands.' . PHP_EOL;
return [
[StatusCode::OK, self::CORE_VALUE_LITERAL_PREVIOUS_RELEASE, ''],
[StatusCode::OK, self::CORE_VALUE_LITERAL_CURRENT_RECOMMENDED, ''],
Expand Down

0 comments on commit e85fb12

Please sign in to comment.