Skip to content

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Feb 22, 2022

Resources:
https://symfony.com/doc/5.4/setup/flex_private_recipes.html
https://symfony.com/blog/symfony-flex-is-going-serverless

Relevant part:

The JSON files are stored in this repository and are generated by
GitHub Actions using this script > thanks to a custom recipe checker tool. The existing Flex server
endpoint will keep working for some time as a legacy service for applications that haven't been updated yet.

This PR adds the workflows used in symfony/recipes repository:

  1. Generating recipes structure - flex-update.yml

https://github.com/symfony/recipes/blob/master/.github/workflows/flex-update.yml
It calls this workflow: https://github.com/symfony/recipes/blob/main/.github/workflows/callable-flex-update.yml

which parses the recipes and creates proper files so that they can be accessed by Flex - it's pushed to the flex/main branch.

You can see that Symfony adds an additional argument, versions_json: https://github.com/symfony/recipes/blob/master/.github/workflows/flex-update.yml#L13-L17 This file (https://github.com/symfony/recipes/blob/master/.github/versions.json#L8 ) is used only for Symfony packages and automatically defines aliases for their packages (see: https://github.com/symfony-tools/recipes-checker/blob/86f5d7f8c12b8fa3faeadc5a5652aba1b2e369d2/src/GenerateFlexEndpointCommand.php#L44-L54)

  1. Creating a recipes archive

https://github.com/symfony/recipes/blob/master/.github/workflows/flex-update-achived.yml

This is required for the recipes:update command to work. See:
symfony/flex#857
symfony/recipes#1038
symfony-tools/recipes-checker#3
symfony/flex#845

Symfony has chosen manual trigger for now - this is fine, because it's a fallback in case something goes wrong in the update workflow and allos to rebuild the archive if needed. It's not needed on every push, because the archive should be updated during the update workflow (see "How it works" in symfony/flex#845 - symfony/recipes#1037 is the relevant PR that includes it in the flex-update workflow.

Other changes that are needed:

  1. The --force switch does not work for the official recipes as we're used to, see Fixed not working "--force" option if you want to reinstall a recipe symfony/flex#702 (and the updated --force description: https://github.com/symfony/flex/pull/714/files)

To execute the recipe once again we need to use the --force option combined with --reset option.
PR: symfony/flex#795

So, we will have to replace the mentions of composer recipes:install <edition> --force in manual installation doc with composer recipes:install <edition> --force --reset. Same for nightly and other tools.

  1. For PHP 8/8.1 we need [Composer] Allowed using symfony/flex v2 oss#44 - otherwise the downgrade that happens during the instalation process corrupts the instalation.

Migrations process

  1. We merge these PRs:
    Added Symfony serverless workflows #99
    [Composer] Allowed using symfony/flex v2 oss#44
  2. We can test the endpoint locally, by running:
composer config extra.symfony.endpoint "https://api.github.com/repos/ibexa/recipes/contents/index.json?ref=flex/main"
  1. We set a redirect from https://flex.ibexa.co to https://api.github.com/repos/mnocon/recipes/contents/index.json?ref=flex/main - this way we don't have to change the value in https://github.com/ibexa/website-skeleton/blob/3.3/composer.json#L98

We can do 1 and 2 right now, to test things - these steps are just preparation, only after step 3 our current solution (private Flex server) can be disabled and the new one will start working.

Testing process

If you'd like to see it in action locally you can use:
https://github.com/mnocon/website-skeleton/ (which uses our new endpoint endpoint: https://github.com/ibexa/website-skeleton/blob/3.3/composer.json#L98).
Install running:

composer create-project mnocon/website-skeleton:^4.0.x-dev --repository='{"type": "vcs","url": "https://github.com/mnocon/website-skeleton"}'

Generated recipes:
https://github.com/ibexa/recipes/tree/flex/main
https://github.com/ibexa/recipes/blob/flex/main/index.json

Remember about the --reset flag during manual installation.

@mnocon mnocon force-pushed the flex-serverless branch 2 times, most recently from cc35d27 to 31f8d57 Compare February 22, 2022 14:17
@mnocon mnocon marked this pull request as ready for review February 22, 2022 15:10
@mnocon mnocon force-pushed the flex-serverless branch 4 times, most recently from 584cdcb to ea94891 Compare February 23, 2022 08:29
@mnocon mnocon requested a review from ibexa-yuna February 23, 2022 08:30
@ibexa-yuna
Copy link
Contributor

ibexa-yuna commented Feb 23, 2022

Same for nightly and other tools.

Please create a corresponding PR.
https://github.com/ibexa/jenkins-pipelines

Also, what about post-install repository?

@mnocon
Copy link
Contributor Author

mnocon commented Feb 23, 2022

Update: I've switched the full archive creation back to manual, as Symfony does it (c3f2c8b ) and updated the PR description

@mnocon
Copy link
Contributor Author

mnocon commented Feb 23, 2022

Sure, PRs created:
https://github.com/ibexa/jenkins-pipelines/pull/1
https://github.com/ibexa/phpstorm-plugin/pull/50

Also, what about post-install repository?

This repo does not need to be changed - it's our own implementation based on the idea of Symfony Flex, the command composer ibexa:setup --platformsh will keep working as it currently works

@mnocon mnocon merged commit 68b9b8d into master Feb 28, 2022
@webhdx webhdx deleted the flex-serverless branch March 9, 2022 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants