voxpupuli / modulesync

Synchronize common files across your Git repositories.
Apache License 2.0
105 stars 49 forks source link

2.3.0 fails to create GitHub PRs #250

Open bastelfreak opened 2 years ago

bastelfreak commented 2 years ago

Hi, I installed the latest 2.3.0 release and tried to create a new PR:

$ bundle exec msync update --message "modulesync 5.2.0" --pr --pr-labels modulesync --pr-title "modulesync 5.2.0" --filter grafana
Syncing 'puppet-grafana'
bundler: failed to load command: msync (/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync)
/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://github.com/repos/voxpupuli/puppet-grafana/pulls?base=master&head=voxpupuli%3Amodulesync&state=open: 404 - Not Found (Octokit::NotFound)
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/middleware.rb:19:in `block in call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/response.rb:61:in `on_complete'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/middleware.rb:18:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-retry-1.0.3/lib/faraday/retry/middleware.rb:140:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:154:in `build_response'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/connection.rb:516:in `run_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/connection.rb:200:in `get'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/connection.rb:156:in `request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/connection.rb:84:in `paginate'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/client/pull_requests.rb:20:in `pull_requests'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/git_service/github.rb:31:in `_open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/git_service/base.rb:11:in `open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/source_code.rb:64:in `open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:146:in `manage_module'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:171:in `block in update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:170:in `each'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:170:in `update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/cli.rb:149:in `update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/cli/thor.rb:21:in `start'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/bin/msync:24:in `<top (required)>'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `load'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `<top (required)>'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `load'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `kernel_load'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:23:in `run'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:477:in `exec'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:31:in `dispatch'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:25:in `start'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/exe/bundle:49:in `block in <top (required)>'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/exe/bundle:37:in `<top (required)>'
    from /usr/bin/bundle:23:in `load'
    from /usr/bin/bundle:23:in `<main>'

I guess /repos/ in the url is bogus?

ekohl commented 2 years ago

No, that looks correct but only if it's using api.github.com as the domain. https://api.github.com/repos/voxpupuli/puppet-grafana/pulls?base=master&head=voxpupuli%3Amodulesync&state=open does work for me. But we don't configure the domain at all so I wonder if this is something in your settings.

ekohl commented 2 years ago

Oh, of course just after I post that I see this: Edit: here's the code where it is configured: https://github.com/voxpupuli/modulesync/blob/39863fc23291e232bbb6dbad9a3a69a0c0f689ea/lib/modulesync/git_service/github.rb#L13-L16

This determines it: https://github.com/voxpupuli/modulesync/blob/39863fc23291e232bbb6dbad9a3a69a0c0f689ea/lib/modulesync/git_service.rb#L52-L76

The guess method is this: https://github.com/voxpupuli/modulesync/blob/39863fc23291e232bbb6dbad9a3a69a0c0f689ea/lib/modulesync/git_service/base.rb#L23-L29

So that should be overridden in github.rb so rewrite github.com to api.github.com.

The short term workaround is to set GITHUB_BASE_URL=https://api.github.com as an env var now.

bastelfreak commented 1 year ago

my understanding is that endpoint = sourcecode.options.dig(type, :base_url) checks our modulesync.yml for a base_url setting. We don't have that: https://github.com/voxpupuli/modulesync_config/blob/f14a18d2ae681a4c973b3e898ab16e384046ca45/modulesync.yml#L1-L6

If I add: base_url: "https://api.github.com/"

msync still fails:

$ bundle exec msync update --message "modulesync 5.3.0" --pr --pr-labels modulesync --pr-title "modulesync 5.3.0" --filter yum
Syncing 'puppet-yum'
bundler: failed to load command: msync (/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync)
/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://github.com/repos/voxpupuli/puppet-yum/pulls?base=master&head=voxpupuli%3Amodulesync&state=open: 404 - Not Found (Octokit::NotFound)
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/middleware.rb:19:in `block in call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/response.rb:61:in `on_complete'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/middleware.rb:18:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/middleware/follow_redirects.rb:61:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-retry-1.0.3/lib/faraday/retry/middleware.rb:140:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/rack_builder.rb:154:in `build_response'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/connection.rb:516:in `run_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/connection.rb:202:in `get'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/sawyer-0.9.2/lib/sawyer/agent.rb:99:in `call'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/connection.rb:156:in `request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/connection.rb:84:in `paginate'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/client/pull_requests.rb:20:in `pull_requests'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/git_service/github.rb:31:in `_open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/git_service/base.rb:11:in `open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/source_code.rb:64:in `open_pull_request'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:146:in `manage_module'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:171:in `block in update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:170:in `each'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:170:in `update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/cli.rb:149:in `update'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/cli/thor.rb:21:in `start'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/bin/msync:24:in `<top (required)>'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `load'
    from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `<top (required)>'
    from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `load'
    from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `kernel_load'
    from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:23:in `run'
    from /usr/lib/ruby/3.0.0/bundler/cli.rb:486:in `exec'
    from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /usr/lib/ruby/3.0.0/bundler/cli.rb:31:in `dispatch'
    from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /usr/lib/ruby/3.0.0/bundler/cli.rb:25:in `start'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
    from /usr/lib/ruby/3.0.0/bundler/friendly_errors.rb:120:in `with_friendly_errors'
    from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
    from /usr/bin/bundle:25:in `load'
    from /usr/bin/bundle:25:in `<main>'

but with export GITHUB_BASE_URL="https://api.github.com" it passes :thinking:

rwaffen commented 2 months ago

just FYI: still problematic with 3.3.x