Skip to content

Commit 7c8821e

Browse files
authored
Merge branch 'master' into automl
2 parents cce984c + 6a48e3e commit 7c8821e

File tree

693 files changed

+19369
-6890
lines changed

Some content is hidden

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

693 files changed

+19369
-6890
lines changed

.github/snippet-bot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ credentials.*
1010
.php_cs.cache
1111
.vscode/
1212
.kokoro/secrets.sh
13+
.phpunit.result.cache

.kokoro/docker/php73/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ RUN ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a && \
9898
php -r "if (hash_file('SHA384', 'composer-setup.php') === rtrim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
9999
php composer-setup.php --filename=composer --install-dir=/usr/local/bin
100100

101+
# Install phpunit globally
102+
RUN composer global require phpunit/phpunit:^7.0
103+
101104
# Install Google Cloud SDK
102105
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz \
103106
-o ${HOME}/google-cloud-sdk.tar.gz \
@@ -108,7 +111,7 @@ RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz \
108111
--command-completion false
109112

110113
# Make composer and gcloud bins available via the PATH variable
111-
ENV PATH="$PATH:/root/google-cloud-sdk/bin:/root/.composer/vendor/bin"
114+
ENV PATH="$PATH:/root/.composer/vendor/bin:/root/google-cloud-sdk/bin"
112115

113116
# Configure Google Cloud SDK
114117
RUN gcloud config set app/promote_by_default false && \
@@ -117,3 +120,5 @@ RUN gcloud config set app/promote_by_default false && \
117120
gcloud -q components install app-engine-php && \
118121
gcloud -q components update
119122

123+
# Build php-cs-fixer
124+
RUN composer global require friendsofphp/php-cs-fixer

.kokoro/docker/php74/Dockerfile

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
FROM gcr.io/gcp-runtimes/ubuntu_16_0_4
2+
ENV PHP_DIR=/opt/php74
3+
ENV PHP_SRC_DIR=/usr/local/src/php74-build
4+
ENV PATH=${PATH}:/usr/local/bin:${PHP_DIR}/bin
5+
6+
RUN apt-get update && \
7+
apt-get -y install \
8+
autoconf \
9+
build-essential \
10+
git-core \
11+
jq \
12+
libbz2-dev \
13+
libcurl4-openssl-dev \
14+
libc-client2007e \
15+
libc-client2007e-dev \
16+
libfcgi-dev \
17+
libfcgi0ldbl \
18+
libfreetype6-dev \
19+
libicu-dev \
20+
libjpeg62-dbg \
21+
libjpeg-dev \
22+
libkrb5-dev \
23+
libmcrypt-dev \
24+
libpng12-dev \
25+
libpq-dev \
26+
libssl-dev \
27+
libxml2-dev \
28+
libxslt1-dev \
29+
libzip-dev \
30+
python-ipaddr \
31+
wget \
32+
zip \
33+
zlib1g-dev \
34+
pkg-config \
35+
sqlite3 \
36+
libsqlite3-dev \
37+
libonig-dev \
38+
php-pear
39+
40+
RUN ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a && \
41+
mkdir -p ${PHP_DIR} ${PHP_SRC_DIR} ${PHP_DIR}/lib/conf.d && \
42+
cd ${PHP_SRC_DIR} && \
43+
wget http://us1.php.net/get/php-7.4.0.tar.bz2/from/this/mirror \
44+
-O php-7.4.0.tar.bz2 && \
45+
tar jxf php-7.4.0.tar.bz2 && \
46+
cd php-7.4.0 && \
47+
./configure \
48+
--prefix=${PHP_DIR} \
49+
--with-config-file-scan-dir=${PHP_DIR}/lib/conf.d \
50+
--with-pdo-pgsql \
51+
--with-zlib-dir \
52+
--enable-mbstring \
53+
--enable-soap \
54+
--enable-intl \
55+
--enable-calendar \
56+
--with-curl \
57+
--with-zlib \
58+
--with-pgsql \
59+
--disable-rpath \
60+
--enable-inline-optimization \
61+
--with-bz2 \
62+
--with-zlib \
63+
--enable-sockets \
64+
--enable-sysvsem \
65+
--enable-sysvshm \
66+
--enable-sysvmsg \
67+
--enable-pcntl \
68+
--enable-mbregex \
69+
--enable-exif \
70+
--enable-bcmath \
71+
--with-mhash \
72+
--with-pdo-mysql \
73+
--with-mysqli \
74+
--with-openssl \
75+
--with-fpm-user=www-data \
76+
--with-fpm-group=www-data \
77+
--with-libdir=/lib/x86_64-linux-gnu \
78+
--enable-ftp \
79+
--with-imap \
80+
--with-imap-ssl \
81+
--with-gettext \
82+
--with-xmlrpc \
83+
--with-xsl \
84+
--with-zip \
85+
--with-kerberos \
86+
--enable-fpm && \
87+
make && \
88+
make install && \
89+
pecl install grpc && \
90+
cp php.ini-production ${PHP_DIR}/lib/php.ini && \
91+
echo 'zend_extension=opcache.so' >> ${PHP_DIR}/lib/php.ini && \
92+
echo 'extension=grpc.so' >> ${PHP_DIR}/lib/conf.d/ext-grpc.ini && \
93+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
94+
php -r "if (hash_file('SHA384', 'composer-setup.php') === rtrim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
95+
php composer-setup.php --filename=composer --install-dir=/usr/local/bin
96+
97+
# Remove old version of PHP
98+
RUN apt purge -y php7.0-common
99+
100+
# Install phpunit globally
101+
RUN composer global require phpunit/phpunit:^7.0
102+
103+
# Install Google Cloud SDK
104+
RUN curl https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz \
105+
-o ${HOME}/google-cloud-sdk.tar.gz \
106+
&& tar xzf ${HOME}/google-cloud-sdk.tar.gz -C $HOME \
107+
&& ${HOME}/google-cloud-sdk/install.sh \
108+
--usage-reporting false \
109+
--path-update false \
110+
--command-completion false
111+
112+
# Make composer and gcloud bins available via the PATH variable
113+
ENV PATH="$PATH:/root/.composer/vendor/bin:/root/google-cloud-sdk/bin"
114+
115+
# Configure Google Cloud SDK
116+
RUN gcloud config set app/promote_by_default false && \
117+
gcloud config set disable_prompts true && \
118+
gcloud -q components install app-engine-python && \
119+
gcloud -q components update
120+
121+
# Build php-cs-fixer
122+
RUN composer global require friendsofphp/php-cs-fixer

.kokoro/php73.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ env_vars: {
1515
key: "GOOGLE_ALT_CREDENTIALS_FILENAME"
1616
value: "service-account-kokoro3.json"
1717
}
18-
env_vars: {
19-
key: "RUN_CS_CHECK"
20-
value: "true"
21-
}

.kokoro/php71.cfg renamed to .kokoro/php74.cfg

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Configure the docker image for kokoro-trampoline.
44
env_vars: {
55
key: "TRAMPOLINE_IMAGE"
6-
value: "gcr.io/cloud-devrel-kokoro-resources/php71"
6+
value: "gcr.io/cloud-devrel-kokoro-resources/php74"
77
}
88

99
# Give the docker image a unique project ID and credentials per PHP version
@@ -15,3 +15,7 @@ env_vars: {
1515
key: "GOOGLE_ALT_CREDENTIALS_FILENAME"
1616
value: "service-account-kokoro1.json"
1717
}
18+
env_vars: {
19+
key: "RUN_CS_CHECK"
20+
value: "true"
21+
}

.kokoro/secrets-example.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/bin/bash
22

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-
################################################################################
3+
# This file contains the necessary environment variables for the kokoro
4+
# tests. Contact the repository owners if you need access to view or modify
5+
# the variables.
6+
#
7+
# Run the following gcloud command to decrypt secrets.sh.enc as follows:
8+
#
9+
# gcloud kms decrypt --location=global --keyring=ci --key=ci \
10+
# --ciphertext-file=.kokoro/secrets.sh.enc \
11+
# --plaintext-file=.kokoro/secrets.sh
12+
#
13+
# Then run `source .kokoro/secrets.sh`
14+
#
15+
# To modify the file, edit .kokoro/secrets.sh then use the following gcloud
16+
# command to encrypt it with the changes:
17+
#
18+
# gcloud kms encrypt --location=global --keyring=ci --key=ci \
19+
# --ciphertext-file=.kokoro/secrets.sh.enc \
20+
# --plaintext-file=.kokoro/secrets.sh
1221

1322
# General
1423
export GOOGLE_PROJECT_ID=
@@ -57,8 +66,6 @@ export CLOUD_DATASTORE_NAMESPACE=
5766
export DATASTORE_EVENTUALLY_CONSISTENT_RETRY_COUNT=
5867

5968
# DLP
60-
export DLP_TOPIC=dlp-tests
61-
export DLP_SUBSCRIPTION=dlp-tests
6269
export DLP_DEID_WRAPPED_KEY=
6370
export DLP_DEID_KEY_NAME=projects/$GOOGLE_PROJECT_ID/locations/global/keyRings/ci/cryptoKeys/ci
6471

@@ -91,6 +98,10 @@ export REDIS_PORT=
9198
export GOOGLE_PUBSUB_SUBSCRIPTION=php-example-subscription
9299
export GOOGLE_PUBSUB_TOPIC=php-example-topic
93100

101+
# Security Center
102+
export GOOGLE_ORGANIZATION_ID=
103+
export GOOGLE_SECURITYCENTER_PUBSUB_TOPIC=
104+
94105
# Spanner
95106
export GOOGLE_SPANNER_INSTANCE_ID=
96107
export GOOGLE_SPANNER_DATABASE_ID=test-database

.kokoro/secrets.sh.enc

94 Bytes
Binary file not shown.

.kokoro/system_tests.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ export PULL_REQUEST_NUMBER=$KOKORO_GITHUB_PULL_REQUEST_NUMBER
5252

5353
# Run code standards check when appropriate
5454
if [ "${RUN_CS_CHECK}" = "true" ]; then
55-
curl -L https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o php-cs-fixer \
56-
&& chmod a+x php-cs-fixer
5755
bash testing/run_cs_check.sh
5856
fi
5957

@@ -64,7 +62,7 @@ if [ "${RUN_REST_TESTS_ONLY}" = "true" ]; then
6462
fi
6563

6664
# Install global test dependencies
67-
bash testing/composer.sh
65+
composer install -d testing/
6866

6967
# Run tests
7068
bash testing/run_test_suite.sh

.php_cs.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ return PhpCsFixer\Config::create()
1010
'method_argument_space' => [
1111
'keep_multiple_spaces_after_comma' => true
1212
],
13+
'return_type_declaration' => [
14+
'space_before' => 'none'
15+
],
1316
])
1417
->setFinder(
1518
PhpCsFixer\Finder::create()

CODEOWNERS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Code owners file.
2+
# This file controls who is tagged for review for any given pull request.
3+
#
4+
# For syntax help see:
5+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6+
7+
8+
# The php-admins team is the default owner for anything not
9+
# explicitly taken by someone else.
10+
* @GoogleCloudPlatform/php-admins
11+
12+
/bigtable/ @GoogleCloudPlatform/bigtable-dpe @GoogleCloudPlatform/php-admins
13+
/cloud_sql/ @GoogleCloudPlatform/cloud-sql-dpes @GoogleCloudPlatform/php-admins
14+
/datastore/ @GoogleCloudPlatform/firestore-dpe @GoogleCloudPlatform/php-admins
15+
/firestore/ @GoogleCloudPlatform/firestore-dpe @GoogleCloudPlatform/php-admins
16+
/storage/ @GoogleCloudPlatform/storage-dpe @GoogleCloudPlatform/php-admins

CONTRIBUTING.md

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,86 @@ accept your pull requests.
2121

2222
## Contributing A Patch
2323

24-
1. Submit an issue describing your proposed change to the repo in question.
24+
1. Submit an issue describing your proposed change.
2525
1. The repo owner will respond to your issue promptly.
2626
1. If your proposed change is accepted, and you haven't already done so, sign a
2727
Contributor License Agreement (see details above).
28-
1. Fork the desired repo, develop and test your code changes.
29-
30-
Install dependencies via [Composer](http://getcomposer.org/doc/00-intro.md).
31-
Run `composer install` (if composer is installed globally).
32-
33-
To run the tests, first set up [application default
34-
credentials](https://cloud.google.com/docs/authentication/getting-started)
35-
by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the
36-
path to a service account key JSON file.
37-
38-
Then set any environment variables needed by the test. Check the
39-
`$SAMPLES_DIRECTORY/test` directory to see what specific variables are needed.
40-
```
41-
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
42-
export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
43-
```
44-
45-
To run the tests in a samples directory, first install the global Composer
46-
dependencies by running `bash test/composer.sh`. Then, run `composer install`
47-
and `phpunit` in any directory containing a `phpunit.xml.dist` file to run
48-
the tests.
49-
```
50-
bash test/composer.sh
51-
cd $SAMPLES_DIRECTORY
52-
composer install
53-
phpunit
54-
```
55-
28+
1. Fork this repo, develop and test your code changes.
5629
1. Ensure that your code adheres to the existing style in the sample to which
5730
you are contributing.
5831
1. Ensure that your code has an appropriate set of unit tests which all pass.
59-
Set up [Travis](./TRAVIS.md) to run the unit tests on your fork.
6032
1. Submit a pull request.
6133

34+
## Testing your code changes.
35+
36+
### Install dependencies
37+
38+
To run the tests in a samples directory, you will need to install
39+
[Composer](http://getcomposer.org/doc/00-intro.md).
40+
41+
First install the testing dependencies which are shared across all samples:
42+
43+
```
44+
composer install -d testing/
45+
```
46+
47+
Next, install the dependencies for the individual sample you're testing:
48+
49+
```
50+
SAMPLES_DIRECTORY=translate
51+
cd $SAMPLES_DIRECTORY
52+
composer install
53+
```
54+
55+
### Environment variables
56+
Set up [application default credentials](https://cloud.google.com/docs/authentication/getting-started)
57+
by setting the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the path to a service
58+
account key JSON file.
59+
60+
Then set any environment variables needed by the test. Check the
61+
`$SAMPLES_DIRECTORY/test` directory to see what specific variables are needed.
62+
```
63+
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
64+
export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
65+
```
66+
67+
If your tests require new environment variables, you can set them up in
68+
[.kokoro/secrets.sh.enc](.kokoro/secrets.sh.enc). For instructions on managing those variables,
69+
view [.kokoro/secrets-example.sh](.kokoro/secrets-example.sh) for more information.
70+
71+
### Run the tests
72+
73+
Once the dependencies are installed and the environment variables set, you can run the
74+
tests in a samples directory.
75+
```
76+
cd $SAMPLES_DIRECTORY
77+
# Execute the "phpunit" installed for the shared dependencies
78+
PATH_TO_REPO=/path/to/php-docs-samples
79+
$PATH_TO_REPO/testing/vendor/bin/phpunit
80+
```
81+
82+
Use `phpunit -v` to get a more detailed output if there are errors.
83+
6284
## Style
6385

6486
Samples in this repository follow the [PSR2][psr2] and [PSR4][psr4]
6587
recommendations. This is enforced using [PHP CS Fixer][php-cs-fixer].
6688

89+
Install that by running
90+
91+
```
92+
composer global require friendsofphp/php-cs-fixer
93+
```
94+
95+
Then to fix your directory or file run
96+
97+
```
98+
php-cs-fixer fix .
99+
php-cs-fixer fix path/to/file
100+
```
101+
102+
The [DLP snippets](https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/dlp) are an example of snippets following the latest style guidelines.
103+
67104
[psr2]: http://www.php-fig.org/psr/psr-2/
68105
[psr4]: http://www.php-fig.org/psr/psr-4/
69106
[php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer

0 commit comments

Comments
 (0)