lolli42 / enetcache

Provides an interface to cache plugin content elements
GNU General Public License v2.0
5 stars 4 forks source link

Out of the box testing fails because of PHP version conflicts #10

Closed sypets closed 3 years ago

sypets commented 3 years ago

I used the documentation https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/Testing/ExtensionTesting.html# to setup testing with typo3/testing-framework in my extension and I found the documentation very helpful. :thumbsup: What I especially like is that you have basically the same / similar scripts and workflow and framework for core and extension testing. Also, everything is explained very well in a step by step way which makes it easy to get started - even as beginner.


That being said, there are some minor inconsistencies:

I followed the instructions on https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/Testing/ExtensionTesting.html#. The docs refer to this extension or more specifically the runTests.sh and docker-compose.yml scripts.

I ran into difficulties with PHP version conflicts. These can be fixed easily (see https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/1368), but I think it would be best if this works out-of-the-box.

using PHP 7.4 locally and proceeding as described on the "Extension testing" docs page:

Fresh clone and running unit tests results in error:

$ composer install
$ Build/Scripts/runTests.sh 
Creating network "local_default" with the default driver
PHP 7.2.34 (cli) (built: Dec 17 2020 10:26:11) ( NTS )
Composer detected issues in your platform:

Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.2.34.

PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.2.34. in /home/peters/prog.local/github-pull-requests/typo3-extensions/enetcache/.Build/vendor/composer/platform_check.php on line 24
Removing local_unit_run_ba23c1091b20 ... done
Removing network local_default

This can be prevented by either changing the default PHP version in runTests.sh or supplying it on the command line, e.g. Build/Scripts/runTests.sh -p 7.4

OR

changing the dependencies. It would probably also be good to add version constraints for PHP to composer.json.

The Core Team encourages extension developers to have dedicated Core branches per Core version

and

This documentation assumes an extension is tested with only one major Core version. It does not support extension testing with multiple target Core versions. Extensions that support multiple Core versions at the same time in the same branch are not scope of this document.

This extension does not follow this recommendation: it has a composer.json which supports 11 and 10 (in master).

As said, these are some minor inconsistencies which may pose difficulties. (My own personal experience is that not having everything working smoothly from the start actually helps because you learn more and can then cope with difficulties further on down the road).

sypets commented 3 years ago

Alternatively, it might make more sense to do composer install via runTests too for local testing, e.g.

Build/Scripts/runTests.sh -p 7.3 -s composerInstallMin

but that deviates from the description in https://docs.typo3.org/m/typo3/reference-coreapi/10.4/en-us/Testing/ExtensionTesting.html#preparing-composer-json

lolli42 commented 3 years ago

Thanks for your input, Sybille. styleguide has a runTests.sh -s composerInstall already, i'll add the same to enetcache. Other things mentioned in the issues seem to be related to core-docs, seems some have been adapted there already. It seems there isn't too much that can be done here, but feel free to add patches to specific things if we missed something. I hope it's ok to close here for now since I don't see much that can be done here at the moment.

lolli42 commented 3 years ago

Note: I'll keep php 7.2 & 7.3 compatible versions in testing until enetcache is branched to drop v10 support. current version supports both v10 and v11.

sypets commented 3 years ago

@lolli42 Thank you.

I recently noticed that the extension testing documentation in "TYPO3 Explained" differs from the methods in the "tea" example (which do not use runTests.sh):

("tea" should be the "best practice" example for CI and Extbase / Fluid)

So if and before you put too much effort into this from the docs perspective, you may want to talk with Olli Klee.


As a side note:it is sometimes difficult for me to figure out a "best practice" for myself, also how to run the tests - e.g. via the "project" repo and include the extensions in the project as a mono repo or separately. Currently I have both. I am transitioning, this is all a work in progress. The resources I found help but it makes it more difficult if there are several ways to do it - especially in the official stuff but also in external blogs and git repos.)

lolli42 commented 3 years ago

I opened an issue for tea month ago with https://github.com/TYPO3-Documentation/tea/issues/94 runTests.sh is best practice from core view. it is (at the time of this writing) documented as such in the 'coredocs'. testing-framework actively supports extension testing. tea should be adapted from core point of view.

sypets commented 3 years ago

ah cool. Didn't see that issue before. I think we are on the same page. Not sure if everyone else is though.