-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
[CI] Working round PHPStan dependencies #1918
Conversation
composer.json
Outdated
"auto-scripts": { | ||
"cache:clear --no-warmup": "symfony-cmd", | ||
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd" | ||
}, |
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.
Should be part of website build script or Dockerfile, not core code composer.json
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'm not sure about this specific change. As a developer, I use bolt/core
directly when working on Bolt. Did you remove it because it's problematic, or just as part of cleaning up?
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.
Understood.
This part it problematic, as it requires whole project to be runnable, before even running codding standard or PHPStan or PHP linter in CI.
So if code is broken, the composer install will fail here and no CI tool will help us.
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 that really a problem, though? If the code is broken, CI should fail, and we'd need to fix that regardless.
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 is, because it fails on composer install
and not on one of 8 jobs we have now. It's false positive actually. The point of CI is to have the minimal scope the error appears in. That's why the PHPStan should be decouple from project's container.
In a correct project setup, this shoud be part of build script, Docker, npm run
etc. Same way assets build is.
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.
Several are breaking with the following error 🤔
PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/home/runner/work/core/core/bin/../.env" environment file. in /home/runner/work/core/core/vendor/symfony/dotenv/Dotenv.php:565
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.
That's the problem I got at first place. The .env file should not be required to install dependencies. Only after
This the issue stacking I talked about. --no-scripts probably disables some process outside composer.json
that some package rely on by convention.
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.
Right, it's breaking here: https://github.com/bolt/core/blob/master/bin/console#L18-L23
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}
$_SERVER['APP_ENV']
isn't set, so it attempts to read .env
, which doesn't exist.
In Travis the env settings are set from .env.dist
by:
export $(grep -v '^#' .env.dist | xargs -d '\n')
Should the github workflow do something similar?
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.
Why not have the file with name .env
by default? It would remove this hidden dependency.
The convention is to have environment-based configs if needed:
- .env.prod
- .env.local
- .env.test
etc
See Symfony post about it: https://symfony.com/doc/4.1/configuration/dot-env-changes.html
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 commited it, just to try it out. I don't think it will be enough
Travis now fails on another single random Behat tests. It seems unrelated to this PR. Does it happen often with Behat? It seems not very useful to have random fails all the time 🥺 |
Yes, it does happen quite often, but is goes in waves. Some weeks it's more than others (this week is definitely a "more" week), and it also happens more often when we assume Travis is busy, like during working hours in USA time. |
I see. That must be very frustrating for daily development of whole Bolt project. After we migrate the basic stuff to Github Actions, maybe Travis will have less work to handle and handle it better. If not, I'll try look into it. CI must be flawless and reliable :) |
"Frustrating" is a bit too much, but it can surely be annoying.. We sometimes call it "the little Travis dance" 🤣 |
…om copied composer.json from symfony monorepo
a0bf303
to
b7b8edb
Compare
Joining the My 2 cents: I totally get what @TomasVotruba says about decoupling. And gosh wouldn't I love the CI running smoother/faster 😍 If it's one or the other, faced with better CI setup vs better experience for contributors , I'd much rather have the latter. IMHO, when people want to contribute, we should make it as easy as possible, which means less steps to setup (so no extra Contributors by and large will know how to clone/composer install, but they'll have to read to know about running a |
I agree. What about best of both worlds? :)
Have a single script that will be skipped if in CI. |
I haven't looked at Also, I agree with the both of you: We do want to make the threshold for developers who want to contribute on Bolt to be as low as possible. And, as silly as it may sound: people are terrible at reading instructions. So, if we could make it so that we have a pleasant developer experience and make it to CI runs smoothly, that'd be the absolute best! ^_^ |
Not trying to rush you, but I was curious on what the status on this PR is. Can you add |
No problem :). I'm now focused on another project, so I'll look into it on Wednesday. If you have time, feel free to try it. It's just adding 1 package to composer and custom PHP script that would handle the CI check first. |
Surpassed by #1961 |
CI check for #1917 (comment)