-
Notifications
You must be signed in to change notification settings - Fork 88
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 simple CI pipeline with basic PHP test runner #823
Conversation
test matrix contains all currently released and supported PHP versions
``` 2 tests triggered 2 PHPUnit deprecations: 1) functionsTest::test_serendipity_serverOffsetHour Data Provider method functionsTest::serverOffsetHourDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:17 2) functionsTest::test_serendipity_serverOffsetHourWithTimestampNull Data Provider method functionsTest::serverOffsetHourWithTimestampNullDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:46 ```
``` There was 1 PHPUnit test runner deprecation: 1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"! ```
``` There were 3 PHPUnit test runner deprecations: 1) Metadata found in doc-comment for method functionsConfigTest::test_serendipity_getTemplateFile(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 2) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHour(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 3) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHourWithTimestampNull(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. ```
`assertContains()` is used for arrays etc., but we only have a string. Use `assertStringEndsWith()` instead, the _ends with_ also makes the test more robust.
Wow, that's pretty cool. I wasn't aware the tests we have are really anything at this point, but happy to see the can still act as a foundation. Have you by chance seen the "feature/composer" branch and #821 (comment)? Would you be interested in aligning this PR with that branch and maybe work on it together? (Otherwise I'd happily merge this PR into main, it's an improvement either way. If we could add PHP 7.4 into the matrix mix, I'm sure @onli would be happy, because that's still used in some Linux distro LTS's) Many, many, many thanks for getting involved, this puts a smile to my face. |
Exactly right :) |
The tests run under PHP 7.4 , too, I've just added it to the build matrix. I think I'll first try to tackle the frontend testsuite before looking at #821 in depth – I've never worked with composer (and I don't want to use Docker 😉), so I'll have to dive a bit deeper before doing anything.
Feel free to merge this in the meantime, I can use it as a foundation if I take a look at the composer-feature. |
* add initial PHP test workflow test matrix contains all currently released and supported PHP versions * actually run the tests as described in tests/README * tests: fix PHPUnit imports * tests: fix missing constant S9Y_INCLUDE_PATH * tests: fix PHPUnit deprecation warning: DataProviders must be static ``` 2 tests triggered 2 PHPUnit deprecations: 1) functionsTest::test_serendipity_serverOffsetHour Data Provider method functionsTest::serverOffsetHourDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:17 2) functionsTest::test_serendipity_serverOffsetHourWithTimestampNull Data Provider method functionsTest::serverOffsetHourWithTimestampNullDataProvider() is not static /home/runner/work/Serendipity/Serendipity/tests/include/functionsTest.php:46 ``` * tests: migrate PHPUnit XML configuration to version 11.0 ``` There was 1 PHPUnit test runner deprecation: 1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"! ``` * tests: disable code coverage for now * tests: migrate doc-comments to Attributes ``` There were 3 PHPUnit test runner deprecations: 1) Metadata found in doc-comment for method functionsConfigTest::test_serendipity_getTemplateFile(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 2) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHour(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. 3) Metadata found in doc-comment for method functionsTest::test_serendipity_serverOffsetHourWithTimestampNull(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. ``` * tests: fix assertions `assertContains()` is used for arrays etc., but we only have a string. Use `assertStringEndsWith()` instead, the _ends with_ also makes the test more robust. * tests: also run on PHP 7.4
Hi! Thanks a lot, I just merged your PR into both branches (main and feature/composer).
You should be able to help with the "composer move" effort even without too much composer knowledge I hope. With Docker and ddev you would be setup in a minute, just git clone the Without that, it's a lot more configuration of course:
Of course currently the branch is non-functional, it throws errors because the PHP include directories and paths are not referenced properly, because I moved around directories but did not change the code for it. That's the "busywork" we need to work on :-D
I'd do that with phpstan and php-cs-fixer, there are .github workflows out there I utilize, e.g. https://github.com/TYPO3-Documentation/render-guides/blob/main/.github/workflows/main.yaml - it should be straight-forward to port that to serendipity, once we use composer.
There's some GitHub action workflows available that use dependabot, I do have some bootstrap code for that (https://github.com/TYPO3-Documentation/render-guides/blob/main/.github/dependabot.yml) which should also be easy to port to Serendipity, again - once composer is properly utilized :-)
I've got some experience with that too, steps would be similar to something like https://github.com/sergeyklay/gh-actions-php-phar-create-release-example/blob/master/.github/workflows/release.yml Also the creation of a docker container shouldn't be hard, with something like https://github.com/garvinhicking/typo3-documentation-browsersync/blob/main/.github/workflows/docker.yaml Crossing my fingers I can get you hooked 👯♂️ |
Just to note, IIRC I did have no luck with phpstan, it was not compatible with the oldschool serendipity PHP code. That is why I set on phan instead, at #758 is still the config. So if you get phpstan to work we can close #758, otherwise maybe the config there can be re-used :) |
(ping @garvinhicking ref. https://www.onli-blogging.de/2323/15-Jahre-Serendipity-als-Entwickler-ein-Rueckblick-und-ein-Ausblick.html#c10436)
I have prepared a simple GitHub Action CI pipeline that runs the basic PHP tests on every push and will annotate commits and Pull Requests with the build status.
The tests run for all current PHP versions (that means 8.1, 8.2 and 8.3). The matrix can be expanded to other versions as well, but I don't know if we need to test against deprecated PHP versions without security support. On the other hand, nightly builds of PHP 8.4 could also be used as a test target.
To make the tests pass I had to update them to make them work with a current version of PHPUnit.
Things currently not included:
README.markdown
yet. If you like to have one, I'll add it :-)FrontendTest.php
is not included yet. The test framework Selenium RC is triple-deprecated (Selenium RC is Selenium 1; Selenium 1, 2 and 3 are already deprecated; Selenium 4 is current) and I can't even find downloads of the mentionedselenium-server.jar
(Selenium homepage and GitHub project offer Selenium 2.39.0 as oldest download). I'll see if I can update the tests to work with a current version somehow or if it is feasible to switch to another test framework (any wishes?) - but not as part of this PR ;-)