Skip to content

Commit

Permalink
Test component composer integration, bump gax requirement (#507)
Browse files Browse the repository at this point in the history
* Test component composer integeration, bump gax requirement

* Use dry-run and repository path

* Switch to exec()

* Add to travis build

* Skip if grpc missing
  • Loading branch information
jdpedrie authored May 25, 2017
1 parent ecae3e8 commit ae772db
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ before_script:

script:
- ./dev/sh/tests
- ./dev/sh/test-composer
- vendor/bin/phpcs --standard=./phpcs-ruleset.xml
- ./dev/sh/build-docs

Expand Down
5 changes: 5 additions & 0 deletions dev/sh/test-composer
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "Checking Component Installability"

php $(dirname $0)/../../tests/component/TestComposerInstall.php
6 changes: 3 additions & 3 deletions dev/sh/tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ set -e
function unit () {
echo "Running Unit Test Suite"

vendor/bin/phpunit
$(dirname $0)/../../vendor/bin/phpunit
}

function system () {
echo "Running System Test Suite"

vendor/bin/phpunit -c phpunit-system.xml.dist
$(dirname $0)/../../vendor/bin/phpunit -c phpunit-system.xml.dist
}

function snippets() {
echo "Running Snippet Test Suite"

vendor/bin/phpunit -c phpunit-snippets.xml.dist
$(dirname $0)/../../vendor/bin/phpunit -c phpunit-snippets.xml.dist
}

unit
Expand Down
3 changes: 1 addition & 2 deletions src/ErrorReporting/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"minimum-stability": "stable",
"require": {
"ext-grpc": "*",
"google/cloud-core": "^1.0",
"google/proto-client-php": "^0.13",
"google/gax": "^0.8"
"google/gax": "^0.9"
},
"extra": {
"component": {
Expand Down
3 changes: 1 addition & 2 deletions src/Monitoring/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"minimum-stability": "stable",
"require": {
"ext-grpc": "*",
"google/cloud-core": "^1.0",
"google/proto-client-php": "^0.13",
"google/gax": "^0.8"
"google/gax": "^0.9"
},
"extra": {
"component": {
Expand Down
76 changes: 76 additions & 0 deletions tests/component/TestComposerInstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/**
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* This file tests that all google-cloud-php components can be installed alongside
* each other at their latest versions.
*/

use Google\Cloud\Dev\GetComponentsTrait;

if (!extension_loaded('grpc')) {
echo "gRPC Not Installed.";
exit(0);
}

include __DIR__ .'/../../vendor/autoload.php';

define('BASE_PATH', __DIR__ .'/../..');

class GetComponentsImpl
{
use GetComponentsTrait;

public function components()
{
return $this->getComponents(
BASE_PATH .'/src',
BASE_PATH .'/composer.json'
);
}
}

$composer = [];
$composer['require'] = [];
$composer['repositories'] = [];
$composer['minimum-stability'] = 'dev';

foreach((new GetComponentsImpl)->components() as $component) {
if ($component['id'] === 'google-cloud') continue;
if ($component['id'] === 'cloud-core') continue;

$composer['require']['google/'. $component['id']] = '*';
$composer['repositories'][] = [
'type' => 'path',
'url' => BASE_PATH .'/'. $component['path']
];
}

file_put_contents(__DIR__ .'/composer.json', json_encode($composer, JSON_UNESCAPED_SLASHES));

$out = [];
$return = null;
exec('composer install --dry-run --working-dir='. __DIR__ .' 2>&1', $out, $return);
unlink(__DIR__ .'/composer.json');

if ($return !== 0) {
echo "Problem installing components!" . PHP_EOL . PHP_EOL;

echo implode("\n", $out);
exit(1);
}

0 comments on commit ae772db

Please sign in to comment.