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

What's the expected implementation for a request source "validates_as_ci" method? #1417

Open
sphanley opened this issue Jan 26, 2023 · 2 comments
Labels

Comments

@sphanley
Copy link
Contributor

sphanley commented Jan 26, 2023

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. BitBucket Cloud and BitBucket Server 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 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?

@orta
Copy link
Member

orta commented Jan 27, 2023

if I recall, some environments can be just used for CI and others can be just used for code review and these were used to determine error messaging but it's been a few years now

@Pinkyrose67

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants