Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Configure Circle CI #1

Merged
merged 2 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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

RUN pecl install opencensus-alpha && \
php -dextension=opencensus.so vendor/bin/phpunit
19 changes: 19 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"apache/thrift": "^0.11"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "2.*",
"phpunit/phpunit": "^6.0",
"squizlabs/php_codesniffer": "2.*"
},
"license": "Apache-2.0",
"authors": [
Expand Down
5 changes: 5 additions & 0 deletions phpcs-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<ruleset name="Google-Cloud-PHP-PSR2">
<rule ref="PSR2" />
<file>src</file>
</ruleset>
30 changes: 30 additions & 0 deletions scripts/dump_credentials.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* 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.
*/

/**
* Dumps the contents of the environment variable GOOGLE_CREDENTIALS_BASE64 to
* a file.
*
* To setup Travis to run on your fork, read TRAVIS.md.
*/
if (getenv('GOOGLE_CREDENTIALS_BASE64') === false) {
exit(0);
}
file_put_contents(
getenv('PHP_DOCKER_GOOGLE_CREDENTIALS'),
base64_decode(getenv('GOOGLE_CREDENTIALS_BASE64'))
);
76 changes: 76 additions & 0 deletions scripts/install_test_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# 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.

# A script for installing necessary software on CI systems.

set -ex

if [ "${INSTALL_GCLOUD}" == "true" ]; then
# Install gcloud
if [ ! -d ${HOME}/gcloud/google-cloud-sdk ]; then
mkdir -p ${HOME}/gcloud &&
wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz --directory-prefix=${HOME}/gcloud &&
cd "${HOME}/gcloud" &&
tar xzf google-cloud-sdk.tar.gz &&
./google-cloud-sdk/install.sh --usage-reporting false --path-update false --command-completion false &&
cd "${TEST_BUILD_DIR}";
fi
fi

if [ -z "${CLOUDSDK_ACTIVE_CONFIG_NAME}" ]; then
echo "You need to set CLOUDSDK_ACTIVE_CONFIG_NAME envvar."
exit 1
fi

if [ -z "${GOOGLE_PROJECT_ID}" ]; then
echo "You need to set GOOGLE_PROJECT_ID envvar."
exit 1
fi

if [ -z "${CLOUDSDK_VERBOSITY}" ]; then
CLOUDSDK_VERBOSITY='none'
fi

# gcloud configurations
gcloud config configurations create ${CLOUDSDK_ACTIVE_CONFIG_NAME} || /bin/true # ignore failure
gcloud config set project ${GOOGLE_PROJECT_ID}
gcloud config set app/promote_by_default false
gcloud config set verbosity ${CLOUDSDK_VERBOSITY}

# Dump the credentials from the environment variable.
php scripts/dump_credentials.php

# Set the timeout
gcloud config set container/build_timeout 3600

if [ ! -f "${PHP_DOCKER_GOOGLE_CREDENTIALS}" ]; then
echo 'Please set PHP_DOCKER_GOOGLE_CREDENTIALS envvar.'
exit 1
fi

# Use the service account for gcloud operations.
gcloud auth activate-service-account \
--key-file "${PHP_DOCKER_GOOGLE_CREDENTIALS}"

if [ "${CIRCLECI}" == "true" ]; then
# Need sudo on circleci:
# https://discuss.circleci.com/t/gcloud-components-update-version-restriction/3725
# They also overrides the PATH to use
# /opt/google-cloud-sdk/bin/gcloud so we can not easily use our
# own gcloud
sudo /opt/google-cloud-sdk/bin/gcloud -q components update beta
else
gcloud -q components update beta
fi
20 changes: 20 additions & 0 deletions scripts/run_test_suite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# 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.

# A script for installing necessary software on CI systems.

set -ex

gcloud container builds submit --config=cloudbuild.yaml .