From c5e1e8eef217f2de136e6eeaaf0b77ae618e12ab Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 19 Apr 2018 14:29:13 -0700 Subject: [PATCH] Switch to Circle 2.0 (#5) * Try out circle 2.0 * fix path to phpunit * Run on 5.6 and 7.2 also * Lower required phpunit version to test against php 5.6 * Try to run integration tests * Need to run integrations * Install composer packages * Fetch the zipkin server ip address * Fix integration test * Need to setup remote docker --- .circleci/config.yml | 67 ++++++++++++++++++++++++ Dockerfile | 34 +++---------- Dockerfile.integration | 20 -------- circle.yml | 19 ------- cloudbuild.yaml | 30 ----------- composer.json | 2 +- integration-tests.yaml | 29 ----------- scripts/dump_credentials.php | 30 ----------- scripts/install_test_dependencies.sh | 76 ---------------------------- scripts/run_test_suite.sh | 21 -------- 10 files changed, 74 insertions(+), 254 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 Dockerfile.integration delete mode 100644 circle.yml delete mode 100644 cloudbuild.yaml delete mode 100644 integration-tests.yaml delete mode 100644 scripts/dump_credentials.php delete mode 100755 scripts/install_test_dependencies.sh delete mode 100755 scripts/run_test_suite.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0cc0aa3 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,67 @@ +unit-config: &unit-config + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "composer.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: composer install -n --prefer-dist + + - save_cache: + paths: + - ./vendor + key: v1-dependencies-{{ checksum "composer.json" }} + + # run tests! + - run: vendor/bin/phpcs --standard=./phpcs-ruleset.xml + - run: vendor/bin/phpunit + +version: 2 +jobs: + php56: + <<: *unit-config + docker: + - image: circleci/php:5.6-node + + php70: + <<: *unit-config + docker: + - image: circleci/php:7.0-node + + php71: + <<: *unit-config + docker: + - image: circleci/php:7.1-node + + php72: + <<: *unit-config + docker: + - image: circleci/php:7.2-node + + integration: + docker: + - image: circleci/php:7.2-node + steps: + - checkout + + - setup_remote_docker: + docker_layer_caching: true + + - run: docker network create -d bridge nw_zipkin + - run: docker run -d -p9411:9411 --name=zipkin-server --network=nw_zipkin openzipkin/zipkin:2.7 + - run: docker build -t integration-test . + - run: docker run --network=nw_zipkin -e ZIPKIN_HOST=zipkin-server integration-test vendor/bin/phpunit --config=./phpunit-integration.xml.dist + +workflows: + version: 2 + units: + jobs: + - php56 + - php70 + - php71 + - php72 + - integration diff --git a/Dockerfile b/Dockerfile index 21542e5..33379cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,35 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG BASE_IMAGE -FROM $BASE_IMAGE +FROM circleci/php:7.2-node -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 . /workspace +WORKDIR /workspace -COPY . /build/ +RUN sudo chown -R $(whoami) /workspace -WORKDIR /build/ +RUN composer install -n --prefer-dist -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 - -RUN pecl install opencensus-alpha && \ - php -dextension=opencensus.so vendor/bin/phpunit \ No newline at end of file +ENTRYPOINT [] \ No newline at end of file diff --git a/Dockerfile.integration b/Dockerfile.integration deleted file mode 100644 index 7b6892b..0000000 --- a/Dockerfile.integration +++ /dev/null @@ -1,20 +0,0 @@ -# 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. - -FROM gcr.io/google-appengine/php72 - -COPY . $APP_DIR -RUN composer install - -ENTRYPOINT [] \ No newline at end of file diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 9296470..0000000 --- a/circle.yml +++ /dev/null @@ -1,19 +0,0 @@ -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 deleted file mode 100644 index 5eb0250..0000000 --- a/cloudbuild.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# 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-debug', '.'] - waitFor: ['-'] - id: php71-debug diff --git a/composer.json b/composer.json index 714a28c..a261539 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "opencensus/opencensus": "~0.4" }, "require-dev": { - "phpunit/phpunit": "^6.0", + "phpunit/phpunit": "^5.0", "squizlabs/php_codesniffer": "2.*", "guzzlehttp/guzzle": "~6.0" }, diff --git a/integration-tests.yaml b/integration-tests.yaml deleted file mode 100644 index a9935d4..0000000 --- a/integration-tests.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# This cloudbuild.yaml is used to test run a full integration test against a -# running Zipkin instance. -steps: - - name: gcr.io/cloud-builders/docker - args: ['network', 'create', '-d', 'bridge', 'nw_zipkin'] - id: test-network - waitFor: ['-'] - - - name: gcr.io/cloud-builders/docker - args: - - 'run' - - '-d' - - '-p' - - '9411:9411' - - '--name=zipkin-server' - - '--network=nw_zipkin' - - 'openzipkin/zipkin:2.7' - id: zipkin-server - waitFor: ['test-network'] - - - name: gcr.io/cloud-builders/docker - args: ['build', '-t', 'gcr.io/$PROJECT_ID/test-runner', '-f', 'Dockerfile.integration', '.'] - id: test-build - waitFor: ['-'] - - - name: gcr.io/cloud-builders/docker - args: ['run', '--network=nw_zipkin', '-e', 'ZIPKIN_HOST=zipkin-server', 'gcr.io/$PROJECT_ID/test-runner', 'vendor/bin/phpunit', '--config=./phpunit-integration.xml.dist'] - id: test-run - waitFor: ['test-build', 'zipkin-server'] diff --git a/scripts/dump_credentials.php b/scripts/dump_credentials.php deleted file mode 100644 index 908fa40..0000000 --- a/scripts/dump_credentials.php +++ /dev/null @@ -1,30 +0,0 @@ -