From f12eee089b1293423f21564f0ac6eba26e68013c Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 10 Oct 2024 15:06:56 +0530 Subject: [PATCH 1/7] Add @cover annotation in test-load file and add support for codecov for test coverage --- .github/workflows/codecov-coverage.yml | 39 +++++++++++++ codecov.yml | 15 +++++ composer.json | 6 +- plugins/webp-uploads/tests/test-load.php | 71 ++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/codecov-coverage.yml create mode 100644 codecov.yml diff --git a/.github/workflows/codecov-coverage.yml b/.github/workflows/codecov-coverage.yml new file mode 100644 index 0000000000..a1a4002d53 --- /dev/null +++ b/.github/workflows/codecov-coverage.yml @@ -0,0 +1,39 @@ +name: PHP Test and Coverage + +on: [push, pull_request] + +jobs: + php-test: + runs-on: ubuntu-latest + name: WordPress Test Coverage + strategy: + fail-fast: false + matrix: + php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2'] + wp: [ 'latest' ] + include: + - php: '7.4' + wp: '6.5' + - php: '8.3' + wp: 'trunk' + env: + WP_ENV_PHP_VERSION: ${{ matrix.php }} + WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, intl, curl, dom, json, xml, zip + - name: Install Composer dependencies + run: composer install --no-interaction --no-progress + - name: Run PHPUnit tests + run: vendor/bin/phpunit --coverage-clover=coverage.xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + flags: unittests + name: ${{ matrix.php }}-coverage \ No newline at end of file diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..447f19001b --- /dev/null +++ b/codecov.yml @@ -0,0 +1,15 @@ +codecov: + notify: + require_ci_to_pass: yes +coverage: + status: + project: + default: + target: auto + threshold: 80% + base: auto + informational: true + patch: + default: + threshold: 80% + informational: true \ No newline at end of file diff --git a/composer.json b/composer.json index 28f6548a01..236550abd4 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,9 @@ "wp-phpunit/wp-phpunit": "^6.5", "yoast/phpunit-polyfills": "^2.0", "phpstan/php-8-stubs": "^0.3.84", - "phpstan/phpstan-strict-rules": "^1.6" + "phpstan/phpstan-strict-rules": "^1.6", + "phpunit/phpunit": "^9.5", + "codecov/codecov": "^1.0" }, "config": { "allow-plugins": { @@ -89,7 +91,7 @@ "lint:web-worker-offloading": "@lint -- ./plugins/web-worker-offloading --standard=./plugins/web-worker-offloading/phpcs.xml.dist", "lint:webp-uploads": "@lint -- ./plugins/webp-uploads --standard=./plugins/webp-uploads/phpcs.xml.dist", "phpstan": "phpstan analyse --memory-limit=2048M", - "test": "phpunit", + "test": "phpunit --strict-coverage", "test-multisite": [ "WP_MULTISITE=1 phpunit --exclude-group=ms-excluded" ], diff --git a/plugins/webp-uploads/tests/test-load.php b/plugins/webp-uploads/tests/test-load.php index f70fd19e9f..637838873b 100644 --- a/plugins/webp-uploads/tests/test-load.php +++ b/plugins/webp-uploads/tests/test-load.php @@ -43,6 +43,9 @@ static function ( string $filename ) { /** * Don't create the original mime type for JPEG images. * + * @covers ::wp_get_attachment_metadata + * @covers ::wp_get_original_image_path + * @covers ::get_post_mime_type * @dataProvider data_provider_supported_image_types */ public function test_it_should_not_create_the_original_mime_type_for_jpeg_images( string $image_type ): void { @@ -79,6 +82,9 @@ public function test_it_should_not_create_the_original_mime_type_for_jpeg_images /** * Create the original mime type for WebP images. + * + * @covers ::wp_get_attachment_metadata + * @covers ::get_post_mime_type */ public function test_it_should_create_the_original_mime_type_as_well_with_all_the_available_sources_for_the_specified_mime(): void { update_option( 'perflab_generate_webp_and_jpeg', false ); @@ -109,6 +115,8 @@ public function test_it_should_create_the_original_mime_type_as_well_with_all_th /** * Create JPEG and output type for JPEG images, if opted in. * + * @covers ::wp_get_attachment_metadata + * @covers ::get_post_mime_type * @dataProvider data_provider_supported_image_types */ public function test_it_should_create_jpeg_and_webp_for_jpeg_images_if_opted_in( string $image_type ): void { @@ -145,6 +153,8 @@ public function test_it_should_create_jpeg_and_webp_for_jpeg_images_if_opted_in( /** * Create JPEG and output format for JPEG images, if perflab_generate_webp_and_jpeg option set. * + * @covers ::wp_get_attachment_metadata + * @covers ::get_post_mime_type * @dataProvider data_provider_supported_image_types */ public function test_it_should_create_jpeg_and_webp_for_jpeg_images_if_generate_webp_and_jpeg_set( string $image_type ): void { @@ -181,6 +191,9 @@ public function test_it_should_create_jpeg_and_webp_for_jpeg_images_if_generate_ /** * Don't create the sources property if no transform is provided. + * + * @covers ::wp_get_attachment_metadata + * @covers ::assertArrayNotHasKey */ public function test_it_should_not_create_the_sources_property_if_no_transform_is_provided(): void { add_filter( 'webp_uploads_upload_image_mime_transforms', '__return_empty_array' ); @@ -200,6 +213,8 @@ public function test_it_should_not_create_the_sources_property_if_no_transform_i /** * Create the sources property when no transform is available + * + * @covers ::wp_get_attachment_metadata */ public function test_it_should_create_the_sources_property_when_no_transform_is_available(): void { add_filter( @@ -225,6 +240,9 @@ static function () { /** * Not create the sources property if the mime is not specified on the transforms images + * + * @covers ::wp_get_attachment_metadata + * @covers ::assertArrayNotHasKey */ public function test_it_should_not_create_the_sources_property_if_the_mime_is_not_specified_on_the_transforms_images(): void { add_filter( @@ -249,6 +267,9 @@ static function () { /** * Create a WebP version with all the required properties + * + * @covers ::wp_get_attachment_metadata + * @covers ::assertFileExists */ public function test_it_should_create_a_webp_version_with_all_the_required_properties(): void { $attachment_id = self::factory()->attachment->create_upload_object( @@ -275,6 +296,8 @@ public function test_it_should_create_a_webp_version_with_all_the_required_prope /** * Create the full size images when no size is available + * + * @covers ::wp_get_attachment_metadata */ public function test_it_should_create_the_full_size_images_when_no_size_is_available(): void { add_filter( 'intermediate_image_sizes', '__return_empty_array' ); @@ -291,6 +314,9 @@ public function test_it_should_create_the_full_size_images_when_no_size_is_avail /** * Remove `scaled` suffix from the generated filename + * + * @covers ::get_attached_file + * @covers ::wp_get_attachment_metadata */ public function test_it_should_remove_scaled_suffix_from_the_generated_filename(): void { // Create JPEG and WebP to check for scaled suffix. @@ -316,6 +342,9 @@ static function () { /** * Remove the generated webp images when the attachment is deleted + * + * @covers ::get_attached_file + * @covers ::wp_get_attachment_metadata */ public function test_it_should_remove_the_generated_webp_images_when_the_attachment_is_deleted(): void { $attachment_id = self::factory()->attachment->create_upload_object( @@ -349,6 +378,9 @@ public function test_it_should_remove_the_generated_webp_images_when_the_attachm /** * Remove the attached WebP version if the attachment is force deleted + * + * @covers ::wp_delete_attachment + * @covers ::wp_get_attachment_metadata */ public function test_it_should_remove_the_attached_webp_version_if_the_attachment_is_force_deleted(): void { $attachment_id = self::factory()->attachment->create_upload_object( @@ -374,6 +406,9 @@ public function test_it_should_remove_the_attached_webp_version_if_the_attachmen /** * Remove full size images when no size image exists + * + * @covers ::wp_delete_attachment + * @covers ::wp_get_attachment_metadata */ public function test_it_should_remove_full_size_images_when_no_size_image_exists(): void { add_filter( 'intermediate_image_sizes', '__return_empty_array' ); @@ -397,6 +432,10 @@ public function test_it_should_remove_full_size_images_when_no_size_image_exists /** * Remove the attached WebP version if the attachment is force deleted after edit. + * + * @covers ::wp_delete_attachment + * @covers ::wp_get_attachment_metadata + * @covers ::get_post_meta */ public function test_it_should_remove_the_backup_sizes_and_sources_if_the_attachment_is_deleted_after_edit(): void { $attachment_id = self::factory()->attachment->create_upload_object( @@ -429,6 +468,7 @@ public function test_it_should_remove_the_backup_sizes_and_sources_if_the_attach /** * Avoid the change of URLs of images that are not part of the media library * + * @covers ::webp_uploads_update_image_references * @group webp_uploads_update_image_references */ public function test_it_should_avoid_the_change_of_urls_of_images_that_are_not_part_of_the_media_library(): void { @@ -443,6 +483,7 @@ public function test_it_should_avoid_the_change_of_urls_of_images_that_are_not_p /** * Avoid replacing not existing attachment IDs * + * @covers ::webp_uploads_update_image_references * @group webp_uploads_update_image_references */ public function test_it_should_avoid_replacing_not_existing_attachment_i_ds(): void { @@ -457,6 +498,7 @@ public function test_it_should_avoid_replacing_not_existing_attachment_i_ds(): v /** * Prevent replacing a WebP image * + * @covers ::webp_uploads_update_image_references * @group webp_uploads_update_image_references */ public function test_it_should_prevent_replacing_a_webp_image(): void { @@ -485,6 +527,8 @@ public function test_it_should_prevent_replacing_a_webp_image(): void { /** * Prevent replacing a jpg image if the image does not have the target class name + * + * @covers ::webp_uploads_update_image_references */ public function test_it_should_prevent_replacing_a_jpg_image_if_the_image_does_not_have_the_target_class_name(): void { $attachment_id = self::factory()->attachment->create_upload_object( @@ -502,6 +546,8 @@ public function test_it_should_prevent_replacing_a_jpg_image_if_the_image_does_n /** * Replace references to a JPG image to a WebP version * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references * @dataProvider provider_replace_images_with_different_extensions * @group webp_uploads_update_image_references */ @@ -530,6 +576,8 @@ public function test_it_should_replace_references_to_a_jpg_image_to_a_webp_versi /** * Should not replace jpeg images in the content if other mime types are disabled via filter. * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references * @dataProvider provider_replace_images_with_different_extensions * @group webp_uploads_update_image_references */ @@ -559,6 +607,9 @@ public function provider_replace_images_with_different_extensions(): Generator { /** * Replace all the images including the full size image + * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references */ public function test_it_should_replace_all_the_images_including_the_full_size_image(): void { // Create JPEG and WebP to check replacement of JPEG => WebP. @@ -586,6 +637,8 @@ public function test_it_should_replace_all_the_images_including_the_full_size_im /** * Prevent replacing an image with no available sources * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references * @group webp_uploads_update_image_references */ public function test_it_should_prevent_replacing_an_image_with_no_available_sources(): void { @@ -602,6 +655,8 @@ public function test_it_should_prevent_replacing_an_image_with_no_available_sour /** * Prevent update not supported images with no available sources * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references * @dataProvider data_provider_not_supported_webp_images * @group webp_uploads_update_image_references */ @@ -654,6 +709,8 @@ static function () { /** * Tests that we can force generating jpeg subsizes using the webp_uploads_upload_image_mime_transforms filter. + * + * @covers \Test_WebP_Uploads_Load::opt_in_to_jpeg_and_webp */ public function test_it_should_preserve_jpeg_subsizes_using_transform_filter(): void { // Create JPEG and WebP. @@ -674,6 +731,8 @@ public function test_it_should_preserve_jpeg_subsizes_using_transform_filter(): /** * Allow the upload of an image if at least one editor supports the image type * + * @covers ::wp_image_editor_supports + * @covers ::set_post_thumbnail * @dataProvider data_provider_supported_image_types * * @group current1 @@ -716,6 +775,8 @@ static function ( $editors ) { /** * Replace the featured image to the proper type when requesting the featured image. * + * @covers ::get_the_post_thumbnail + * @covers ::set_post_thumbnail * @dataProvider data_provider_supported_image_types */ public function test_it_should_replace_the_featured_image_to_webp_when_requesting_the_featured_image( string $image_type ): void { @@ -752,6 +813,7 @@ public function data_provider_supported_image_types(): array { /** * Prevent replacing an image if image was uploaded via external source or plugin. * + * @covers ::webp_uploads_update_image_references * @group webp_uploads_update_image_references */ public function test_it_should_prevent_replacing_an_image_uploaded_via_external_source(): void { @@ -774,6 +836,9 @@ static function () { /** * The image with the smaller filesize should be used when webp_uploads_discard_larger_generated_images is set to true. + * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references */ public function test_it_should_create_webp_when_webp_is_smaller_than_jpegs(): void { // Create JPEG and WebP. @@ -813,6 +878,9 @@ public function test_it_should_create_webp_when_webp_is_smaller_than_jpegs(): vo /** * The image with the smaller filesize should be used when webp_uploads_discard_larger_generated_images is set to true. + * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references */ public function test_it_should_create_webp_for_full_size_which_is_smaller_in_webp_format(): void { // Create JPEG and WebP. @@ -840,6 +908,9 @@ public function test_it_should_create_webp_for_full_size_which_is_smaller_in_web /** * The image with the smaller filesize should be used when webp_uploads_discard_larger_generated_images is set to true. + * + * @covers ::webp_uploads_img_tag_update_mime_type + * @covers ::webp_uploads_update_image_references */ public function test_it_should_create_webp_for_some_sizes_which_are_smaller_in_webp_format(): void { // Create JPEG and WebP. From 9e6da72ee8a435bd0c87c0c0163a9f2adde2b64e Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 10 Oct 2024 15:19:45 +0530 Subject: [PATCH 2/7] Addressed merge conflict --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 236550abd4..0006c2814f 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "wp-coding-standards/wpcs": "^3.1", "wp-phpunit/wp-phpunit": "^6.5", "yoast/phpunit-polyfills": "^2.0", - "phpstan/php-8-stubs": "^0.3.84", + "phpstan/php-8-stubs": "^0.4.0", "phpstan/phpstan-strict-rules": "^1.6", "phpunit/phpunit": "^9.5", "codecov/codecov": "^1.0" From 50d4c51c1a3fd6e61a931ee3fdcd2fa91440dc4c Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 10 Oct 2024 16:15:12 +0530 Subject: [PATCH 3/7] Add coverage in the existing php-test-plugins.yml and removed redundant code from composer.json --- .github/workflows/codecov-coverage.yml | 39 -------------------------- .github/workflows/php-test-plugins.yml | 18 ++++++++++-- 2 files changed, 16 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/codecov-coverage.yml diff --git a/.github/workflows/codecov-coverage.yml b/.github/workflows/codecov-coverage.yml deleted file mode 100644 index a1a4002d53..0000000000 --- a/.github/workflows/codecov-coverage.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: PHP Test and Coverage - -on: [push, pull_request] - -jobs: - php-test: - runs-on: ubuntu-latest - name: WordPress Test Coverage - strategy: - fail-fast: false - matrix: - php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2'] - wp: [ 'latest' ] - include: - - php: '7.4' - wp: '6.5' - - php: '8.3' - wp: 'trunk' - env: - WP_ENV_PHP_VERSION: ${{ matrix.php }} - WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} - steps: - - uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mbstring, intl, curl, dom, json, xml, zip - - name: Install Composer dependencies - run: composer install --no-interaction --no-progress - - name: Run PHPUnit tests - run: vendor/bin/phpunit --coverage-clover=coverage.xml - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.xml - flags: unittests - name: ${{ matrix.php }}-coverage \ No newline at end of file diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index 4e58a117a1..3145419d96 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -68,6 +68,20 @@ jobs: - name: Composer Install run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress - name: Running single site unit tests - run: npm run test-php + run: npm run test-php -- --coverage-clover=coverage.xml - name: Running multisite unit tests - run: npm run test-php-multisite + run: npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml + - name: Upload single site coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + flags: unittests + name: ${{ matrix.php }}-single-site-coverage + - name: Upload multisite coverage reports to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage-multisite.xml + flags: multisite + name: ${{ matrix.php }}-multisite-coverage From 9be95944e66203346049163c1ab6e4371cf2ad1b Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 10 Oct 2024 16:16:29 +0530 Subject: [PATCH 4/7] Removed redundant code from composer.json --- composer.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 0006c2814f..1503fcf405 100644 --- a/composer.json +++ b/composer.json @@ -32,9 +32,7 @@ "wp-phpunit/wp-phpunit": "^6.5", "yoast/phpunit-polyfills": "^2.0", "phpstan/php-8-stubs": "^0.4.0", - "phpstan/phpstan-strict-rules": "^1.6", - "phpunit/phpunit": "^9.5", - "codecov/codecov": "^1.0" + "phpstan/phpstan-strict-rules": "^1.6" }, "config": { "allow-plugins": { From bad76779aa572cb96df6f1a0a6af69f1f3996a77 Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Thu, 7 Nov 2024 02:59:19 +0530 Subject: [PATCH 5/7] Update workflow to run code coverage using matrix strategy --- .github/workflows/php-test-plugins.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index 3145419d96..2daacec3aa 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -43,11 +43,15 @@ jobs: matrix: php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2'] wp: [ 'latest' ] + coverage: [false] include: - php: '7.4' wp: '6.5' - php: '8.3' wp: 'trunk' + - php: '8.2' + wp: 'latest' + coverage: true env: WP_ENV_PHP_VERSION: ${{ matrix.php }} WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} @@ -68,10 +72,21 @@ jobs: - name: Composer Install run: npm run wp-env run tests-cli -- --env-cwd="wp-content/plugins/$(basename $(pwd))" composer install --no-interaction --no-progress - name: Running single site unit tests - run: npm run test-php -- --coverage-clover=coverage.xml + run: | + if [ "${{ matrix.coverage }}" == "true" ]; then + npm run test-php -- --coverage-clover=coverage.xml + else + npm run test-php + fi - name: Running multisite unit tests - run: npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml + run: | + if [ "${{ matrix.coverage }}" == "true" ]; then + npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml + else + npm run test-php-multisite + fi - name: Upload single site coverage reports to Codecov + if: ${{ matrix.coverage == true }} uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -79,7 +94,8 @@ jobs: flags: unittests name: ${{ matrix.php }}-single-site-coverage - name: Upload multisite coverage reports to Codecov - uses: codecov/codecov-action@v2 + if: ${{ matrix.coverage == true }} + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage-multisite.xml From 8ec7982ce66f1bf833c275386cc7878877928771 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 7 Nov 2024 15:38:38 -0800 Subject: [PATCH 6/7] Add EOF line break to codecov.yml --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 447f19001b..94ce322661 100644 --- a/codecov.yml +++ b/codecov.yml @@ -12,4 +12,4 @@ coverage: patch: default: threshold: 80% - informational: true \ No newline at end of file + informational: true From 3a58d609d6b5dfa822d261e36846d674eaeaa710 Mon Sep 17 00:00:00 2001 From: Sarthak Jaiswal Date: Sun, 10 Nov 2024 00:46:15 +0530 Subject: [PATCH 7/7] Addressed feedback : - Implemented alerted of failures. - append commit SHA to avoid chance of conflicts --- .github/workflows/php-test-plugins.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/php-test-plugins.yml b/.github/workflows/php-test-plugins.yml index 2daacec3aa..5aae802fb9 100644 --- a/.github/workflows/php-test-plugins.yml +++ b/.github/workflows/php-test-plugins.yml @@ -41,7 +41,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.2', '8.1', '8.0', '7.4', '7.3', '7.2'] + php: ['8.1', '8.0', '7.4', '7.3', '7.2'] wp: [ 'latest' ] coverage: [false] include: @@ -74,14 +74,14 @@ jobs: - name: Running single site unit tests run: | if [ "${{ matrix.coverage }}" == "true" ]; then - npm run test-php -- --coverage-clover=coverage.xml + npm run test-php -- --coverage-clover=coverage-${{ github.sha }}.xml else npm run test-php fi - name: Running multisite unit tests run: | if [ "${{ matrix.coverage }}" == "true" ]; then - npm run test-php-multisite -- --coverage-clover=coverage-multisite.xml + npm run test-php-multisite -- --coverage-clover=coverage-multisite-${{ github.sha }}.xml else npm run test-php-multisite fi @@ -90,14 +90,16 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.xml - flags: unittests + files: coverage-${{ github.sha }}.xml + flags: single name: ${{ matrix.php }}-single-site-coverage + fail_ci_if_error: true - name: Upload multisite coverage reports to Codecov if: ${{ matrix.coverage == true }} uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - files: coverage-multisite.xml + files: coverage-multisite-${{ github.sha }}.xml flags: multisite name: ${{ matrix.php }}-multisite-coverage + fail_ci_if_error: true