fix: always use LocalOnlyGitRepo source with dry_run command#1452
Conversation
80fcb9b to
1c32e4e
Compare
|
@imaginaris |
1c32e4e to
a36f316
Compare
|
@manicmaniac Done. |
|
@imaginaris Could you resolve the following lint error? https://github.com/danger/danger/actions/runs/7768462603/job/21188021833?pr=1452 |
a36f316 to
d9ba574
Compare
|
@manicmaniac Fixed. The CI job should pass now. |
|
|
||
| # Finds a Danger::CI class based on the ENV | ||
| def self.local_ci_source(env) | ||
| return Danger::LocalOnlyGitRepo if LocalOnlyGitRepo.validates_as_ci? env |
There was a problem hiding this comment.
regression: There should be a way to not fall into this if. I lost the capability to simulate my workflows locally that depend on the gitlab API, and the same will happen for other SCMs =/
In my scenario, I run bundle exec danger staging --pry with some gitlab envs such GITLAB_CI, etc.
There was a problem hiding this comment.
Upon reviewing the code, this MR makes much more sense than relying on CI load ordering.
My workaround for local simulation is to wrap the pry as it happens in the staging command, and run it as simple danger execution with the CI variables correctly set. Sorry for the confusion 😅
This PR should fix an issue that happens in my project.
We are running
danger dry_runon master branch (no PR) on Bitrise CI machines.After upgrading ruby version from 2.7.6 to 3.1.4 we started to get following error:
/Users/vagrant/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/danger-9.3.1/lib/danger/request_sources/bitbucket_cloud_api.rb:125:infetch_json': Credentials not available. Provide DANGER_BITBUCKETCLOUD_USERNAME, DANGER_BITBUCKETCLOUD_UUID, and DANGER_BITBUCKETCLOUD_PASSWORD as environment variables. (RuntimeError)`Even though we use Github.com repos and the same Danger version (9.3.1) as before.
The
CI.available_ci_sourcesis a set andlocal_ci_sourcemethod inenvironment_manager.rbuses a find function to search for the first valid source in that set. A set has undefined order of elements when treated as a list so when there are multiple CI sources valid (in my case Bitrise and LocalOnly), thelocal_ci_sourcemethod (theoretically) can return a different value each time.Returning
Danger::Bitrisevalue in my case can't work because there is no PR info in the system env when I'm runningdanger dry_runon no-PR build. (Bitrise class tries to init all RequestSource classes fromsupported_request_sourcesone by one).Long story short, when running
danger dry_runonlyLocalOnlyGitReposhould be used as a CI source.I did my best in this PR (I'm not a ruby dev 🙂) so any comments are welcome.