From 78f9f419579f48df4a635d17f8e3a0f2d3042697 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 13:34:11 -0400 Subject: [PATCH 1/9] Move tests to github --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dcae6b6e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: docker run --rm -v $PWD:/code --entrypoint='' humanmade/plugin-tester composer install + + - name: Run tests + run: ./tests/run-tests.sh --coverage-clover=coverage.xml + + - name: Upload coverage to Codecov + run: bash <(curl -s https://codecov.io/bash) + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 560b12c86e6a179a47aa8dcc41892b33fe304d80 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 13:36:35 -0400 Subject: [PATCH 2/9] Supress warning --- .github/workflows/ci.yml | 1 + tests/run-tests.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcae6b6e..3bb9236e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,7 @@ name: CI on: push: + branches: [ master, v3-branch ] pull_request: jobs: diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 2a4ba3ad..46a6e32c 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -10,7 +10,7 @@ mkdir /tmp/s3-uploads-tests/tests docker run --rm --name s3-uploads-tests-minio -d --rm -p 9000:9000 -e MINIO_ACCESS_KEY=AWSACCESSKEY -e MINIO_SECRET_KEY=AWSSECRETKEY -v /tmp/s3-uploads-tests:/data minio/minio server /data > /dev/null -docker run --rm -e S3_UPLOADS_BUCKET=tests -e S3_UPLOADS_KEY=AWSACCESSKEY -e S3_UPLOADS_SECRET=AWSSECRETKEY -e S3_UPLOADS_REGION=us-east-1 -v $PWD:/code humanmade/plugin-tester $@ +docker run --rm -e AWS_SUPPRESS_PHP_DEPRECATION_WARNING=1 -e S3_UPLOADS_BUCKET=tests -e S3_UPLOADS_KEY=AWSACCESSKEY -e S3_UPLOADS_SECRET=AWSSECRETKEY -e S3_UPLOADS_REGION=us-east-1 -v $PWD:/code humanmade/plugin-tester $@ docker kill s3-uploads-tests-minio > /dev/null echo "Running Psalm..." From 3040810a49e94234d02f1a86f7d4a0f81f4ed39a Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 13:37:41 -0400 Subject: [PATCH 3/9] Remove travis file --- .travis.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b3f59966..00000000 --- a/.travis.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Travis CI Configuration File - -services: - - docker - -cache: - timeout: 1000 - directories: - - vendor - -notifications: - email: false - -before_script: - - docker run --rm -v $PWD:/code --entrypoint='' humanmade/plugin-tester composer install - -script: - - ./tests/run-tests.sh --coverage-clover=coverage.xml - - bash <(curl -s https://codecov.io/bash) From 2e0a76d07f1a289c8ee8997e1c7e03e148c6054b Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 14:43:27 -0400 Subject: [PATCH 4/9] Fix psalm --- inc/class-plugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/class-plugin.php b/inc/class-plugin.php index 199a00ed..5cd7d32a 100644 --- a/inc/class-plugin.php +++ b/inc/class-plugin.php @@ -538,6 +538,7 @@ public function set_attachment_files_acl( int $attachment_id, string $acl ) : ?W * * @param int $attachment_id Attachment whose ACL has been changed. * @param string $acl The new ACL that's been set. + * @psalm-suppress TooManyArguments -- Currently do_action doesn't detect variable number of arguments. */ do_action( 's3_uploads_set_attachment_files_acl', $attachment_id, $acl ); From 243835a12dadc7f5ae1f40dbf35fc660c4bbfce6 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 15:01:33 -0400 Subject: [PATCH 5/9] Add phpunit polyfills --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 22a19f1d..15243642 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "require-dev": { "phpunit/phpunit": "7.5", "pcov/clobber": "^2.0", - "humanmade/psalm-plugin-wordpress": "^1.0" + "humanmade/psalm-plugin-wordpress": "^1.0", + "yoast/phpunit-polyfills": "^4.0" }, "scripts": { "test": "./tests/run-tests.sh", From 33e0f79209374ec4dd252e78961ba7130e2021e2 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 15:18:27 -0400 Subject: [PATCH 6/9] Different way to get factory? --- tests/test-s3-uploads.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-s3-uploads.php b/tests/test-s3-uploads.php index 0c175641..a0b7fd04 100644 --- a/tests/test-s3-uploads.php +++ b/tests/test-s3-uploads.php @@ -73,7 +73,7 @@ public function test_generate_attachment_metadata() { $upload_dir = wp_upload_dir(); copy( dirname( __FILE__ ) . '/data/sunflower.jpg', $upload_dir['path'] . '/sunflower.jpg' ); $test_file = $upload_dir['path'] . '/sunflower.jpg'; - $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( 'post_mime_type' => 'image/jpeg', 'post_excerpt' => 'A sample caption', ) ); @@ -99,7 +99,7 @@ public function test_generate_attachment_metadata_for_mp4() { $upload_dir = wp_upload_dir(); copy( dirname( __FILE__ ) . '/data/video.m4v', $upload_dir['path'] . '/video.m4v' ); $test_file = $upload_dir['path'] . '/video.m4v'; - $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( 'post_mime_type' => 'video/mp4', 'post_excerpt' => 'A sample caption', ) ); @@ -116,7 +116,7 @@ public function test_image_sizes_are_deleted_on_attachment_delete() { $upload_dir = wp_upload_dir(); copy( dirname( __FILE__ ) . '/data/sunflower.jpg', $upload_dir['path'] . '/sunflower.jpg' ); $test_file = $upload_dir['path'] . '/sunflower.jpg'; - $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( 'post_mime_type' => 'image/jpeg', 'post_excerpt' => 'A sample caption', ) ); @@ -138,7 +138,7 @@ public function test_generate_attachment_metadata_for_pdf() { $upload_dir = wp_upload_dir(); copy( dirname( __FILE__ ) . '/data/gdpr.pdf', $upload_dir['path'] . '/gdpr.pdf' ); $test_file = $upload_dir['path'] . '/gdpr.pdf'; - $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array( + $attachment_id = self::factory()->attachment->create_object( $test_file, 0, array( 'post_mime_type' => 'application/pdf', 'post_excerpt' => 'A sample caption', ) ); From a149289308944e7bc7155b529fc95e288571cb51 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 15:19:47 -0400 Subject: [PATCH 7/9] Bump required PHP version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e514139..734dc3a4 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ It's focused on providing a highly robust S3 interface with no "bells and whistl ## Requirements -- PHP >= 7.1 +- PHP >= 7.4 - WordPress >= 5.3 ## Getting Set Up From 9b9ed3841f6981fc32b2c96bfb96dfda73af0bb9 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 15:39:02 -0400 Subject: [PATCH 8/9] Update build images --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 734dc3a4..5e53f5d1 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ Psalm coverage - - Build status + + CI - - Coverage via codecov.io + + From 2bae209d43a84bc3c162a2e9d1d07c797ed10320 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 3 Jun 2025 15:40:06 -0400 Subject: [PATCH 9/9] FIx url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e53f5d1..349149e8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Lightweight "drop-in" for storing WordPress uploads on Amazon S3 instead of the local filesystem. - + Psalm coverage