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

update docker images to use PHP 8 #1869

Merged
merged 8 commits into from
Sep 24, 2022
Merged

update docker images to use PHP 8 #1869

merged 8 commits into from
Sep 24, 2022

Conversation

nodiscc
Copy link
Member

@nodiscc nodiscc commented Aug 11, 2022

@nodiscc nodiscc added bug it's broken! docker containers & cloud dependencies Pull requests that update a dependency file labels Aug 11, 2022
@nodiscc nodiscc added this to the 0.12.2 milestone Aug 11, 2022
Copy link
Member

@ArthurHoaro ArthurHoaro left a comment

Choose a reason for hiding this comment

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

Checking with quick local build, you need to update .docker/services.d/php-fpm/run executable to php-fpm8.

Copy link
Member

@virtualtam virtualtam left a comment

Choose a reason for hiding this comment

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

Main image tested locally ✔️

After running some quick tests, the Alpine test image does not seem to provide a environment suitable to running tests, which may point to potential issues with the main image:

  • the test targets depend on the the translate target, which fails due to using find's execdir flag
  • 322 tests fail with PHP parsing errors (this may be related to the currently pinned PHPUnit version)
  • 7 tests fail with errors related to filesystem permissions (IIRC this is not new and dates back to running test suites on Alpine images)

I'm attaching the output of:

$ vendor/bin/phpunit --bootstrap tests/bootstrap.php --testsuite unit-tests

for reference: tests.log

@nodiscc
Copy link
Member Author

nodiscc commented Sep 4, 2022

I also get these results with

git clone -b docker-alpine-php8 https://github.com/shaarli/Shaarli
cd Shaarli
sudo docker build --no-cache -f tests/docker/alpine316/Dockerfile .
# Successfully built 8b37e75ac81f
sudo docker run -it --rm --mount type=bind,source=/home/user/Shaarli,destination=/shaarli --entrypoint=/bin/sh 8b37e75ac81f
/shaarli # make test
  • Busybox's find does not support -execdir, makefile target must be rewritten
  • PHPUnit failures: is PHPUnit supposed to support PHP8 at all? Only PHP7 is mentioned at https://phpunit.de/getting-started/phpunit-9.html I couldn't upgrade PHPUnit to ^9.5 because of this error:
/shaarli # composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/phpunit[9.5.0, ..., 9.5.24] require php >=7.3 -> your php version (7.1.29; overridden via config.platform, actual: 8.0.22) does not satisfy that requirement.
    - Root composer.json requires phpunit/phpunit ^9.5 -> satisfiable by phpunit/phpunit[9.5.0, ..., 9.5.24].

@nodiscc
Copy link
Member Author

nodiscc commented Sep 13, 2022

After setting in composer.json

    "require-dev": {
        ...
        "phpunit/phpunit": "^8.0 || ^9.0"

and running composer update --ignore-platform-req=php, we are down to 7 failures:

/shaarli # make test
-------
PHPUNIT
-------
PHPUnit 9.5.24 #StandWithUkraine

Warning:       No code coverage driver available
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

..F............................................................  63 / 982 (  6%)
............................................................... 126 / 982 ( 12%)
............................................................... 189 / 982 ( 19%)
............................................................... 252 / 982 ( 25%)
............................................................... 315 / 982 ( 32%)
............................................................... 378 / 982 ( 38%)
............................................................... 441 / 982 ( 44%)
............................................................... 504 / 982 ( 51%)
............................................................... 567 / 982 ( 57%)
............................................................... 630 / 982 ( 64%)
.........F.F......F............................................ 693 / 982 ( 70%)
............................................................... 756 / 982 ( 76%)
.....................................F......................... 819 / 982 ( 83%)
............................................................... 882 / 982 ( 89%)
............................................................... 945 / 982 ( 96%)
E.........................F..F.......                           982 / 982 (100%)

Time: 00:02.751, Memory: 38.00 MB

There was 1 error:

1) Shaarli\Security\LoginManagerTest::testCheckCredentialsFromUnreachableLdap
Error: Call to undefined function Shaarli\Security\ldap_connect()

/shaarli/application/security/LoginManager.php:201
/shaarli/application/security/LoginManager.php:212
/shaarli/application/security/LoginManager.php:154
/shaarli/tests/security/LoginManagerTest.php:341
/shaarli/vendor/bin/phpunit:123

--

There were 7 failures:

1) Shaarli\HistoryTest::testConstructNotWritable
Failed asserting that exception of type "Exception" is thrown.

/shaarli/vendor/bin/phpunit:123

2) Shaarli\Helper\FileUtilsTest::testWriteWithoutPermission
Failed asserting that exception of type "Shaarli\Exceptions\IOException" is thrown.

/shaarli/vendor/bin/phpunit:123

3) Shaarli\Helper\FileUtilsTest::testWriteFolderPermission
Failed asserting that exception of type "Shaarli\Exceptions\IOException" is thrown.

/shaarli/vendor/bin/phpunit:123

4) Shaarli\Helper\FileUtilsTest::testClearFolderOutsideOfShaarliDirectory
Failed asserting that exception of type "Shaarli\Exceptions\IOException" is thrown.

/shaarli/vendor/bin/phpunit:123

5) Shaarli\Updater\LegacyUpdaterTest::testWriteUpdatesFileNotWritable
Failed asserting that exception of type "Exception" is thrown.

/shaarli/vendor/bin/phpunit:123

6) Shaarli\Updater\UpdaterTest::testReadEmptyUpdatesFile
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
+    0 => 'test'
 )

/shaarli/tests/updater/UpdaterTest.php:75
/shaarli/vendor/bin/phpunit:123

7) Shaarli\Updater\UpdaterTest::testWriteUpdatesFileNotWritable
Failed asserting that exception of type "Exception" is thrown.

/shaarli/vendor/bin/phpunit:123

ERRORS!
Tests: 982, Assertions: 4145, Errors: 1, Failures: 7.
make: *** [Makefile:69: test] Error 2

nodiscc added a commit that referenced this pull request Sep 13, 2022
- tests are failing with php8 and phpunit 7.x
- ref. #1869
@ArthurHoaro
Copy link
Member

Great job!

For the LDAP error, it's probably just missing php8-ldap. BTW, we should probably add it in the main image as well if we want that feature to be available when installing Shaarli through our Docker, right?

The other issues seem all related to permissions. My guess is that the tests run as root, so it doesn't raise permission issues like it would with a regular user. I'm not sure what's the best approach here.

Depending on how easy it is to fix, since the main image build is broken, it could maybe make sense to merge it first and fix the tests Dockerfiles later?

Copy link
Member

@virtualtam virtualtam left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@virtualtam
Copy link
Member

The other issues seem all related to permissions. My guess is that the tests run as root, so it doesn't raise permission issues like it would with a regular user. I'm not sure what's the best approach here.

I did similar work for another project to setup reference Debian and Ubuntu environments with Docker and run builds as an unprivileged user: https://github.com/virtualtam/ccache_exporter/tree/main/integration

merge it first and fix the tests Dockerfiles later

Agreed, I'll see how I can port the aforementioned work so we can run PHP tests using unprivileged users 👍

@jlkDE
Copy link

jlkDE commented Sep 24, 2022

I just tried out this PR to fix my personal container build of Shaarli, so far everything seems to work, good job!
One thing I noticed is that the date format of entries changed: From 30. Januar 2022 um 12:44:20 UTC * in my case to simply 2022 M01 30 12:44:20 UTC *.

@nodiscc
Copy link
Member Author

nodiscc commented Sep 24, 2022

For the LDAP error, it's probably just missing php8-ldap

-> #1890

merge it first and fix the tests Dockerfiles later

Let's merge it as-is and tackle remaining problems in separate issues. Thanks for your help.

@nodiscc nodiscc merged commit dc589b7 into master Sep 24, 2022
@nodiscc nodiscc deleted the docker-alpine-php8 branch September 24, 2022 15:58
@nodiscc nodiscc mentioned this pull request Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug it's broken! dependencies Pull requests that update a dependency file docker containers & cloud
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing Github actions workflow "Build/push Docker image (master/latest)"
4 participants