Skip to content

Commit 4f2cfd2

Browse files
e2e test reliability
* release: 3.6.10 * wait for docker compose to boot * add cache for mock api image * fix(ci): cache localstack Docker image in GitHub Actions * remove e2e for s3 offload and dependencies * exit on error when running mocks * add healthcheck to mock api * add plain index * Remove plugins from wp boot --------- Co-authored-by: Sertii <36940685+Sreini@users.noreply.github.com>
1 parent bf0abc7 commit 4f2cfd2

File tree

10 files changed

+21
-215
lines changed

10 files changed

+21
-215
lines changed

.github/workflows/integration-tests.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ jobs:
3232
node-version: 18
3333
cache: 'npm'
3434

35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v4
37+
38+
- name: Build Mock Image
39+
uses: docker/build-push-action@v7
40+
with:
41+
context: .
42+
file: ./config/Dockerfile-mock-webservice
43+
tags: tinify-mock-api:latest
44+
load: true
45+
cache-from: type=gha
46+
cache-to: type=gha,mode=max
47+
3548
- name: Cache node_modules
3649
uses: actions/cache@v4
3750
with:
@@ -57,7 +70,6 @@ jobs:
5770

5871
- run: npx playwright install --with-deps
5972
if: steps.playwright-cache.outputs.cache-hit != 'true'
60-
6173
- name: Start WordPress
6274
uses: nick-fields/retry@v3
6375
with:
@@ -73,7 +85,6 @@ jobs:
7385
run: npm run test:playwright
7486
env:
7587
WORDPRESS_PORT: 80${{ matrix.wp }}
76-
PHP_VERSION: ${{ matrix.php }}
7788

7889
- uses: actions/upload-artifact@v4
7990
if: ${{ !cancelled() }}

bin/run-mocks

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
2+
set -e
23

34
port="$1"
45

5-
docker compose -f config/mocks.docker-compose.yml up -d
6+
docker compose -f config/mocks.docker-compose.yml up -d --wait
67

78
mv src/vendor/tinify/Tinify/Client.php src/vendor/tinify/Tinify/Client.php.bak
89
cp test/fixtures/Client.php src/vendor/tinify/Tinify/Client.php

bin/run-wordpress

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ EOF
9393
echo "Activating tinify.."
9494
docker compose -f config/docker-compose.yml run --rm wpcli wp plugin activate tiny-compress-images --allow-root
9595

96-
if [ "$WORDPRESS_VERSION_ENV" -ge 55 ]; then
97-
echo "Installing compatible plugins for WordPress ${WORDPRESS_PORT}.."
98-
docker compose -f config/docker-compose.yml run --rm --user 33 wpcli wp plugin install amazon-s3-and-cloudfront --activate --allow-root || exit 1
99-
fi
100-
10196
MAX_ATTEMPTS=10
10297
ATTEMPT=0
10398
until curl -s --head --fail "http://localhost:${WORDPRESS_PORT}" >/dev/null; do

config/docker-compose.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ services:
2929
WORDPRESS_DB_PASSWORD: wordpress
3030
WORDPRESS_DB_NAME: wordpress
3131
WORDPRESS_DEBUG: '1'
32-
AWS_ENDPOINT: http://localstack:4566
33-
AWS_USE_PATH_STYLE_ENDPOINT: true
34-
AWS_ACCESS_KEY_ID: test_key_id
35-
AWS_SECRET_ACCESS_KEY: test_secret_access_key
36-
AWS_REGION: eu-central-1
37-
AWS_DEFAULT_REGION: eu-central-1
3832
volumes:
3933
- wordpress_data:/var/www/html
4034
- ../:/var/www/html/wp-content/plugins/tiny-compress-images

config/localstack-init.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

config/mocks.docker-compose.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
services:
2-
localstack:
3-
image: localstack/localstack
4-
volumes:
5-
- './localstack-init.sh:/etc/localstack/init/ready.d/init-aws.sh'
6-
ports:
7-
- 4566:4566
8-
networks:
9-
- tinify
10-
112
tinify-mock-api:
123
image: tinify-mock-api
134
build:
@@ -17,6 +8,11 @@ services:
178
- '8100:80'
189
volumes:
1910
- ../test/mock-tinypng-webservice:/var/www/html
11+
healthcheck:
12+
test: ["CMD", "curl", "-f", "http://localhost/"]
13+
interval: 5s
14+
timeout: 3s
15+
retries: 3
2016
networks:
2117
- tinify
2218

test/fixtures/class-tiny-config.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
if (! defined('TINY_DEBUG')) {
44
define('TINY_DEBUG', null);
55
}
6-
define('AWS_REGION', getenv('AWS_REGION'));
7-
define('AWS_ENDPOINT', getenv('AWS_ENDPOINT'));
8-
define('AWS_ACCESS_KEY_ID', getenv('AWS_ACCESS_KEY_ID'));
9-
define('AWS_SECRET_ACCESS_KEY', getenv('AWS_SECRET_ACCESS_KEY'));
106

117
class Tiny_Config
128
{
@@ -17,23 +13,6 @@ class Tiny_Config
1713
const META_KEY = 'tiny_compress_images';
1814
}
1915

20-
/**
21-
* Filter for adding arguments to the AS3CF AWS client.
22-
* Required to point the client to the LocalStack instance.
23-
*/
24-
add_filter('as3cf_aws_init_client_args', function ($args) {
25-
$args['endpoint'] = AWS_ENDPOINT;
26-
$args['use_path_style_endpoint'] = true;
27-
$args['region'] = AWS_REGION;
28-
return $args;
29-
});
30-
31-
// Force all S3 URLs to use LocalStack instead of s3.amazonaws.com
32-
add_filter('as3cf_aws_s3_url_domain', function ($domain, $bucket, $region, $expires, $args) {
33-
// Replace any AWS domain with LocalStack
34-
return AWS_ENDPOINT . '/' . $bucket;
35-
}, 10, 5);
36-
3716
// ajax hook to delete all attachments as doing it via UI is flaky
3817
add_action( 'wp_ajax_clear_media_library', 'clear_media_library' );
3918
function clear_media_library() {

test/integration/compatibility.spec.ts

Lines changed: 0 additions & 156 deletions
This file was deleted.

test/integration/utils.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,6 @@ export async function getWPVersion(page: Page): Promise<number> {
160160
return parsedText;
161161
}
162162

163-
/**
164-
* @returns {number} retrieves the current PHP version from environment variable
165-
*/
166-
export function getPHPVersion(): number {
167-
const { PHP_VERSION } = process.env;
168-
if (!PHP_VERSION) {
169-
throw Error('PHP_VERSION is not set');
170-
}
171-
172-
return +PHP_VERSION;
173-
}
174-
175163
/**
176164
* @param {Page} page context
177165
* @param {string} pluginSlug slug of the plugin, ex 'tiny-compress-images'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

0 commit comments

Comments
 (0)