Skip to content

Conversation

markmetcalfe
Copy link
Member

@markmetcalfe markmetcalfe commented Sep 5, 2025

This improvement adds the pcov extention to the PHP 7.3-8.4 containers, and some helper aliases unit_pcov, set_coverage to the PHP container shells to make running code coverage and viewing reports easier.

This supports Totara 14 and above (as 13 and below use PHPUnit 8 which has a different configuration)

To test this:

  1. Checkout this PR
  2. Build each of the containers changed in this PR (tbuild nginx php-7.3 php-7.4 php-8.0 php-8.1 php-8.2 php-8.3 php-8.4)
  3. Re-up the nginx container via tup nginx
  4. Checkout t14-release
  5. Re-up and log into the PHP container via tup php && tzsh php
  6. Test installing phpunit via installunit
  7. Test setting a path to run coverage on works via set_coverage server/lib server/totara/core (which will add coverage paths for server/lib and server/totara/core)
  8. Run unit_pcov path/to/test.php and make sure there are no errors
  9. Make sure you are able to open and view the coverage report located at http://coverage-report.localhost (ie outputted in the terminal)
  10. Make sure you are able to run tests normally without coverage via unit path/to/test.php without any issues
  11. Repeat steps 4 to 10 but with t19-release

Will update the docker-dev wiki and the public developer docs on coverage once this is tested and merged

@markmetcalfe markmetcalfe force-pushed the code-coverage branch 3 times, most recently from b374b7c to 5921831 Compare September 16, 2025 20:18
@LinnyTheDuck LinnyTheDuck self-requested a review September 18, 2025 21:19
Copy link
Contributor

@LinnyTheDuck LinnyTheDuck left a comment

Choose a reason for hiding this comment

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

Tested and working, LGTM

@markmetcalfe markmetcalfe merged commit 45ea148 into totara:develop Sep 18, 2025
@markmetcalfe markmetcalfe deleted the code-coverage branch September 18, 2025 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants