Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#526 from paumas/php-7.4
Browse files Browse the repository at this point in the history
Adding version 7.4.12
  • Loading branch information
donmccasland authored Dec 1, 2020
2 parents 8bde890 + 3f7b1ba commit a255902
Show file tree
Hide file tree
Showing 89 changed files with 2,117 additions and 35 deletions.
18 changes: 13 additions & 5 deletions builder/gen-dockerfile/src/Builder/GenFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ protected function configure()
$this
->setName('create')
->setDescription('Create Dockerfile and .dockerignore file')
->addOption(
'php74-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 74 base image of the Dockerfile'
)
->addOption(
'php73-image',
null,
Expand Down Expand Up @@ -111,17 +117,17 @@ protected function initialize(InputInterface $input, OutputInterface $output)
$output->writeln("<info>
There is no PHP runtime version specified in composer.json, or
we don't support the version you specified. Google App Engine
uses the latest 7.3.x version.
uses the latest 7.4.x version.
We recommend pinning your PHP version by running:
composer require php 7.3.* (replace it with your desired minor version)
composer require php 7.4.* (replace it with your desired minor version)
Using PHP version 7.3.x...</info>
Using PHP version 7.4.x...</info>
");
} elseif ($version === DetectPhpVersion::EXACT_VERSION_SPECIFIED) {
throw new ExactVersionException(
"An exact PHP version was specified in composer.json. Please pin your" .
"PHP version to a minor version such as '7.3.*'."
"PHP version to a minor version such as '7.4.*'."
);
}
if (substr($version, 0, 3) === '5.6') {
Expand All @@ -132,8 +138,10 @@ protected function initialize(InputInterface $input, OutputInterface $output)
$this->detectedPhpVersion = '7.1';
} elseif (substr($version, 0, 3) === '7.2') {
$this->detectedPhpVersion = '7.2';
} else {
} elseif (substr($version, 0, 3) === '7.3') {
$this->detectedPhpVersion = '7.3';
} else {
$this->detectedPhpVersion = '7.4';
}
$yamlPath = getenv('GAE_APPLICATION_YAML_PATH')
?: self::DEFAULT_YAML_PATH;
Expand Down
1 change: 1 addition & 0 deletions builder/gen-dockerfile/src/DetectPhpVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static function isExactVersion($constraint)
private static function detectAvailableVersions()
{
return [
trim(file_get_contents('/opt/php74_version')),
trim(file_get_contents('/opt/php73_version')),
trim(file_get_contents('/opt/php72_version')),
trim(file_get_contents('/opt/php71_version')),
Expand Down
47 changes: 31 additions & 16 deletions builder/gen-dockerfile/tests/GenFilesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function testGenFilesCommand(
'--php71-image' => 'gcr.io/google-appengine/php71:latest',
'--php72-image' => 'gcr.io/google-appengine/php72:latest',
'--php73-image' => 'gcr.io/google-appengine/php73:latest',
'--php74-image' => 'gcr.io/google-appengine/php74:latest',
];
}
if ($expectedException !== null) {
Expand Down Expand Up @@ -131,10 +132,10 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.3' \n"
"DETECTED_PHP_VERSION='7.4' \n"
]
],
[
Expand All @@ -144,11 +145,11 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"SKIP_LOCKDOWN_DOCUMENT_ROOT='true' \\\n",
"DETECTED_PHP_VERSION='7.3' \n"
"DETECTED_PHP_VERSION='7.4' \n"
]
],
[
Expand All @@ -169,10 +170,10 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
["COMPOSER_FLAGS='--prefer-dist --no-dev --no-script' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.3' \n"
"DETECTED_PHP_VERSION='7.4' \n"
]
],
[
Expand Down Expand Up @@ -212,14 +213,27 @@ public function dataProvider()
"DETECTED_PHP_VERSION='7.3' \n"
]
],
[
// PHP 7.4
__DIR__ . '/test_data/php74',
null,
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php74:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.4' \n"
]
],
[
// values on env_variables
__DIR__ . '/test_data/values_only_on_env',
null,
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
[
"WHITELIST_FUNCTIONS='exec' \\\n",
"FRONT_CONTROLLER_FILE='app.php'",
Expand All @@ -239,7 +253,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\MissingDocumentRootException'
],
Expand All @@ -250,7 +264,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
[
"WHITELIST_FUNCTIONS='exec' \\\n",
"FRONT_CONTROLLER_FILE='app.php'",
Expand All @@ -271,7 +285,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
["FRONT_CONTROLLER_FILE='app.php' \\\n"]
],
[
Expand All @@ -281,7 +295,7 @@ public function dataProvider()
'my.yaml',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest'
'gcr.io/google-appengine/php74:latest'
],
[
// Overrides baseImage
Expand All @@ -292,11 +306,12 @@ public function dataProvider()
'--php71-image' => 'gcr.io/php-mvm-a-28051/php71:latest',
'--php72-image' => 'gcr.io/php-mvm-a-28051/php72:latest',
'--php73-image' => 'gcr.io/php-mvm-a-28051/php73:latest',
'--php74-image' => 'gcr.io/php-mvm-a-28051/php74:latest',
],
'',
'/app',
'added by the php runtime builder',
'gcr.io/php-mvm-a-28051/php73:latest'
'gcr.io/php-mvm-a-28051/php74:latest'
],
[
// Has document_root set
Expand All @@ -305,7 +320,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest'
'gcr.io/google-appengine/php74:latest'
],
[
// Has document_root set in env_variables
Expand All @@ -314,7 +329,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest'
'gcr.io/google-appengine/php74:latest'
],
[
// document_root in both will throw exception
Expand All @@ -323,7 +338,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\EnvConflictException'
],
Expand All @@ -343,7 +358,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php73:latest',
'gcr.io/google-appengine/php74:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\ExactVersionException'
]
Expand Down
5 changes: 5 additions & 0 deletions builder/gen-dockerfile/tests/test_data/php74/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env: flex
runtime: php

runtime_config:
document_root: /app
5 changes: 5 additions & 0 deletions builder/gen-dockerfile/tests/test_data/php74/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "7.4.*"
}
}
2 changes: 1 addition & 1 deletion builder/php-latest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steps:
- name: 'gcr.io/gcp-runtimes/php/gen-dockerfile:latest'
args: ['--php73-image', 'gcr.io/google-appengine/php73:latest', '--php72-image', 'gcr.io/google-appengine/php72:latest', '--php71-image', 'gcr.io/google-appengine/php71:latest', '--php70-image', 'gcr.io/google-appengine/php70:latest', '--php56-image', 'gcr.io/google-appengine/php56:latest']
args: ['--php74-image', 'gcr.io/google-appengine/php74:latest', '--php73-image', 'gcr.io/google-appengine/php73:latest', '--php72-image', 'gcr.io/google-appengine/php72:latest', '--php71-image', 'gcr.io/google-appengine/php71:latest', '--php70-image', 'gcr.io/google-appengine/php70:latest', '--php56-image', 'gcr.io/google-appengine/php56:latest']
env: 'GAE_APPLICATION_YAML_PATH=$_GAE_APPLICATION_YAML_PATH'
- name: 'gcr.io/kaniko-project/executor:v0.6.0'
args: ['--destination=$_OUTPUT_IMAGE']
Expand Down
19 changes: 19 additions & 0 deletions check-versions/tests/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public static function setUpBeforeClass()
'Failed to detect the latest PHP73 version';
}

$pattern = '/PHP (7\.4\.\d+)/';
if (preg_match($pattern, $body, $matches)) {
self::$versions['php74'] = $matches[1];
} else {
self::$versions['php74'] =
'Failed to detect the latest PHP74 version';
}

exec('apt-get update');
}

Expand All @@ -69,4 +77,15 @@ public function testPHP73Version()
$this->fail('Failed to detect the current php73 version');
}
}

public function testPHP74Version()
{
$output = exec('apt-cache madison gcp-php74');
$pattern = '/(7\.4\.\d+)/';
if (preg_match($pattern, $output, $matches)) {
$this->assertEquals($matches[1], self::$versions['php74']);
} else {
$this->fail('Failed to detect the current php74 version');
}
}
}
55 changes: 55 additions & 0 deletions cloudbuild-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ steps:
waitFor: ['php-base']
id: php-base-structure

# php74
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74:$_TAG', '--build-arg', 'PHP_VERSION=7.4', '.']
dir: php-versioned
waitFor: ['php-base']
id: php74
- name: gcr.io/gcp-runtimes/structure_test
args: ['-i', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74:$_TAG', '--config', '/workspace/php-versioned/php74.yaml', '-v']
waitFor: ['php74']
id: php74-structure

# php73
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php73:$_TAG', '--build-arg', 'PHP_VERSION=7.3', '.']
Expand Down Expand Up @@ -126,6 +137,24 @@ steps:
waitFor: ['php71-custom-app', 'test-runner']
id: php71-custom-test

# php74-custom test
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-custom:$_TAG', '.']
dir: testapps/php74_custom
waitFor: ['php-onbuild']
id: php74-custom-build
- name: gcr.io/gcp-runtimes/structure_test
args: ['-i', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-custom:$_TAG', '--config', 'php74.yaml', '-v']
waitFor: ['php74-custom-build']
- name: gcr.io/cloud-builders/docker
args: ['run', '--net=nw_$_TAG', '--name=php74-custom', '-d', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-custom:$_TAG']
waitFor: ['php74-custom-build', 'test-network']
id: php74-custom-app
- name: gcr.io/cloud-builders/docker
args: ['run', '--net=nw_$_TAG','-v', '/workspace:/workspace', 'gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG', '/workspace/testapps/php74_custom/tests']
waitFor: ['php74-custom-app', 'test-runner']
id: php74-custom-test

# php73-custom test
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php73-custom:$_TAG', '.']
Expand Down Expand Up @@ -222,9 +251,35 @@ steps:
waitFor: ['php73-extensions-build']
id: php73-extensions-legacy-test

# php74-extensions test
- name: gcr.io/cloud-builders/docker
args: [ 'build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-extensions:$_TAG', '.' ]
dir: testapps/php74_extensions
waitFor: [ 'php-onbuild' ]
id: php74-extensions-build
- name: gcr.io/cloud-builders/docker
args: [ 'run', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-extensions:$_TAG', 'vendor/bin/phpunit' ]
dir: testapps/php74_extensions
waitFor: [ 'php74-extensions-build' ]
id: php74-extensions-test

# php74-extensions-legacy test
- name: gcr.io/cloud-builders/docker
args: [ 'build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-extensions:$_TAG', '.' ]
dir: testapps/php74_extensions_legacy
waitFor: [ 'php-onbuild' ]
id: php74-extensions-legacy-build
- name: gcr.io/cloud-builders/docker
args: [ 'run', 'gcr.io/${_GOOGLE_PROJECT_ID}/php74-extensions:$_TAG', 'vendor/bin/phpunit' ]
dir: testapps/php74_extensions_legacy
waitFor: [ 'php74-extensions-build' ]
id: php74-extensions-legacy-test


images:
- gcr.io/${_GOOGLE_PROJECT_ID}/php-base:$_TAG
- gcr.io/${_GOOGLE_PROJECT_ID}/php:$_TAG
- gcr.io/${_GOOGLE_PROJECT_ID}/php74:$_TAG
- gcr.io/${_GOOGLE_PROJECT_ID}/php73:$_TAG
- gcr.io/${_GOOGLE_PROJECT_ID}/php72:$_TAG
- gcr.io/${_GOOGLE_PROJECT_ID}/php71:$_TAG
Expand Down
11 changes: 11 additions & 0 deletions integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ steps:
waitFor: ['-']
id: test-runner

# php74_e2e test
- name: gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG
args: ['/workspace/testapps/php74_e2e/tests']
waitFor: ['test-runner']
id: php74_e2e
env:
- 'SERVICE_ACCOUNT_JSON=${_SERVICE_ACCOUNT_JSON}'
- 'TAG=${_TAG}-e2e'
- 'E2E_PROJECT_ID=${_E2E_PROJECT_ID}'
- 'TEST_VM_IMAGE=${_TEST_VM_IMAGE}'

# php73_e2e test
- name: gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG
args: ['/workspace/testapps/php73_e2e/tests']
Expand Down
Empty file.
Loading

0 comments on commit a255902

Please sign in to comment.