Skip to content
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

Allow to select the branch to release #1507

Merged
merged 8 commits into from
May 10, 2021
Merged

Allow to select the branch to release #1507

merged 8 commits into from
May 10, 2021

Conversation

VincentLanglet
Copy link
Member

@VincentLanglet VincentLanglet requested review from a team and OskarStark May 1, 2021 16:12
@VincentLanglet
Copy link
Member Author

I made the code BC for the controller which display the next release.
image

But should we update them in order to display all the branches ?
This way we won't miss a potential release (for instance for the [email protected]).

WDYT @sonata-project/contributors ?

@VincentLanglet VincentLanglet marked this pull request as draft May 1, 2021 16:24
@VincentLanglet
Copy link
Member Author

I need to make more test for release on master branch. But I'm currently getting

 You have reached GitHub hourly limit! Actual limit is: 60

@jordisala1991
Copy link
Member

I like the idea, and it is probably a good solution, but we have a problem with the github api calls. One question, does packagist expose an api for releases?

@VincentLanglet
Copy link
Member Author

I don't know why but I'm getting

[WARNING] Release is not needed

When trying to run the command with admin-bundle and master branch.

cc @OskarStark

@VincentLanglet
Copy link
Member Author

I like the idea, and it is probably a good solution, but we have a problem with the github api calls. One question, does packagist expose an api for releases?

It's not supposed to make a lot more calls than before.

  • When running bin/console release it's supposed to do the same calls.
  • On the controller, it will make more calls for project with multiple stable branch, I think block-bundle is the only one. So it's just like having one project more to check for release.

I'm not sure packagist would be better since we still have a lot of github checks to do. We should look for caching calls or having more call to github per hour...

@jordisala1991
Copy link
Member

we should have 5000 calls per hour: https://docs.github.com/es/rest/overview/resources-in-the-rest-api#rate-limiting

something is wrong here

@jordisala1991
Copy link
Member

Did you add your github token on .env?

@VincentLanglet
Copy link
Member Author

Did you add your github token on .env?

Yes. But when I dump the authenticate method it seems like it's not called.
It's like the config

    Github\Client:
        arguments:
            - '@Github\HttpClient\Builder'
        calls:
            - ['authenticate', ['%env(GITHUB_OAUTH_TOKEN)%', null, 'access_token_header']]
            - ['addCache', ['@Cache\Adapter\Redis\RedisCachePool']]

is not used

@VincentLanglet
Copy link
Member Author

Yes, if I call manually $this->github->authenticate it works.

@VincentLanglet
Copy link
Member Author

This also explain why the cache is not used on the website.

Now, how to fix this ?

@VincentLanglet
Copy link
Member Author

Adding

    _defaults:
        # The Github\Client is only calling authenticate/addCache when public (but I don't know why)
        public: true
        autowire: true
        autoconfigure: true

Does call authenticate

I don't know why it need to be public...

@VincentLanglet VincentLanglet marked this pull request as ready for review May 1, 2021 21:56
@@ -1,4 +1,10 @@
services:
_defaults:
# The Github\Client is only calling authenticate/addCache when public (but I don't know why)
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch, can you open an issue on the repo and ask?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should it be on the Github\Client repo or on the symfony repo ?

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why that would happen, just making Github\Client public fixes the issue or should all services defined there be public?

I've never used the commands.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just discovered that I don't need to add

    _defaults:
        # The Github\Client is only calling authenticate/addCache when public (but I don't know why)
        public: true
        autowire: true
        autoconfigure: true

If I remove the call

- ['addCache', ['@Cache\Adapter\Redis\RedisCachePool']]

Maybe it's related to the failure I get

                                                                                                                        
 [WARNING] Some commands could not be registered:                                                                       
                                                                                                                        

In getClientService.php line 53:
                      
  Connection refused  

The failure of one calls is denying every calls ? how to solve this ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sonata-project/contributors Any idea why the addCache call is disabling the github authentication ?

@OskarStark should we remove it ?

Copy link
Member

Choose a reason for hiding this comment

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

KnpLabs/php-github-api#947

Maybe this helps?

Copy link
Member Author

@VincentLanglet VincentLanglet May 9, 2021

Choose a reason for hiding this comment

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

Ok I found the reason.

When I correctly configure redis the authenticate call is made.
So it was related to the error

 [WARNING] Some commands could not be registered:                                                                       
                                                                                                                        

In getClientService.php line 53:
                      
  Connection refused  

Is there a way to add the addCache call only if redis server is started, in order to not lose the authenticate call when the redis server is not started ? ^^'


try {
$currentRelease = $this->releases->latest($repository);
$currentRelease = $this->releases->branchLatest($repository, $branch);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$currentRelease = $this->releases->branchLatest($repository, $branch);
$currentRelease = $this->releases->latestBranch($repository, $branch);

(I think)

Copy link
Member

Choose a reason for hiding this comment

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

The method fetch latest release from given branch, maybe should simply be latestRelease, or more verbose latestBranchRelease

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a latest method. It would be weird to add Release to this method and not the latest one.

Here I wanted to say it's the branch's latest release. So branchLatest.
Maybe latestForBranch is more clear ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I made the change @franmomu @jordisala1991

@VincentLanglet
Copy link
Member Author

I think this is ready to be merged :)

@VincentLanglet VincentLanglet merged commit 93b9f95 into sonata-project:master May 10, 2021
@VincentLanglet VincentLanglet deleted the allowToSelectBranches branch May 10, 2021 20:07
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.

4 participants