Skip to content

Commit f44c03f

Browse files
authored
Adds Kokoro pre-submit (GoogleCloudPlatform#598)
1 parent bd6341a commit f44c03f

File tree

72 files changed

+1744
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1744
-684
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ credentials.*
88
**/build/
99
.php_cs.cache
1010
.vscode/
11-
export-secrets.sh
1211
iap/composer.lock
12+
.kokoro/secrets.sh

.kokoro/php72/docker/Dockerfile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
FROM gcr.io/google_appengine/php72
22

3-
RUN composer global require phpunit/phpunit:4.8
3+
RUN apt-get update && apt-get install -y \
4+
python-ipaddr \
5+
autoconf \
6+
build-essential \
7+
zlib1g-dev \
8+
jq
49

5-
RUN export PATH="$PATH:/opt/composer/vendor/bin"
10+
RUN git clone https://github.com/GoogleCloudPlatform/php-tools.git ${HOME}/php-tools \
11+
&& ${HOME}/php-tools/scripts/install_test_deps.sh
12+
13+
# install / enable PHP extensions
14+
RUN pecl install grpc \
15+
&& echo "extension=grpc.so" >> /opt/php72/lib/conf.d/ext-grpc.ini \
16+
&& echo "extension=bcmath.so" >> /opt/php72/lib/conf.d/ext-bcmath.ini
17+
18+
# Install composer globally
19+
RUN composer global require phpunit/phpunit:^5.0
20+
21+
# Install Google Cloud SDK
22+
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz \
23+
-o ${HOME}/google-cloud-sdk.tar.gz \
24+
&& tar xzf ${HOME}/google-cloud-sdk.tar.gz -C $HOME \
25+
&& ${HOME}/google-cloud-sdk/install.sh \
26+
--usage-reporting false \
27+
--path-update false \
28+
--command-completion false
29+
30+
ENV PATH="$PATH:/opt/composer/vendor/bin:/root/google-cloud-sdk/bin"
631

732
ENTRYPOINT /bin/bash

.kokoro/secrets-example.sh

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
# Run the following gcloud command to decrypt secrets.sh.enc as follows: #
5+
# #
6+
# gcloud kms decrypt -location=global --keyring=ci --key=ci \ #
7+
# --ciphertext-file=.kokoro/secrets.sh.enc \ #
8+
# --plaintext-file=.kokoro/secrets.sh #
9+
# #
10+
# Then run `source .kokoro/secrets.sh` #
11+
################################################################################
12+
13+
# General
14+
export GOOGLE_PROJECT_ID=
15+
export GOOGLE_API_KEY=
16+
export GOOGLE_STORAGE_BUCKET=$GOOGLE_PROJECT_ID
17+
export GOOGLE_CLIENT_ID=
18+
export GOOGLE_CLIENT_SECRET=
19+
export GCLOUD_PROJECT=$GOOGLE_PROJECT_ID
20+
21+
# AppEngine
22+
export MAILJET_APIKEY=
23+
export MAILJET_SECRET=
24+
export MAILGUN_APIKEY=
25+
export MAILGUN_DOMAIN=
26+
export MAILGUN_RECIPIENT=
27+
export SENDGRID_APIKEY=
28+
export SENDGRID_SENDER=
29+
export TWILIO_ACCOUNT_SID=
30+
export TWILIO_AUTH_TOKEN=
31+
export TWILIO_FROM_NUMBER=
32+
export TWILIO_TO_NUMBER=
33+
34+
# BigQuery
35+
export GOOGLE_BIGQUERY_DATASET=test_dataset
36+
export GOOGLE_BIGQUERY_TABLE=test_table
37+
38+
# CloudSQL
39+
export CLOUDSQL_CONNECTION_NAME_MYSQL=
40+
export CLOUDSQL_CONNECTION_NAME_POSTGRES=
41+
export MYSQL_DSN=
42+
export MYSQL_DATABASE=
43+
export MYSQL_USER=
44+
export MYSQL_PASSWORD=
45+
export POSTGRES_DSN=
46+
export POSTGRES_DATABASE=
47+
export POSTGRES_USER=
48+
export POSTGRES_PASSWORD=
49+
50+
# Datastore
51+
export CLOUD_DATASTORE_NAMESPACE=
52+
export DATASTORE_EVENTUALLY_CONSISTENT_RETRY_COUNT=
53+
54+
# DLP
55+
export DLP_TOPIC=dlp-tests
56+
export DLP_SUBSCRIPTION=dlp-tests
57+
export DLP_DEID_WRAPPED_KEY=
58+
export DLP_DEID_KEY_NAME=projects/$GOOGLE_PROJECT_ID/locations/global/keyRings/ci/cryptoKeys/ci
59+
60+
# Firestore
61+
export FIRESTORE_PROJECT_ID=
62+
63+
# IAP
64+
export IAP_CLIENT_ID=
65+
export IAP_PROJECT_ID=
66+
export IAP_PROJECT_NUMBER=
67+
export IAP_URL=
68+
69+
# IAM
70+
export GOOGLE_IAM_USER=
71+
72+
# IOT
73+
export GOOGLE_IOT_DEVICE_CERTIFICATE_B64=
74+
75+
# KMS
76+
export GOOGLE_KMS_KEYRING=
77+
export GOOGLE_KMS_CRYPTOKEY=
78+
export GOOGLE_KMS_CRYPTOKEY_ALTERNATE=
79+
export GOOGLE_KMS_SERVICEACCOUNTEMAIL=
80+
81+
# PubSub
82+
export GOOGLE_PUBSUB_SUBSCRIPTION=php-example-subscription
83+
export GOOGLE_PUBSUB_TOPIC=php-example-topic
84+
85+
# Spanner
86+
export GOOGLE_SPANNER_INSTANCE_ID=
87+
export GOOGLE_SPANNER_DATABASE_ID=test-database
88+
89+
# Tasks
90+
export CLOUD_TASKS_APPENGINE_QUEUE=
91+
export CLOUD_TASKS_LOCATION=
92+
export CLOUD_TASKS_PULL_QUEUE=

.kokoro/secrets.sh.enc

5.61 KB
Binary file not shown.

.kokoro/system_tests.sh

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
11
#!/bin/bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
217
set -ex
318

4-
echo "hello world"
19+
# Kokoro directory for running these samples
20+
cd github/php-docs-samples
21+
22+
export GOOGLE_APPLICATION_CREDENTIALS=$KOKORO_GFILE_DIR/service-account.json
23+
24+
# export the secrets
25+
if [ -f ${GOOGLE_APPLICATION_CREDENTIALS} ]; then
26+
gcloud auth activate-service-account \
27+
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}" \
28+
--project $(cat "${GOOGLE_APPLICATION_CREDENTIALS}" | jq -r .project_id)
29+
gcloud kms decrypt \
30+
--location=global \
31+
--keyring=ci \
32+
--key=ci \
33+
--ciphertext-file=.kokoro/secrets.sh.enc \
34+
--plaintext-file=.kokoro/secrets.sh
35+
fi
36+
37+
# Unencrypt and extract secrets
38+
source .kokoro/secrets.sh
39+
40+
mkdir -p build/logs
41+
42+
export IS_PULL_REQUEST=$KOKORO_GITHUB_PULL_REQUEST_COMMIT
43+
44+
# Run tests
45+
bash testing/run_test_suite.sh

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ env:
3939
- PATH="${HOME}/google-cloud-sdk/bin:${PATH}"
4040
- PHP_CGI_PATH=/home/travis/.phpenv/shims/php-cgi
4141
- TEST_BUILD_DIR=$TRAVIS_BUILD_DIR
42+
# We use the envvar "IS_PULL_REQUEST" for both kokoro and travis
43+
- IS_PULL_REQUEST=$TRAVIS_PULL_REQUEST_BRANCH
4244

4345
before_install:
4446
- git clone https://github.com/GoogleCloudPlatform/php-tools.git ${HOME}/php-tools

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Please fill out either the individual or corporate Contributor License Agreement
1212
own the intellectual property, then you'll need to sign an
1313
[individual CLA](https://developers.google.com/open-source/cla/individual).
1414
* If you work for a company that wants to allow you to contribute your work,
15-
then you'll need to sign a
15+
then you'll need to sign a
1616
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
1717

1818
Follow either of the two links above to access the appropriate CLA and
@@ -31,14 +31,14 @@ accept your pull requests.
3131
credentials](https://cloud.google.com/docs/authentication/getting-started)
3232
by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the
3333
path to a service account key JSON file.
34-
34+
3535
Then set any environment variables needed by the test. Check the
3636
`$SAMPLES_DIRECTORY/test` directory to see what specific variables are needed.
3737
```
3838
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
39-
export GOOGLE_BUCKET_NAME=YOUR_BUCKET
39+
export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
4040
```
41-
41+
4242
To run the tests in a samples directory,
4343
```
4444
cd $SAMPLES_DIRECTORY

appengine/flexible/cloudsql-mysql/test/LocalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function setUp()
2828

2929
public function createApplication()
3030
{
31-
if (getenv('MYSQL_DSN') === false ||
32-
getenv('MYSQL_USER') === false ||
33-
getenv('MYSQL_PASSWORD') === false) {
31+
if (!getenv('MYSQL_DSN') ||
32+
!getenv('MYSQL_USER') ||
33+
!getenv('MYSQL_PASSWORD')) {
3434
$this->markTestSkipped('set the MYSQL_DSN, MYSQL_USER and MYSQL_PASSWORD environment variables');
3535
return;
3636
}

appengine/flexible/cloudsql-postgres/test/LocalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public function setUp()
2828

2929
public function createApplication()
3030
{
31-
if (getenv('POSTGRES_DSN') === false ||
32-
getenv('POSTGRES_USER') === false ||
33-
getenv('POSTGRES_PASSWORD') === false) {
31+
if (!getenv('POSTGRES_DSN') ||
32+
!getenv('POSTGRES_USER') ||
33+
!getenv('POSTGRES_PASSWORD')) {
3434
$this->markTestSkipped('set the POSTGRES_DSN, POSTGRES_USER and POSTGRES_PASSWORD environment variables');
3535
return;
3636
}

appengine/flexible/logging/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222

2323
// create the Silex application
2424
$app = new Application();
25-
$app['project_id'] = getenv('GOOGLE_CLOUD_PROJECT');
25+
$app['project_id'] = getenv('GOOGLE_PROJECT_ID');
2626
// register twig
2727
$app->register(new TwigServiceProvider(), [
2828
'twig.path' => __DIR__
2929
]);
3030

3131
$app->get('/', function () use ($app) {
3232
if (empty($app['project_id'])) {
33-
return 'Set the GOOGLE_CLOUD_PROJECT environment variable to run locally';
33+
return 'Set the GOOGLE_PROJECT_ID environment variable to run locally';
3434
}
3535
$projectId = $app['project_id'];
3636
# [START list_entries]

appengine/flexible/logging/test/LocalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class LocalTest extends WebTestCase
2222
{
2323
public function setUp()
2424
{
25-
if (!getenv('GOOGLE_CLOUD_PROJECT')) {
26-
$this->markTestSkipped('Must set GOOGLE_CLOUD_PROJECT');
25+
if (!getenv('GOOGLE_PROJECT_ID')) {
26+
$this->markTestSkipped('Must set GOOGLE_PROJECT_ID');
2727
}
2828
if (!getenv('TRAVIS_SECURE_ENV_VARS')) {
2929
$this->markTestSkipped('No secret available');
@@ -36,7 +36,7 @@ public function setUp()
3636
public function createApplication()
3737
{
3838
$app = require __DIR__ . '/../app.php';
39-
$app['project_id'] = getenv('GOOGLE_CLOUD_PROJECT');
39+
$app['project_id'] = getenv('GOOGLE_PROJECT_ID');
4040
return $app;
4141
}
4242

appengine/flexible/sendgrid/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ composer install
2727

2828
**Run Locally**
2929
```sh
30-
export SENDGRID_API_KEY=your-sendgrid-api-key
30+
export SENDGRID_APIKEY=your-sendgrid-api-key
3131
3232
php -S localhost:8000 -t .
3333
```

appengine/flexible/sendgrid/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$sendgridApiKey = $app['sendgrid.api_key'];
3939
$sendgridRecipient = $request->get('recipient');
4040
# [START send_mail]
41-
// $sendgridApiKey = 'YOUR_SENDGRID_API_KEY';
41+
// $sendgridApiKey = 'YOUR_SENDGRID_APIKEY';
4242
// $sendgridSender = '[email protected]';
4343
// $sendgridRecipient = '[email protected]';
4444
$sender = new SendGrid\Email(null, $sendgridSender);

appengine/flexible/sendgrid/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ runtime_config:
66

77
# [START env_variables]
88
env_variables:
9-
SENDGRID_API_KEY: your-sendgrid-api-key
9+
SENDGRID_APIKEY: your-sendgrid-api-key
1010
SENDGRID_SENDER: your-sendgrid-sender
1111
# [END env_variables]

appengine/flexible/sendgrid/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$app = require __DIR__ . '/app.php';
2323

2424
$app['sendgrid.sender'] = getenv('SENDGRID_SENDER');
25-
$app['sendgrid.api_key'] = getenv('SENDGRID_API_KEY');
25+
$app['sendgrid.api_key'] = getenv('SENDGRID_APIKEY');
2626

2727
// Run the app!
2828
// use "gcloud app deploy" or run "php -S localhost:8000"

appengine/flexible/sendgrid/test/DeployTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public function beforeDeploy()
3131
chdir($tmpDir);
3232

3333
$appYaml = Yaml::parse(file_get_contents('app.yaml'));
34-
$appYaml['env_variables']['SENDGRID_API_KEY'] =
35-
getenv('SENDGRID_API_KEY');
34+
$appYaml['env_variables']['SENDGRID_APIKEY'] =
35+
getenv('SENDGRID_APIKEY');
3636
$appYaml['env_variables']['SENDGRID_SENDER'] =
3737
getenv('SENDGRID_SENDER');
3838
file_put_contents('app.yaml', Yaml::dump($appYaml));

appengine/flexible/sendgrid/test/LocalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public function createApplication()
2727
$app['debug'] = true;
2828

2929
$app['sendgrid.sender'] = getenv('SENDGRID_SENDER');
30-
$app['sendgrid.api_key'] = getenv('SENDGRID_API_KEY');
30+
$app['sendgrid.api_key'] = getenv('SENDGRID_APIKEY');
3131

3232
if (empty($app['sendgrid.sender']) || empty($app['sendgrid.api_key'])) {
3333
$this->markTestSkipped(
34-
'set the SENDGRID_SENDER and SENDGRID_API_KEY' .
34+
'set the SENDGRID_SENDER and SENDGRID_APIKEY ' .
3535
'environment variables'
3636
);
3737
}

appengine/flexible/storage/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ Before running this sample:
3232

3333
## Run Locally
3434

35-
Set the environment variables `GOOGLE_BUCKET_NAME` and `GCLOUD_PROJECT` to the name of your storage bucket and project ID respectively.
35+
Set the environment variables `GOOGLE_STORAGE_BUCKET` and `GCLOUD_PROJECT` to the name of your storage bucket and project ID respectively.
3636

3737
```
38-
export GOOGLE_BUCKET_NAME=your-bucket-name
38+
export GOOGLE_STORAGE_BUCKET=your-bucket-name
3939
export GCLOUD_PROJECT=your-project-id
4040
```
4141

appengine/flexible/storage/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ runtime_config:
66

77
# [START env_variables]
88
env_variables:
9-
GOOGLE_BUCKET_NAME: "your-bucket-name"
9+
GOOGLE_STORAGE_BUCKET: "your-bucket-name"
1010
# [END env_variables]
1111

appengine/flexible/storage/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$app = require __DIR__ . '/app.php';
2323

2424
// change this to your bucket name!
25-
$app['bucket_name'] = getenv('GOOGLE_BUCKET_NAME') ?: 'your-bucket-name';
25+
$app['bucket_name'] = getenv('GOOGLE_STORAGE_BUCKET') ?: 'your-bucket-name';
2626
$app['project_id'] = getenv('GCLOUD_PROJECT');
2727
$app['object_name'] = 'hello.txt';
2828

appengine/flexible/storage/test/LocalTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function setUp()
2323
if (!getenv('GOOGLE_PROJECT_ID')) {
2424
$this->markTestSkipped('Must set GOOGLE_PROJECT_ID');
2525
}
26-
if (!getenv('GOOGLE_BUCKET_NAME')) {
27-
$this->markTestSkipped('Must set GOOGLE_BUCKET_NAME');
26+
if (!getenv('GOOGLE_STORAGE_BUCKET')) {
27+
$this->markTestSkipped('Must set GOOGLE_STORAGE_BUCKET');
2828
}
2929
parent::setUp();
3030
$this->client = $this->createClient();
@@ -43,8 +43,8 @@ public function createApplication()
4343

4444
// the bucket name doesn't matter because we mock the stream wrapper
4545
$app['project_id'] = getenv('GOOGLE_PROJECT_ID');
46-
$app['bucket_name'] = getenv('GOOGLE_BUCKET_NAME');
47-
$app['object_name'] = 'hello_flex.txt';
46+
$app['bucket_name'] = getenv('GOOGLE_STORAGE_BUCKET');
47+
$app['object_name'] = 'appengine/hello_flex.txt';
4848

4949
return $app;
5050
}

0 commit comments

Comments
 (0)