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

Add PHP Code coverage report as a GitHub action #1915

Merged
merged 9 commits into from
Mar 30, 2023
Merged

Conversation

mikkamp
Copy link
Contributor

@mikkamp mikkamp commented Mar 6, 2023

Changes proposed in this Pull Request:

Resolves part of #864

This PR adds a code coverage report as a PR comment. Since we run multiple unit tests in GitHub actions the coverage report is only generated once when the tests are run with the latest WP version and for PHP 8.0.

I've added the coverage using a flag php-unit-tests, the intention is to also include the coverage report for the JS unit tests, but that will be part of a followup PR.

Note
There is currently no report stored for the develop branch. So it's only producing a coverage report of the current PR and isn't able to compare the difference between the two. Once this PR is merged to develop it will generate the report for develop which will allow the comparison to appear in subsequent PR's.

Detailed test instructions:

  1. View the code coverage report here in the PR comment and confirm it contains the right test results (no comparison data available)
  2. Confirm that in the workflow runs the coverage report is only generated for PHP 8.0 and WP latest, we should see skipped tasks that differ:
    image

Changelog entry

  • Dev - Add PHP Code coverage report as GitHub action.

@github-actions github-actions bot added changelog: add A new feature, function, or functionality was added. type: enhancement The issue is a request for an enhancement. labels Mar 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2023

Coverage report for commit: e1696bc
File: tests/php-coverage/report.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ███████████████████████ │ 45.8%
  10% │ ██░░░░░░░░░░░░░░░░░░░░░ │  3.2%
  20% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.3%
  30% │ █░░░░░░░░░░░░░░░░░░░░░░ │  1.5%
  40% │ ██░░░░░░░░░░░░░░░░░░░░░ │  2.3%
  50% │ ███░░░░░░░░░░░░░░░░░░░░ │  4.2%
  60% │ ██░░░░░░░░░░░░░░░░░░░░░ │  3.2%
  70% │ ██░░░░░░░░░░░░░░░░░░░░░ │  2.3%
  80% │ ███░░░░░░░░░░░░░░░░░░░░ │  5.0%
  90% │ ██████░░░░░░░░░░░░░░░░░ │ 11.1%
 100% │ ███████████░░░░░░░░░░░░ │ 20.2%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 56.63% | Methods: 48.64%
FilesLinesMethodsBranchs
/home/runner/work/google-listings-and-ads/google-listings-and-ads
   google-listings-and-ads.php6.38%--
src/API/Google
   Ads.php93.94%78.57%-
   AdsAsset.php94.68%60.00%-
   AdsAssetGroup.php72.96%56.25%-
   AdsAssetGroupAsset.php83.46%83.33%-
   AdsCampaign.php97.07%68.75%-
   AdsCampaignBudget.php91.43%66.67%-
   AdsConversionAction.php97.44%75.00%-
   AdsReport.php90.91%60.00%-
   ApiExceptionTrait.php68.18%25.00%-
   Connection.php1.69%--
   MerchantMetrics.php76.60%50.00%-
   Middleware.php85.07%84.21%-
   ReportTrait.php92.86%75.00%-
   Settings.php7.94%9.09%-
src/API/Google/Query
   AdsCampaignReportQuery.php75.00%50.00%-
   AdsProductReportQuery.php70.00%50.00%-
   AdsQuery.php83.33%--
   MerchantFreeListingReportQuery.php50.00%--
   MerchantQuery.php76.92%50.00%-
   MerchantReportQuery.php52.38%66.67%-
   Query.php74.73%47.06%-
   ReportQueryTrait.php50.00%--
src/API
   MicroTrait.php66.67%100.00%-
src/API/Site/Controllers/Ads
   ReportsController.php93.55%71.43%-
   SetupCompleteController.php61.90%33.33%-
src/API/Site/Controllers/AttributeMapping
   AttributeMappingDataController.php93.10%71.43%-
   AttributeMappingRulesController.php92.91%44.44%-
   AttributeMappingSyncerController.php95.00%80.00%-
src/API/Site/Controllers
   BaseController.php97.92%90.91%-
   BaseReportsController.php78.05%50.00%-
   DisconnectController.php36.11%25.00%-
src/API/Site/Controllers/Google
   AccountController.php98.04%88.89%-
src/API/Site/Controllers/MerchantCenter
   AttributeMappingCategoriesController.php24.19%33.33%-
   BatchShippingTrait.php15.79%--
   ConnectionController.php53.85%25.00%-
   ContactInformationController.php64.90%60.00%-
   IssuesController.php84.13%83.33%-
   PhoneVerificationController.php98.84%80.00%-
   PolicyComplianceCheckController.php38.81%40.00%-
   ProductFeedController.php12.40%33.33%-
   ProductStatisticsController.php35.29%28.57%-
   ProductVisibilityController.php63.64%71.43%-
   ReportsController.php91.30%71.43%-
   SettingsController.php16.28%20.00%-
   SettingsSyncController.php34.88%50.00%-
   ShippingRateBatchController.php58.02%50.00%-
   ShippingRateController.php43.31%58.33%-
   ShippingRateSuggestionsController.php56.36%40.00%-
   ShippingTimeBatchController.php46.67%33.33%-
   ShippingTimeController.php38.36%25.00%-
   SupportedCountriesController.php94.55%57.14%-
   SyncableProductsCountController.php77.08%83.33%-
   TargetAudienceController.php52.94%25.00%-
src/API/Site
   RESTControllers.php90.91%66.67%-
src/ActionScheduler
   ActionScheduler.php6.25%10.00%-
src/Admin/BulkEdit
   BulkEditInitializer.php60.00%50.00%-
   CouponBulkEdit.php25.81%33.33%-
src/Ads
   AccountService.php92.93%90.00%-
   AdsService.php50.00%75.00%-
   AssetSuggestionsService.php92.09%69.23%-
src/Assets
   AdminAssetHelper.php33.33%--
   BaseAsset.php50.00%40.00%-
   ScriptAsset.php6.25%16.67%-
src
   Container.php12.50%33.33%-
   PluginHelper.php63.64%68.42%-
src/Coupon
   CouponHelper.php62.37%50.00%-
   CouponMetaHandler.php95.00%57.14%-
   CouponSyncer.php70.68%30.00%-
   SyncerHooks.php75.25%66.67%-
   WCCouponAdapter.php78.66%41.67%-
src/DB
   ProductFeedQueryHelper.php36.71%14.29%-
   Query.php1.38%4.35%-
   Table.php11.11%10.00%-
src/DB/Migration
   Migrator.php93.75%100.00%-
src/DB/Query
   AttributeMappingRulesQuery.php12.50%33.33%-
   BudgetRecommendationQuery.php40.00%50.00%-
   MerchantIssueQuery.php66.67%50.00%-
   ShippingRateQuery.php11.76%33.33%-
   ShippingTimeQuery.php20.00%--
src/DB/Table
   BudgetRecommendationTable.php58.70%28.57%-
src/Event
   ClearProductStatsCache.php76.47%33.33%-
   StartProductSync.php40.00%25.00%-
src/Exception
   AccountReconnect.php52.63%50.00%-
   ExceptionWithResponseData.php87.50%66.67%-
   InvalidAsset.php11.11%25.00%-
   InvalidClass.php66.67%66.67%-
   InvalidValue.php55.56%50.00%-
   WPErrorTrait.php11.11%33.33%-
src/Google
   BatchProductIDRequestEntry.php69.23%80.00%-
   BatchProductRequestEntry.php80.00%66.67%-
   GoogleHelper.php97.78%87.50%-
   InvalidCouponEntry.php61.29%87.50%-
   SiteVerificationMeta.php95.00%100.00%-
src/HelperTraits
   Utilities.php5.56%25.00%-
src/Integration
   YoastWooCommerceSeo.php84.00%36.36%-
src/Internal
   ContainerAwareTrait.php50.00%100.00%-
src/Internal/DependencyManagement
   AbstractServiceProvider.php12.50%28.57%-
src/Jobs
   AbstractActionSchedulerJob.php94.44%100.00%-
   AbstractBatchedActionSchedulerJob.php91.67%90.00%-
   AbstractProductSyncerBatchedJob.php87.50%100.00%-
   AbstractProductSyncerJob.php85.71%100.00%-
   CleanupSyncedProducts.php93.75%100.00%-
   JobException.php35.00%25.00%-
   JobRepository.php30.77%--
   SyncableProductsBatchedActionSchedulerJobTrait.php92.86%66.67%-
   UpdateAllProducts.php85.71%100.00%-
   UpdateProducts.php62.50%75.00%-
   UpdateShippingSettings.php91.67%100.00%-
   UpdateSyncableProductsCount.php93.33%100.00%-
src/Logging
   DebugLogger.php52.17%71.43%-
src/MerchantCenter
   AccountService.php95.31%84.62%-
   MerchantCenterAwareTrait.php50.00%100.00%-
   MerchantCenterService.php92.65%83.33%-
   MerchantStatuses.php59.57%33.33%-
   PhoneVerification.php85.71%85.71%-
   PolicyComplianceCheck.php92.86%81.82%-
   TargetAudience.php25.00%--
src/MultichannelMarketing
   GLAChannel.php98.11%100.00%-
src/Notes
   AbstractNote.php50.00%66.67%-
   AttributeMappingNewFeature.php94.74%100.00%-
   ReconnectWordPress.php89.66%80.00%-
src/Options
   Options.php25.00%25.00%-
   OptionsAwareTrait.php50.00%100.00%-
   Transients.php30.00%33.33%-
src/Product/AttributeMapping
   AttributeMappingHelper.php55.88%50.00%-
src/Product/AttributeMapping/Traits
   IsEnumTrait.php66.67%50.00%-
   IsFieldTrait.php2.82%20.00%-
src/Product/Attributes
   AbstractAttribute.php88.24%71.43%-
   Adult.php50.00%66.67%-
   AgeGroup.php91.67%80.00%-
   AttributeManager.php88.57%85.71%-
   AvailabilityDate.php50.00%40.00%-
   Brand.php80.00%75.00%-
   Color.php80.00%75.00%-
   Condition.php90.00%80.00%-
   GTIN.php80.00%75.00%-
   Gender.php40.00%60.00%-
   IsBundle.php50.00%66.67%-
   MPN.php80.00%75.00%-
   Material.php80.00%75.00%-
   Multipack.php83.33%80.00%-
   Pattern.php80.00%75.00%-
   Size.php80.00%75.00%-
   SizeSystem.php94.44%80.00%-
   SizeType.php92.31%80.00%-
src/Product
   BatchProductHelper.php88.68%81.82%-
   FilteredProductList.php92.86%80.00%-
   ProductFactory.php94.74%100.00%-
   ProductHelper.php95.24%85.19%-
   ProductMetaHandler.php91.03%54.55%-
   ProductRepository.php96.43%88.24%-
   ProductSyncer.php97.24%70.00%-
Table truncated to fit comment

PHP unit test coverage

@mikkamp mikkamp self-assigned this Mar 6, 2023
@mikkamp mikkamp added changelog: dev Developer-facing only change. and removed changelog: add A new feature, function, or functionality was added. labels Mar 6, 2023
@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

❗ No coverage uploaded for pull request base (develop@e1ae2ba). Click here to learn what that means.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             develop   #1915   +/-   ##
=========================================
  Coverage           ?   56.8%           
  Complexity         ?    4097           
=========================================
  Files              ?     456           
  Lines              ?   17608           
  Branches           ?       0           
=========================================
  Hits               ?    9994           
  Misses             ?    7614           
  Partials           ?       0           
Flag Coverage Δ
php-unit-tests 56.8% <0.0%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@mikkamp mikkamp force-pushed the add/coverage-report branch from 5e48d0d to 0910662 Compare March 27, 2023 13:32
@mikkamp mikkamp requested a review from a team March 28, 2023 14:40
@mikkamp mikkamp marked this pull request as ready for review March 28, 2023 14:40
phpunit.xml.dist Outdated Show resolved Hide resolved
.codecov.yml Outdated Show resolved Hide resolved
.codecov.yml Outdated
Comment on lines 16 to 18
layout: 'reach, diff, flags, files'
behavior: default
require_changes: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three seems for me like default options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too, but apparently the default looked different without adding these settings. For example the graph (reach) is not displayed by default. If you have a look at the edited link of the codecov comment you can see the history of what the comment looked like. I ran it quite a few times to get it to contain the sections I wanted.

I can take another look to see if there are additional sections we can omit but I tried to copy the defaults from the WooCommerce core yml file.

.codecov.yml Outdated Show resolved Hide resolved
@mikkamp
Copy link
Contributor Author

mikkamp commented Mar 30, 2023

I went ahead and removed more of those defaults as you suggested. I still left the comment.layout since I wasn't getting the reach section included initially. The files section is still not included, but that relies on comparing with a parent branch, so will only start showing up after we've merged to develop. It's ready for another round of review.

@mikkamp mikkamp requested a review from puntope March 30, 2023 12:46
Copy link
Contributor

@puntope puntope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM

@mikkamp mikkamp merged commit 2d11b8f into develop Mar 30, 2023
@mikkamp mikkamp deleted the add/coverage-report branch March 30, 2023 15:00
@tomalec tomalec mentioned this pull request Apr 25, 2023
@mikkamp mikkamp mentioned this pull request Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: dev Developer-facing only change. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants