Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Archive the PHPUnit related containers #160

Merged
merged 1 commit into from
Dec 5, 2024
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
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
Loading