What's the expected implementation for a request source "validates_as_ci" method?
- Dominant language
- Ruby
- Stars
- 5.7k
- Forks
- 488
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to understand the intended expectations around the `validates_as_ci` method of the RequestSource class. In the base class, it provides an implementation whose intention makes sense:
# @return [Boolean] whether scm.origins is a valid git repository or not
def validates_as_ci?
!!self.scm.origins.match(%r{#{Regexp.escape self.host}(:|/)(.+/.+?)(?:\.git)?$})
end
However, the subclasses seem to vary wildly in their approach to overriding this method. For example, Github [just returns true](https://github.com/danger/danger/blob/master/lib/danger/request_sources/github/github.rb#L52-L54). [BitBucket Cloud](https://github.com/danger/danger/blob/master/lib/danger/request_sources/bitbucket_cloud.rb#L29-L32) and [BitBucket Server](https://github.com/danger/danger/blob/master/lib/danger/request_sources/bitbucket_server.rb#L40-L43) both return true as well, but they don't seem as sure about it. VSTS will only return true if `environment['BUILD_REPOSITORY_PROVIDER']` is equal to `TfsGit`, which will only be the case when running on an Azure Pipelines CI agent – meaning this RequestSource can't be used locally (something I tweaked in #1416). [Gitlab](https://github.com/danger/danger/blob/f08c505378aa1fd1f24e6b6656bcebe34c6a6d9c/lib/danger/request_sources/gitlab.rb#L48-L57) uses this as a way to validate the format of its host, and returns a hard-coded value of true unless the validation raised an exception.
I'm having trouble wrapping my head around what it means, conceptually, for a Request source to "validate as CI". Isn't that the responsibility of a CI source? Is there a compelling reason for this method to exist, or should it be folded into `validates_as_api_source`? Or should child classes simply defer to the implementation of the parent class?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.