Skip to content

Commit

Permalink
Archive the PHPUnit related containers. (#160)
Browse files Browse the repository at this point in the history
The need for the `phpunit` containers was removed in WordPress 5.9 and only exist for running tests in old branches.

The highest version of PHP that these versions of WordPress support is PHP 8.0 required a modified version of PHPUnit 7 (see [Core-50902](https://core.trac.wordpress.org/ticket/50902)). PHPUnit 7.x is no longer supported upstream, so there will be no new releases.

With all this in mind, this removes the PHPUnit related containers from the workflow files to avoid needlessly building and publishing them. The images are being left in tact within the `images` directory in case they need to be regenerated at some point in the future.

Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: johnbillion <johnbillion@git.wordpress.org>
  • Loading branch information
3 people authored Dec 5, 2024
1 parent e23d5b0 commit bf6b42c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 240 deletions.
63 changes: 0 additions & 63 deletions .github/workflows/docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,69 +73,6 @@ jobs:
docker images
docker push $PACKAGE_REGISTRY/php:latest$PR_TAG
build-phpunit-images:
name: PHPUnit on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]

env:
PHP_VERSION: ${{ matrix.php }}
PHP_LATEST: '8.2'

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin
- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG images/$PHP_VERSION/phpunit

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG

- name: Tag and push image as latest
if: ${{ env.PHP_LATEST == env.PHP_VERSION }}
run: |
docker image tag $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG $PACKAGE_REGISTRY/phpunit:latest$PR_TAG
docker push $PACKAGE_REGISTRY/phpunit:latest$PR_TAG
build-specific-phpunit-images:
name: PHPUnit ${{ matrix.phpunit }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
phpunit: [ '8-php-7.2', '7-php-7.2', '6-php-7.2', '9-php-7.3', '8-php-7.3', '7-php-7.3', '6-php-7.3', '9-php-7.4', '8-php-7.4', '7-php-7.4', '9-php-8.0', '8-php-8.0', '9-php-8.1', '8-php-8.1', '9-php-8.2', '8-php-8.2', '9-php-8.3' ]

env:
PHPUNIT_VERSION: ${{ matrix.phpunit }}

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin
- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG images/phpunit/$PHPUNIT_VERSION

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG

build-cli-images:
name: CLI on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
Expand Down
63 changes: 0 additions & 63 deletions .github/workflows/github-container-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,69 +82,6 @@ jobs:
docker images
docker push $PACKAGE_REGISTRY/php:latest$PR_TAG
build-phpunit-images:
name: PHPUnit on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]

env:
PHP_VERSION: ${{ matrix.php }}
PHP_LATEST: '8.2'

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin
- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG images/$PHP_VERSION/phpunit

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG

- name: Tag and push image as latest
if: ${{ env.PHP_LATEST == env.PHP_VERSION }}
run: |
docker image tag $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG $PACKAGE_REGISTRY/phpunit:latest$PR_TAG
docker push $PACKAGE_REGISTRY/phpunit:latest$PR_TAG
build-specific-phpunit-images:
name: PHPUnit ${{ matrix.phpunit }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
phpunit: [ '8-php-7.2', '7-php-7.2', '6-php-7.2', '9-php-7.3', '8-php-7.3', '7-php-7.3', '6-php-7.3', '9-php-7.4', '8-php-7.4', '7-php-7.4', '9-php-8.0', '8-php-8.0', '9-php-8.1', '8-php-8.1', '9-php-8.2', '8-php-8.2', '9-php-8.3' ]

env:
PHPUNIT_VERSION: ${{ matrix.phpunit }}

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin
- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG images/phpunit/$PHPUNIT_VERSION

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG

build-cli-images:
name: CLI on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
Expand Down
63 changes: 0 additions & 63 deletions templates/workflow.yml-template
Original file line number Diff line number Diff line change
Expand Up @@ -100,69 +100,6 @@ jobs:
docker images
docker push $PACKAGE_REGISTRY/php:latest$PR_TAG

build-phpunit-images:
name: PHPUnit on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
php: [ %%PHP_VERSION_LIST%% ]

env:
PHP_VERSION: ${{ matrix.php }}
PHP_LATEST: '%%PHP_LATEST%%'

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin

- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG images/$PHP_VERSION/phpunit

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG

- name: Tag and push image as latest
if: ${{ env.PHP_LATEST == env.PHP_VERSION }}
run: |
docker image tag $PACKAGE_REGISTRY/phpunit:$PHP_VERSION-fpm$PR_TAG $PACKAGE_REGISTRY/phpunit:latest$PR_TAG
docker push $PACKAGE_REGISTRY/phpunit:latest$PR_TAG

build-specific-phpunit-images:
name: PHPUnit ${{ matrix.phpunit }}
runs-on: ubuntu-latest
needs: build-php-images
strategy:
matrix:
phpunit: [ %%PHPUNIT_COMBINATIONS%% ]

env:
PHPUNIT_VERSION: ${{ matrix.phpunit }}

steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin

- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG images/phpunit/$PHPUNIT_VERSION

- name: Log Docker images
run: docker images

- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/phpunit:$PHPUNIT_VERSION-fpm$PR_TAG

build-cli-images:
name: CLI on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
Expand Down
56 changes: 5 additions & 51 deletions update.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,12 @@
* Different WordPress versions support different versions of PHP and different versions of PHPUnit.
* This creates a need to run multiple versions of PHPUnit on each version of PHP.
*
* @param array $phpunit_version A list of PHP versions for each PHPUnit version.
* These versions of PHPUnit are no longer supported and do not receive updates.
* Regenerating these containers should very rarely be required.
*
* @param array $legacy_phpunit_versions A list of PHP versions for each PHPUnit version.
*/
$phpunit_versions = array(
$legacy_phpunit_versions = array(
'9' => array(
'8.3',
'8.2',
Expand Down Expand Up @@ -342,8 +345,6 @@
'cli' => file_get_contents( 'templates/Dockerfile-cli.template' ),
);

$phpunit_combinations = array();

// Loop through each PHP version, and generate the Dockerfiles.
foreach ( array_merge( $legacy_php_versions, $php_versions ) as $version => $images ) {
$title = "| PHP $version |";
Expand Down Expand Up @@ -500,50 +501,6 @@
echo "\n";
}

foreach ( $phpunit_versions as $phpunit_version => $supported_php_versions ) {
if ( in_array( $version, $supported_php_versions, true ) ) {
echo str_pad( "phpunit $phpunit_version", 15, '.' );

$php_version = $version;

if ( ! isset( $legacy_php_versions[ $php_version ] ) ) {
$phpunit_combinations[] = "{$phpunit_version}-php-{$php_version}";
}
echo shell_exec( "mkdir -p images/phpunit/{$phpunit_version}-php-{$php_version}" );

$dockerfile = $templates['phpunit'];

// Ensure PHPUnit can be successfully downloaded in older containers.
if ( '7.1' > $version ) {
$dockerfile = str_replace( 'RUN curl -sL', 'RUN curl -sLk', $dockerfile );
}

$dockerfile = str_replace( '%%GENERATED_WARNING%%', $generated_warning, $dockerfile );

if ( 'latest' === $php_version ) {
$version_tag = 'latest';
} else {
$version_tag = "$php_version-fpm";
}
$dockerfile = str_replace( '%%VERSION_TAG%%', $version_tag, $dockerfile );

$dockerfile = str_replace( '%%PHPUNIT_VERSION%%', $phpunit_version, $dockerfile );

// Cleanup any leftover tags.
$dockerfile = preg_replace( '/%%[^%]+%%/', '', $dockerfile );

// Write the real Dockerfile.
write_file( "images/phpunit/{$phpunit_version}-php-{$php_version}/Dockerfile", $dockerfile );

// Copy the entrypoint script, if it exists.
if ( file_exists( "entrypoint/entrypoint-phpunit.sh" ) ) {
copy( "entrypoint/entrypoint-phpunit.sh", "images/phpunit/{$phpunit_version}-php-{$php_version}/entrypoint.sh" );
}

echo "\n";
}
}

$workflow_templates = array(
'docker-hub.yml' => 'GITHUB',
'github-container-registry.yml' => 'DOCKER_HUB',
Expand All @@ -556,9 +513,6 @@
$php_version_list = "'" . implode( "', '", array_keys( $php_versions ) ) . "'";
$workflow_template = str_replace( '%%PHP_VERSION_LIST%%', $php_version_list, $workflow_template );

$phpunit_version_list = "'" . implode( "', '", array_values( $phpunit_combinations ) ) . "'";
$workflow_template = str_replace( '%%PHPUNIT_COMBINATIONS%%', $phpunit_version_list, $workflow_template );

$workflow_template = str_replace( '%%PHP_LATEST%%', $latest, $workflow_template );

foreach ( $workflow_templates as $name => $remove_pattern ) {
Expand Down

0 comments on commit bf6b42c

Please sign in to comment.