8000 Update docker and test configs by hans-thomas · Pull Request #2678 · mongodb/laravel-mongodb · GitHub
[go: up one dir, main page]

Skip to content

Update docker and test configs #2678

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

Merged
merged 19 commits into from
Dec 4, 2023
Merged

Conversation

hans-thomas
Copy link
Contributor

Hello there,
I updated the Dockerfile and docker-compose files. I also added some scripts to the composer that might be used very often.

@hans-thomas hans-thomas marked this pull request as ready for review November 14, 2023 12:11
Copy link
Member
@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Apart from composer scripts, I don't think these changes improve anything.
Thanks for the suggestion.

@hans-thomas
Copy link
Contributor Author

Apart from composer scripts, I don't think these changes improve anything.

I don't want to improve performance or anything else. I just want to update the docker configuration to be more effective and make developing easier.

If you look at the current dockerfile, in the last line, it is installing dependencies and run the tests. which means to run the tests, I have to build the dockerfile each time?
It's obvious developers must build dockerfile the first time and then run the tests using command line inside of the countainer.

@hans-thomas
Copy link
Contributor Author

Another update for the project's structure can be using StyleCI instead of PHP Code Sniffer. StyleCI can be configured to fix the code style using an automated merge commit.
Fixing code style after every change (after the pipeline failed mostly😅) is annoying.

@GromNaN
Copy link
Member
GromNaN commented Nov 15, 2023

If you look at the current dockerfile, in the last line, it is installing dependencies and run the tests. which means to run the tests, I have to build the dockerfile each time? It's obvious developers must build dockerfile the first time and then run the tests using command line inside of the countainer.

The last line is the default command when you run the container.

docker-compose run --rm tests

Note that I don't use this docker image to develop because the integration with PHPStorm and xdebug set-by-step debugging is hard to setup.

So I just found that the memory limit is too low. This lines should be added after docker-php-ext-install -j$(nproc) zip.

    cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini && \
    echo "memory_limit=-1" >> /usr/local/etc/php/php.ini

Another update for the project's structure can be using StyleCI instead of PHP Code Sniffer. StyleCI can be configured to fix the code style using an automated merge commit.
Fixing code style after every change (after the pipeline failed mostly😅) is annoying.

Not all CS issues can be fixed automatically, but in 90% of cases, we could make it easier for external contributors to contribute by automatically committing modifications proposed by phpcbf.

@hans-thomas
Copy link
Contributor Author

The last line is the default command when you run the container.

It had never run tests on my computer. It is even mentioned here.

we could make it easier for external contributors to contribute by automatically committing modifications proposed by phpcbf.

So you mean it can be done automatically? How?

@GromNaN
Copy link
Member
GromNaN commented Nov 15, 2023

we could make it easier for external contributors to contribute by automatically committing modifications proposed by phpcbf.

So you mean it can be done automatically? How?

As proposed by @Treggats in #2664.

@hans-thomas
Copy link
Contributor Author

As proposed by @Treggats in #2664.

That's interesting, I might work on that PR next. Seems an important PR and the best opportunity for me to work with PHPStan.

@Treggats
Copy link
Contributor
Treggats commented Nov 15, 2023

As proposed by @Treggats in #2664.

Thanks for the reminder that I needed to check the test suite. Hope that I can open it pretty soon

Edit
I've opened #2664 for review again.

Dockerfile Outdated
Comment on lines 14 to 15
# Enable coverage mode in xdebug
RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/xdebug.ini
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Xdebug mode is set to coverage.

@hans-thomas
Copy link
Contributor Author

I don't have any more changes to propose and I think it's the end of this PR.
Please take every feature that you find helpful and revert the rest.

@hans-thomas
Copy link
Contributor Author

If you want to merge this PR, you can do it after merging #2664. I think there are some conflicts.

@hans-thomas
Copy link
Contributor Author

Conflicts resolved.


on:
push:
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
name: PHP v${{ matrix.php }} with MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }}
runs-on: "${{ matrix.os }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this change is based on a comment in another PR, but I wonder if it belongs in this PR. As in my eyes it is a code style thing, which adds a lot of noise to the PR. Personally I would create a separate PR to add these changes.

Though personally I don't see a benefit to these changes, but that's me and the project style is leading.

- name: Show PHP version
run: php -v && composer -V
- name: Show Docker version
extensions: "curl,mbstring,xdebug"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to the changes, as those are CS changes.

From the action-runners docs/readme

Both Xdebug and PCOV extensions are installed, but only Xdebug is enabled.

Does this get overridden with setting the extensions manually?

@GromNaN
Copy link
Member
GromNaN commented Dec 4, 2023

I updated the branch with the followings:

  • Revert the PHP_VERSION argument, so it's easy to test with other PHP versions. Even if that's not the main usage, but it would necessary to debug errors specific to a PHP version.
  • Set the ini config in phpunit.xml.dist, it's possible to change them by creating the phpunit.xml
  • Composer scripts automatically resolves binaries in vendor/bin
  • Add a default command for docker-compose run app, that install vendors and run tests. docker-compose run app bash is recommanded if you need to tests many times without restarting the container.

@GromNaN GromNaN changed the title Update structure Update docker and test configs Dec 4, 2023
@GromNaN GromNaN merged commit fc1f9cc into mongodb:4.1 Dec 4, 2023
@GromNaN
Copy link
Member
GromNaN commented Dec 4, 2023

Thank you @hans-thomas

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.

3 participants
0