Skip to content

Commit

Permalink
Use composer to set the sut path repository. (#3346)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson authored Feb 3, 2018
1 parent 704fd3f commit 6d78d47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs
defaults: &defaults
docker:
- image: php:7.1.3-cli
working_directory: ~/drush
environment:
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
Expand All @@ -16,7 +14,6 @@ jobs:
build:
<<: *defaults
docker:
# We can probably use a standard php container here. Maybe we should make our own w/ everything pre-installed
- image: circleci/php:7.1-apache-node
environment:
- MYSQL_HOST=127.0.0.1
Expand All @@ -30,7 +27,6 @@ jobs:
build_highest:
<<: *defaults
docker:
# We can probably use a standard php container here. Maybe we should make our own w/ everything pre-installed
- image: circleci/php:7.1-apache-node
environment:
- MYSQL_HOST=127.0.0.1
Expand All @@ -45,7 +41,6 @@ jobs:
build_56:
<<: *defaults
docker:
# We can probably use a standard php container here. Maybe we should make our own w/ everything pre-installed
- image: circleci/php:5.6-apache-node
environment:
- MYSQL_HOST=127.0.0.1
Expand Down
7 changes: 0 additions & 7 deletions tests/resources/codebase/composer-highest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "Site Under Test",
"repositories": [
{
"type": "path",
"url": "%PATH-TO-DRUSH%",
"options": {
"symlink": true
}
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
Expand Down
7 changes: 0 additions & 7 deletions tests/resources/codebase/composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "Site Under Test",
"repositories": [
{
"type": "path",
"url": "%PATH-TO-DRUSH%",
"options": {
"symlink": true
}
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
Expand Down
27 changes: 8 additions & 19 deletions unish.sut.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ function unish_setup_sut($unish_sandbox) {
drush_delete_dir($working_dir, TRUE);
$codebase = __DIR__ . '/tests/resources/codebase';
drush_copy_dir($codebase, $working_dir);
$composer_json = getenv('COMPOSER') ?: 'composer.json';
foreach ([$composer_json] as $filename) {
$path = $working_dir . "/$filename";
if (file_exists($path)) {
$contents = file_get_contents($path);
$new_contents = replace_token($contents);
file_put_contents($path, $new_contents);
}
}
$drush_project_root = escapeshellarg(__DIR__);
$composer_dir = escapeshellarg($working_dir);
// n.b. we expect the COMPOSER environment variable to be set to specify the target composer.json file
// TODO: We could probably use https://github.com/greg-1-anderson/composer-test-scenarios
// with a single composer.json file in tests/resources/codebase/web to manage our test scenarios.
// It might require slight modification to support the path repository below.
$cmd = "composer --working-dir=$composer_dir config repositories.1 '{\"type\":\"path\",\"url\":\"$drush_project_root\",\"options\":{\"symlink\":true}}'";
passthru($cmd);

$alias_contents = <<<EOT
dev:
Expand Down Expand Up @@ -78,13 +77,3 @@ function unish_setup_sut($unish_sandbox) {

return $return;
}

/**
* Replace a token with the /path/to/drush for this install.
*
* @param $contents
*/
function replace_token($contents) {
// @todo Use https://getcomposer.org/doc/03-cli.md#modifying-repositories if it can edit composer.lock too.
return str_replace('%PATH-TO-DRUSH%', __DIR__, $contents);
}

0 comments on commit 6d78d47

Please sign in to comment.