Skip to content

Commit

Permalink
Fix 8.x build (#4110)
Browse files Browse the repository at this point in the history
* Revert "Convert Drush Make to Composer more accurately (#4082)"

This reverts commit 557b072.

* Add mysql service to Travis build

* Update from git.drupal.org to git.drupalcode.org

* Mark test using 'devel' as skipped if Drupal version is too old. Skip testing broken part of sql-sync with sanitize.

* Update make tests for changes on drupal.org.
  • Loading branch information
greg-1-anderson committed Jun 28, 2019
1 parent 557b072 commit 61c8f45
Show file tree
Hide file tree
Showing 16 changed files with 465 additions and 271 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ branches:
- /^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+.*$/
language: php

services:
- mysql

# Cache Composer & Unish directories.
cache:
directories:
Expand All @@ -29,23 +32,23 @@ matrix:
include:
# D8.7.x
- php: 7.0
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=7.0-alpha1'
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=7.3'

# D8.6.x
- php: 7.0
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=6.12'
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=6.17'

# D8.5.x
- php: 7.0
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=5.13'
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=5.15'

# D8.4.x
- php: 7.0
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=4.8 PHPUNIT_ARGS=--group=commands'

# D8.3.x
- php: 7.0
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=3.7 PHPUNIT_ARGS=--group=commands'
env: 'UNISH_DRUPAL_MAJOR_VERSION=8 UNISH_DRUPAL_MINOR_VERSION=3.9 PHPUNIT_ARGS=--group=commands'

# D8.2.x
- php: 7.0
Expand All @@ -64,7 +67,7 @@ matrix:
env: 'UNISH_DRUPAL_MAJOR_VERSION=6'

# D6
- php: 5.4
- php: 5.6
env: 'UNISH_DRUPAL_MAJOR_VERSION=6'

before_install:
Expand Down
4 changes: 2 additions & 2 deletions commands/make/make.download.inc
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ function make_download_git($name, $type, $download, $download_location) {
$tmp_path = make_tmp();
$wc = _get_working_copy_option($download);
$checkout_after_clone = TRUE;
// If no download URL specified, assume anonymous clone from git.drupal.org.
$download['url'] = isset($download['url']) ? $download['url'] : "https://git.drupal.org/project/$name.git";
// If no download URL specified, assume anonymous clone from git.drupalcode.org.
$download['url'] = isset($download['url']) ? $download['url'] : "https://git.drupalcode.org/project/$name.git";
// If no working-copy download URL specified, assume it is the same.
$download['wc_url'] = isset($download['wc_url']) ? $download['wc_url'] : $download['url'];

Expand Down
61 changes: 13 additions & 48 deletions commands/make/make.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ function drush_make_convert_make_to_composer($info) {
);

$conflict = array(
'drupal/core' => '*',
'drupal/core' => '8.*',
);

$extra = array(
Expand Down Expand Up @@ -649,7 +649,7 @@ function drush_make_convert_make_to_composer($info) {
switch ($project['type']) {
case 'core':
$project['name'] = $core_project_name;
$projects[$project['name']] = str_replace('x', '*', $project['version']);
$projects[$project['name']] = '^' . str_replace('x', '*', $project['version']);
break;

default:
Expand All @@ -660,55 +660,18 @@ function drush_make_convert_make_to_composer($info) {

// Add project patches.
if (!empty($project['patch'])) {
$extra['patches'][$project['name']] = $project['patch'];
foreach($project['patch'] as $key => $patch) {
$patch_description = "Enter {$project['name']} patch #$key description here";
$extra['patches'][$project['name']][$patch_description] = $patch;
}
}
}

$repositories = array(
array('type' => 'composer', 'url' => 'https://packages.drupal.org/' . $core_major_version),
);

// Iterate over libraries, populating composer-friendly array.
if (!empty($info['libraries'])) {
foreach ($info['libraries'] as $library_name => $library) {
if (isset($library['directory_name'])) {
$library_name = $library['directory_name'];
}

$projects['drupal-library/' . $library_name] = '999.999.999';

$repository = array(
'type' => 'package',
'package' => array(
'name' => 'drupal-library/' . $library_name,
'version' => '999.999.999',
'type' => 'drupal-library',
),
);
if (isset($library['download']) && isset($library['download']['url'])) {
$url = $library['download']['url'];
if (isset($library['download']['type']) && $library['download']['type'] === 'git') {
$repository['package']['source'] = array(
'type' => 'git',
'url' => $url,
);
if (isset($library['download']['tag'])) {
$repository['package']['source']['reference'] = $library['download']['tag'];
}
}
else {
$type = 'zip';
if (substr_compare($url, '.tar', -4) === 0 || substr_compare($url, '.tar.gz', -7) === 0) {
$type = 'tar';
}
$repository['package']['dist'] = array(
'type' => $type,
'url' => $url,
);
}
}

$repositories[] = $repository;
$library_name = 'Verify project name: ' . $library_name;
$projects[$library_name] = drush_make_convert_project_to_composer($library, $core_major_version);
}
}

Expand All @@ -720,7 +683,9 @@ function drush_make_convert_make_to_composer($info) {
'name' => 'Enter project name here',
'description' => 'Enter project description here',
'type' => 'project',
'repositories' => $repositories,
'repositories' => array(
array('type' => 'composer', 'url' => 'https://packages.drupal.org/' . $core_major_version),
),
'require' => array_merge($php_reqs, $projects),
'conflict'=> $conflict,
'minimum-stability' => 'dev',
Expand Down Expand Up @@ -795,8 +760,8 @@ function drush_make_convert_version_to_composer($version) {
$cver = $version;
}
else {
// Replace '1.x' with '1.*'.
$cver = str_replace('x', '*', $version);
// Replace '1.x' with '^1.*'.
$cver = '^' . str_replace('x', '*', $version);
}
}

Expand Down
18 changes: 9 additions & 9 deletions commands/pm/package_handler/git_drupalorg.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function package_handler_validate() {
*/
function package_handler_download_project(&$request, $release) {
if ($username = drush_get_option('gitusername')) {
// Uses SSH, which enables pushing changes back to git.drupal.org.
$repository = 'git@git.drupal.org:project/' . $request['name'] . '.git';
// Uses SSH, which enables pushing changes back to git.drupalcode.org.
$repository = 'git@git.drupalcode.org:project/' . $request['name'] . '.git';
}
else {
$repository = 'https://git.drupal.org/project/' . $request['name'] . '.git';
$repository = 'https://git.drupalcode.org/project/' . $request['name'] . '.git';
}
$request['repository'] = $repository;
$tag = $release['tag'];
Expand Down Expand Up @@ -99,13 +99,13 @@ function package_handler_download_project(&$request, $release) {
$command .= ' ' . drush_escapeshellarg($repository);
$command .= ' ' . drush_escapeshellarg($clone_path);
if (!drush_shell_exec($command)) {
return drush_set_error('DRUSH_PM_GIT_CHECKOUT_PROBLEMS', dt('Unable to clone project !name from git.drupal.org.', array('!name' => $request['name'])));
return drush_set_error('DRUSH_PM_GIT_CHECKOUT_PROBLEMS', dt('Unable to clone project !name from git.drupalcode.org.', array('!name' => $request['name'])));
}

// Check if the 'tag' from the release feed is a tag or a branch.
// If the tag exists, git will return it
if (!drush_shell_cd_and_exec($clone_path, 'git tag -l ' . drush_escapeshellarg($tag))) {
return drush_set_error('DRUSH_PM_GIT_CHECKOUT_PROBLEMS', dt('Unable to clone project !name from git.drupal.org.', array('!name' => $request['name'])));
return drush_set_error('DRUSH_PM_GIT_CHECKOUT_PROBLEMS', dt('Unable to clone project !name from git.drupalcode.org.', array('!name' => $request['name'])));
}
$output = drush_shell_exec_output();

Expand All @@ -115,14 +115,14 @@ function package_handler_download_project(&$request, $release) {
$command = 'git checkout ' . drush_get_option('gitcheckoutparams');
$command .= ' ' . drush_escapeshellarg($tag);
if (!drush_shell_cd_and_exec($clone_path, $command)) {
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupal.org.');
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupalcode.org.');
}
}
else {
// Else, we want to checkout a branch.
// First check if we are not already in the correct branch.
if (!drush_shell_cd_and_exec($clone_path, 'git symbolic-ref HEAD')) {
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupal.org.');
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupalcode.org.');
}
$output = drush_shell_exec_output();
$current_branch = preg_replace('@^refs/heads/@', '', $output[0]);
Expand All @@ -133,7 +133,7 @@ function package_handler_download_project(&$request, $release) {
$command .= ' ' . drush_get_option('gitcheckoutparams');
$command .= ' --track ' . drush_escapeshellarg('origin/' . $tag) . ' -b ' . drush_escapeshellarg($tag);
if (!drush_shell_cd_and_exec($clone_path, $command)) {
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupal.org.');
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to retrieve ' . $request['name'] . ' from git.drupalcode.org.');
}
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ function package_handler_update_project($request, $release) {
}

if (!drush_shell_cd_and_exec($request['full_project_path'], implode(' ', $commands))) {
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to update ' . $request['name'] . ' from git.drupal.org.');
return drush_set_error('DRUSH_PM_UNABLE_CHECKOUT', 'Unable to update ' . $request['name'] . ' from git.drupalcode.org.');
}

return TRUE;
Expand Down
4 changes: 2 additions & 2 deletions commands/pm/pm.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1760,9 +1760,9 @@ function pm_drush_engine_package_handler() {
),
),
'git_drupalorg' => array(
'description' => 'Use git.drupal.org to checkout and update projects.',
'description' => 'Use git.drupalcode.org to checkout and update projects.',
'options' => array(
'gitusername' => 'Your git username as shown on user/[uid]/edit/git. Typically, this is set this in drushrc.php. Omitting this prevents users from pushing changes back to git.drupal.org.',
'gitusername' => 'Your git username as shown on user/[uid]/edit/git. Typically, this is set this in drushrc.php. Omitting this prevents users from pushing changes back to git.drupalcode.org.',
'gitsubmodule' => 'Use git submodules for checking out new projects. Existing git checkouts are unaffected, and will continue to (not) use submodules regardless of this setting.',
'gitcheckoutparams' => 'Add options to the `git checkout` command.',
'gitcloneparams' => 'Add options to the `git clone` command.',
Expand Down
2 changes: 1 addition & 1 deletion docs/make.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ Properties in the includer takes precedence over the includee.
type: "module"
download:
type: "git"
url: "https://git.drupal.org/project/views.git"
url: "https://git.drupalcode.org/project/views.git"

A project or library entry of an included makefile can be removed entirely by
setting the corresponding key to NULL:
Expand Down
4 changes: 2 additions & 2 deletions examples/example.make
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ api = 2
; Git clone of Drupal 7.x. Requires the `core` property to be set to 7.x.
; projects[drupal][type] = "core"
; projects[drupal][download][type] = git
; projects[drupal][download][url] = https://git.drupal.org/project/drupal.git
; projects[drupal][download][url] = https://git.drupalcode.org/project/drupal.git

projects[] = drupal

Expand Down Expand Up @@ -69,7 +69,7 @@ projects[ctools][version] = 1.3

projects[data][type] = module
projects[data][download][type] = git
projects[data][download][url] = https://git.drupal.org/project/views.git
projects[data][download][url] = https://git.drupalcode.org/project/views.git
projects[data][download][revision] = DRUPAL-6--3

; For projects on drupal.org, some shorthand is available. If any
Expand Down
4 changes: 2 additions & 2 deletions examples/example.make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ api: 2
# drupal:
# type: "core"
# download:
# url: "https://git.drupal.org/project/drupal.git"
# url: "https://git.drupalcode.org/project/drupal.git"

projects:
drupal:
Expand Down Expand Up @@ -80,7 +80,7 @@ projects:
type: "module"
download:
type: "git" # Note, 'git' is the default, no need to specify.
url: "https://git.drupal.org/project/views.git"
url: "https://git.drupalcode.org/project/views.git"
revision: "7.x-3.x"

# For projects on drupal.org, some shorthand is available. If any
Expand Down
3 changes: 3 additions & 0 deletions tests/coreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public function testStandaloneScript() {
}

function testDrupalDirectory() {
if (explode('.', UNISH_DRUPAL_MINOR_VERSION)[0] < '5') {
$this->markTestSkipped('Test uses devel, which requires Drupal 8.5.x or later');
}
$root = $this->webroot();
$sitewide = $this->drupalSitewideDirectory();
$options = array(
Expand Down
14 changes: 7 additions & 7 deletions tests/makeConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public function providerTestMakeConvert() {
'core = 7.x',
'api = 2',
// Ensure Drupal core tag is set correctly.
'projects[drupal][download][tag] = "7.43"',
'projects[drupal][download][tag] = "7.67"',
'projects[features][download][type] = "git"',
'projects[features][download][url] = "https://git.drupal.org/project/features"',
'projects[features][download][tag] = "7.x-1.0-beta4"',
'projects[features][patch][0] = "http://drupal.org/files/issues/features-drush-backend-invoke-25.patch"'),
'projects[features][download][url] = "https://git.drupalcode.org/project/features.git"',
'projects[features][download][tag] = "1.x-0.0-beta4"',
'projects[features][patch][0] = "https://drupal.org/files/issues/features-drush-backend-invoke-25.patch"'),
),
array(
'composer.lock',
Expand All @@ -97,11 +97,11 @@ public function providerTestMakeConvert() {
'core: 7.x',
'api: 2',
// Ensure Drupal core tag is set correctly.
"tag: '7.43'",
"tag: '7.67'",
'features:',
'tag: 7.x-1.0-beta4',
'tag: 1.x-0.0-beta4',
'patch:',
"- 'http://drupal.org/files/issues/features-drush-backend-invoke-25.patch'",
"- 'https://drupal.org/files/issues/features-drush-backend-invoke-25.patch'",
),
),
);
Expand Down
7 changes: 5 additions & 2 deletions tests/makeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ function testInfoFileWritingGit() {

// Verify that a reference cache was created.
$cache_dir = UNISH_CACHE . DIRECTORY_SEPARATOR . 'cache';
$this->assertFileExists($cache_dir . '/git/cck_signup-' . md5('https://git.drupal.org/project/cck_signup.git'));
$this->assertFileExists($cache_dir . '/git/cck_signup-' . md5('https://git.drupalcode.org/project/cck_signup.git'));

// Test context_admin.info file.
$this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/context_admin/context_admin.info');
Expand All @@ -329,7 +329,7 @@ function testInfoFileWritingGit() {
$this->assertContains('project = "context_admin"', $contents);

// Verify git reference cache exists.
$this->assertFileExists($cache_dir . '/git/context_admin-' . md5('https://git.drupal.org/project/context_admin.git'));
$this->assertFileExists($cache_dir . '/git/context_admin-' . md5('https://git.drupalcode.org/project/context_admin.git'));

// Text caption_filter .info rewrite.
$this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/caption_filter/caption_filter.info');
Expand Down Expand Up @@ -412,6 +412,7 @@ function testMakeDefaultsYaml() {
}

function testMakeFile() {
$this->markTestSkipped('Test depends on drush_make, which can no longer be downloaded from drupal.org.');
$this->runMakefileTest('file');
}

Expand Down Expand Up @@ -456,6 +457,7 @@ function testMakeGZip() {
}

function testMakeIgnoreChecksums() {
$this->markTestSkipped('Test depends on drush_make, which can no longer be downloaded from drupal.org.');
$this->runMakefileTest('ignore-checksums');
}

Expand Down Expand Up @@ -501,6 +503,7 @@ function testMakeMd5Fail() {
}

function testMakeMd5Succeed() {
$this->markTestSkipped('Test depends on drush_make, which can no longer be downloaded from drupal.org.');
$this->runMakefileTest('md5-succeed');
}

Expand Down

0 comments on commit 61c8f45

Please sign in to comment.