-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Adds option to check EOL via about command #37861
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
@@ -61,6 +67,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |||
/** @var KernelInterface $kernel */ | |||
$kernel = $this->getApplication()->getKernel(); | |||
|
|||
if ($input->getOption('eolCheck')) { | |||
if (self::isExpired(Kernel::END_OF_MAINTENANCE) && self::isExpired(Kernel::END_OF_LIFE)) { | |||
throw new RuntimeException(sprintf('Symfony "%s" is not maintained anymore, see https://symfony.com/releases to upgrade.', Kernel::VERSION)); |
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 would return 1 instead of throwing an exception. Also, I would check for end of maintenance, not end of life. People should upgrade as soon as possible, not as late as possible :)
The option name could be named --is-maintained
.
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.
you could use:
// configure() ...
$this
->setDescription('Displays information about the current project')
->addOption('is-maintained', null, InputOption::VALUE_NONE, 'Outputs the state of the Symfony kernel project version. Usefull for CI.')
...
and then
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (false !== $input->getOption('is-maintained')) {
if (self::isExpired(Kernel::END_OF_MAINTENANCE)) {
$io->error(\sprintf('Symfony version %s is not maintained anymore. Please consider upgrading.', Kernel:: VERSION));
return Command::FAILURE;
} else {
$io->success(\sprintf('Symfony version %s is maintained. EOM %s.', Kernel:: VERSION, self::daysBeforeExpiration(Kernel::END_OF_MAINTENANCE)));
return Command::SUCCESS;
}
}
// actual code ...
}
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.
thank you, I opted for 1
as I am not really sure when those constants where introduced and where available. Also I consider this an added option, therefore I only need the exit and carry on with the normal output of the command in case of success (which is already returning 1)
@fabpot done what you asked. |
I was trying to get a better description of the option, but then I realized why I rejected such a feature in the past. Nowadays, you install components and bundles independently. This command only gives you information about the Kernel component. So, you might have some components that are already outdated and you won't get the message. Closing as I don't want to give some wrong information. |
I see, does that means that I can potentially ran in the same repo a maintained Kernel component and a unmaintained other symfony component still compatible with that Kernel ? Would it be better suited as an option in the security-checker which is already inspecting composer.lock ? At that point one could opt-in and pass a flag to check the EOL of all symfony components included in the lock |
This is an action on the slack discussion I had last week that ended up with this PR #37754
Ideally I'd like to ran a command in my CI pipelines that can inform me automatically if the symfony I am running is EOL.
I thought the easiest, less invasive way is re-using the about command with an opt-in flag called
eolCheck