From a29a0ecfcc854886c473bda9a894048e0d669922 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Mon, 2 Apr 2018 10:58:24 -0700 Subject: [PATCH 1/2] Add circle.yml --- Dockerfile | 43 ++++++++++++++++ circle.yml | 19 +++++++ cloudbuild.yaml | 38 ++++++++++++++ composer.json | 2 +- phpcs-ruleset.xml | 5 ++ scripts/dump_credentials.php | 30 +++++++++++ scripts/install_test_dependencies.sh | 76 ++++++++++++++++++++++++++++ scripts/run_test_suite.sh | 20 ++++++++ 8 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 circle.yml create mode 100644 cloudbuild.yaml create mode 100644 phpcs-ruleset.xml create mode 100644 scripts/dump_credentials.php create mode 100755 scripts/install_test_dependencies.sh create mode 100755 scripts/run_test_suite.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..17e6baf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +# Copyright 2018 OpenCensus Authors +# +# 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. + +ARG BASE_IMAGE +FROM $BASE_IMAGE + +RUN mkdir -p /build && \ + apt-get update -y && \ + apt-get install -y -q --no-install-recommends \ + build-essential \ + g++ \ + gcc \ + libc-dev \ + make \ + autoconf \ + git \ + unzip + +COPY . /build/ + +WORKDIR /build/ + +RUN EXPECTED_SIGNATURE=$(curl -f https://composer.github.io/installer.sig) && \ + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ + ACTUAL_SIGNATURE=$(php -r "echo (hash_file('SHA384', 'composer-setup.php'));") && \ + test $EXPECTED_SIGNATURE = $ACTUAL_SIGNATURE && \ + php composer-setup.php && \ + php -r "unlink('composer-setup.php');" + +RUN php composer.phar install && \ + vendor/bin/phpcs --standard=./phpcs-ruleset.xml && \ + vendor/bin/phpunit diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..9296470 --- /dev/null +++ b/circle.yml @@ -0,0 +1,19 @@ +machine: + timezone: America/Los_Angeles + environment: + GCLOUD_DIR: ${HOME}/gcloud + PATH: ${GCLOUD_DIR}/google-cloud-sdk/bin:${PATH} + CLOUDSDK_CORE_DISABLE_PROMPTS: 1 + CLOUDSDK_ACTIVE_CONFIG_NAME: opencensus-php + TEST_BUILD_DIR: ${HOME} + PHP_DOCKER_GOOGLE_CREDENTIALS: ${HOME}/credentials.json + GOOGLE_PROJECT_ID: php-stackdriver + TAG: circle-${CIRCLE_BUILD_NUM} + +dependencies: + override: + - scripts/install_test_dependencies.sh + +test: + override: + - scripts/run_test_suite.sh diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..0c0a704 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,38 @@ +# This cloudbuild.yaml is used to test the php extension against multiple versions of php +steps: + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.1', '.'] + waitFor: ['-'] + id: php71-nts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.1-zts', '.'] + waitFor: ['-'] + id: php71-zts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.0', '.'] + waitFor: ['-'] + id: php70-nts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.0-zts', '.'] + waitFor: ['-'] + id: php70-zts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.2', '.'] + waitFor: ['-'] + id: php72-nts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=php:7.2-zts', '.'] + waitFor: ['-'] + id: php72-zts + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php71-32bit', '.'] + waitFor: ['-'] + id: php71-32bit + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php70-32bit', '.'] + waitFor: ['-'] + id: php70-32bit + - name: gcr.io/cloud-builders/docker + args: ['build', '--build-arg', 'BASE_IMAGE=gcr.io/php-stackdriver/php71-debug', '.'] + waitFor: ['-'] + id: php71-debug diff --git a/composer.json b/composer.json index b5d1a2d..025a9cd 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "2.*", + "squizlabs/php_codesniffer": "2.*" }, "license": "Apache-2.0", "authors": [ diff --git a/phpcs-ruleset.xml b/phpcs-ruleset.xml new file mode 100644 index 0000000..b4467ac --- /dev/null +++ b/phpcs-ruleset.xml @@ -0,0 +1,5 @@ + + + + src + diff --git a/scripts/dump_credentials.php b/scripts/dump_credentials.php new file mode 100644 index 0000000..908fa40 --- /dev/null +++ b/scripts/dump_credentials.php @@ -0,0 +1,30 @@ + Date: Mon, 2 Apr 2018 11:12:59 -0700 Subject: [PATCH 2/2] Lower the phpunit version requirement for allowing PHP 7.0. Run tests with extension --- Dockerfile | 3 +++ composer.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 17e6baf..21542e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,3 +41,6 @@ RUN EXPECTED_SIGNATURE=$(curl -f https://composer.github.io/installer.sig) && \ RUN php composer.phar install && \ vendor/bin/phpcs --standard=./phpcs-ruleset.xml && \ vendor/bin/phpunit + +RUN pecl install opencensus-alpha && \ + php -dextension=opencensus.so vendor/bin/phpunit \ No newline at end of file diff --git a/composer.json b/composer.json index 025a9cd..9df5e64 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "apache/thrift": "^0.11" }, "require-dev": { - "phpunit/phpunit": "^7.0", + "phpunit/phpunit": "^6.0", "squizlabs/php_codesniffer": "2.*" }, "license": "Apache-2.0",