-
-
Notifications
You must be signed in to change notification settings - Fork 452
Added some dev tools & code sniffers #2400
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
can I ask you what do these lines do? |
|
This commands are executed after every
|
|
oki but is phpcs then doing something? will this impact also store owner that installed openmage with composer? |
|
No, it does nothing. Just make the tools available. Also no impact for composer installed shops. |
| }, | ||
| "scripts": { | ||
| "set-phpcs-paths": [ | ||
| "[ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/magento-ecg/coding-standard", |
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.
is there a way not to hardcode vendor?
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.
Tried with COMPOSER_VENDOR_DIR ....
... if you set COMPOSER_VENDOR_DIR as ENV variable it works ...
ddev config.yaml:
web_environment: [
COMPOSER_VENDOR_DIR=test
]
composer.json
"set-phpcs-paths": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || $COMPOSER_VENDOR_DIR/bin/phpcs --config-set installed_paths $COMPOSER_VENDOR_DIR/phpcompatibility/php-compatibility,$COMPOSER_VENDOR_DIR/magento-ecg/coding-standard",
"[ $COMPOSER_DEV_MODE -eq 0 ] || $COMPOSER_VENDOR_DIR/bin/phpcs -i"
],
Having custom vendor dir is an edge case ... i'd not change it.
Edit:
- set
vendor-dirin composer.json is not required in this case - set
vendor-dirin composer.json DOES NOT setCOMPOSER_VENDOR_DIR
|
This was the output for the This is the output for From the description, I should have installed those dev-tools and code sniffs, but I didn't, choosing to adopt the behavior of one OM user who is not aware of the changes adopted in this repository and doesn't even read the information, but just takes them as they are. Shouldn't this situation have been foreseen and the error avoided? Maybe we should have installed them, asked him if he installs them because maybe he doesn't want to, for all these situations the process had to end without errors. |
|
hmmmm it's weird, because the workflow run smoothly :-\ |
|
It looks like it’s the post-install-cmd’s bash syntax and Addison is on windows. |
|
My Linux distribution that I currently use in testing is Debian 10, but here I was asked to do a remote installation of OM + XAMPP + Phpstorm + Composer + ..., so that this person can start working and who knows help us in the future. I did not check this PR in Debian, but if one who uses Composer and is only familiar with the basic commands, he will be very disappointed when he has to deal with such errors. Until this change, things went as you can see from the screenshot without any issues. If those changes are specific to Linux, maybe they should be taken into account only there. Let's not forget an important aspect, Composer runs on MacOS, Linux and ... Windows. Also, OM can be tested in Windows with WAMP or XAMPP when the developers don't want to take everything to a distribution like Ubuntu. I met many people who used Phpstorm in Windows with remote Linux distributions. |
|
On Ubuntu 20.04, it all looks fine to me: I think that we need to have a platform independent composer script to run the phpcs config, like I did here for the release builder: https://github.com/fballiano/openmage/pull/3/files Or can we use a phpcs.xml file? I haven't used phpcs but I'll investigate it. |
|
mmmm it is true that on my mac it gives me this error: when on the first line I lunched it with php8.1 |
|
@fballiano - good observation. In my case PHP version installed by XAMPP is 8.1.6. Another condition to be evaluated and which creates confusion. We changed the minimum PHP requirement to version 7.3, but it is required >8.1, and this complicates things in the case of the current PR. |
|
@fballiano I'm curious what happens if you put this in your composer.json file "scripts": {
"test-php": "php --version"
}and run: |
that's because of the composer.lock... it's not an easy thing to fix unless we remove the composer.lock at all |
well, my system wide "php" command is 7.4, but there's absolutely no reason why anything should test for it, it should only test the currently running version. |
Right, but if composer invokes Edit: I mean makes sense to me in that composer would use the system wide PHP install, not that it should do that. |
|
|
|
This would probably work on linux/macOS: "set-phpcs-paths": [
"[ $COMPOSER_DEV_MODE -eq 0 ] || $(php -r 'echo PHP_BINARY;') vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility,vendor/magento-ecg/coding-standard",
"[ $COMPOSER_DEV_MODE -eq 0 ] || $(php -r 'echo PHP_BINARY;') vendor/bin/phpcs -i"
],But I think we should use PHP scripts for composer's scripts block instead of bash. There you can write platform-independent code. Ideally for this PR it could be done via phpcs.xml but I'm still looking into it. |
|
I first ran with composer.lock from the repo, but when I saw that an error appeared, I brought the whole directory to the previous stage then I deleted composer.lock. Unfortunately I didn't solve anything by running |
|
@justinbeaty you really are a machine, in the good way of course. |
Wait, now I'm wondering if what I wrote actually does work. I think it would call the same 7.4 binary 😅. However putting the script in |
|
@addison74 this is still because the script uses bash syntax. It definitely needs to change. |
|
I thought it wouldn't be called at all, sorry for that. I shut up 🤐 |
|
@justinbeaty - I just wanted to show you that the |
|
Let's just wait for @sreichel and see if he knows about using |
Yep, but i'm not familar with bash scripts ... maybe @colinmollenhour can help? |
Okay, then I'll try and whip up a composer PHP script that should work. Edit: #2467 |
I agree that running phpcs should be very easy so adding the dev dependencies and scripts makes sense. But, I would be in favor of removing the "post-*" hooks so users can run these manually if they actually want to use these tools, but otherwise there is no additional complication for using composer just to manage dependencies. Regarding supporting multiple platforms, I support it when it's easy but otherwise I'd like to see support focused around Docker since that is really the only practical platform-agnostic approach. So brew, XAMPP, yum, etc. should all be considered marginally supported and Docker should be the favored method. This way things like running code quality tools are exactly the same for all users because they are run inside a container. E.g. after installing Docker for Windows|Mac, which is super easy, one could simply run a command which invokes Docker which then invokes phpcs and the result is the same regardless of the dev's platform specifics. That is, all commonly used commands could be run through composer scripts with aliases: This would work with system-installed php if it was similar to the Docker environment, but the "composer" command itself does not need to use a system-installed php, it can be a wrapper for a docker command: Here is an example from my It may be necessary to build a custom composer container for openmage that extends the official composer one by adding some dependencies but that would be easy. |
I thought this one-line-command could be converted easily. :) I'd also prefer a more "docker focused" development, but #2466 shows that it is not so common. It would not came to my mind that we need something like a release-builder (#2165). My expectation was that most would use e.g. composer. Working with "plain" docker also requires some knowledge. Maybe we make some docs to a ddev based setup, thats easy to use. |



Description (*)
Install some dev-tools:
Install code sniffs:
Questions or comments
ToDos:
Contribution checklist (*)