-
Notifications
You must be signed in to change notification settings - Fork 178
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
Refactor docker setup #339
base: master
Are you sure you want to change the base?
Conversation
3d949d9
to
1b00de4
Compare
|
efa71ef
to
88710d0
Compare
@@ -90,7 +90,7 @@ public function getMimeTypesFromCategory($category) | |||
$v = new testValidatorFile(); | |||
$t->is($v->guessFromFileBinary($tmpDir.'/test.txt'), 'text/plain', '->guessFromFileBinary() guesses the type of a given file'); | |||
$t->is($v->guessFromFileBinary($tmpDir.'/foo.txt'), null, '->guessFromFileBinary() returns null if the file type is not guessable'); | |||
$t->like($v->guessFromFileBinary('/bin/ls'), (PHP_OS != 'Darwin') ? '/^application\/x-(pie-executable|executable|sharedlib)$/' : '/^application/octet-stream$/', '->guessFromFileBinary() returns correct type if file is guessable'); | |||
$t->is($v->guessFromFileBinary('/usr/bin/file'), 'application/x-pie-executable', '->guessFromFileBinary() returns correct type if file is guessable'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this make the check pass only under some OS/distros? In other words, do we want to tests to only work under the docker setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, this is to simplify the tests and the pipelines IMO.
Having a reliable docker setup would mean that we can rely on a single and common OS where tests are run.
Otherwise, to be consistent, we would need to have a pipeline testing that part for different OSes.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely great that there's a consistent setup to run tests in, specially one that it can be used to easily run them against multiple php versions without having to maintain that mess locally – it's great for that and I'm all for it.
At the same time, it seems a pity that we opt to drop the possibility of easily running (by easy I mean having them pass) the whole test suite in different environments (be it macos, windows or some random linux distro) and adding the requirement to install/start/use docker to run the test suite.
Also, by making it less easy to run the tests in multiple contexts (e.g. by developers) we also lose some visibility into scenarios where the code&tests may be failing outside of the static docker setup which we may end up finding only when already running the code in some production server, where the set up is always going to be different than the docker one.
Otherwise, to be consistent, we would need to have a pipeline testing that part for different OSes.
I don't think we need to have CI under different OS. That line was already updated a few times over the years to account for some OS specificities that different developers bumped into. Isn't it possible to tweak it to include whatever alpine does differently, and allow the test suite to continue to run (read pass) without docker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: One way to at least avoid different distro layouts might be to test the function against PHP_BINARY
which should always return an executable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mentalstring I like your suggestion to use PHP_BINARY
! nice trick! I applied the change and tests passed 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, another idea to get this to run across different systems, hopefully definitely.
I don't see a good reason to be doing this test against a random executable file which may return different things in different systems – the binary
in the name of the function refers to using the system file
util, not that it only tests binary files.
Hence, instead of PHP_BINARY
, test it against __FILE__
and expect 'text/x-php'
– from a quick test, this works both in linux and macos (guessFromFileBinary()
doesn't work in windows).
a6463df
to
23cd8a0
Compare
Please update the |
23cd8a0
to
2221e70
Compare
@connorhu @mentalstring I would need some help here: I did not setup any MySQL server and the tests are all green. Something is weird IMO |
@thePanz Anno I started looking at the possibility of psr-4 migration and even with obvious problems the test was green with lime. Then I began to port the test system to phpunit because I found lime to be totally unreliable. |
2221e70
to
d3d624b
Compare
Not sure if this is what you are referring to, but I think only Currently, running tests with the It also hides a bunch notices/warnings (e.g. try |
Speaking of tests and refactoring the docker setup, I think |
docker-compose.yml
just
for automation and scripting (requires: https://just.systems )