diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..3bb9236ec --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [ master, v3-branch ] + 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 }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b3f59966a..000000000 --- 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) diff --git a/README.md b/README.md index 11c1cbf61..f028ed00a 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ Lightweight "drop-in" for storing WordPress uploads on Amazon S3 instead of the local filesystem. - + Psalm coverage - - Build status + + CI - - Coverage via codecov.io + + @@ -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 diff --git a/composer.json b/composer.json index 9849e8d35..4595db00b 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,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", diff --git a/inc/class-plugin.php b/inc/class-plugin.php index 90f04358e..de9fe05f5 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 ); diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 2a4ba3ade..46a6e32cf 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..." diff --git a/tests/test-s3-uploads.php b/tests/test-s3-uploads.php index 0c1756419..a0b7fd040 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', ) );