Skip to content

[JENKINS-62130] Add Symbols to extenders of SCMSourceTrait and friends#886

Closed
kshultzCB wants to merge 101 commits intojenkinsci:masterfrom
kshultzCB:add-symbols
Closed

[JENKINS-62130] Add Symbols to extenders of SCMSourceTrait and friends#886
kshultzCB wants to merge 101 commits intojenkinsci:masterfrom
kshultzCB:add-symbols

Conversation

@kshultzCB
Copy link
Contributor

@kshultzCB kshultzCB commented Apr 30, 2020

JENKINS-62130 - Add @Symbol annotations to extenders of scm-api:SCMSourceTrait

Checklist

  • I have read the CONTRIBUTING doc
  • I have referenced the Jira issue related to my changes in one or more commit messages
  • Unit tests pass locally with my changes
  • No Javadoc warnings were introduced with my changes
  • No spotbugs warnings were introduced with my changes

Types of changes

  • New feature (non-breaking change which adds functionality)

Further comments

The @Symbol annotation can make it easier for things outside of the Git plugin, such as CasC and Job DSL. The Git plugin has @Symbol annotations for many of its classes which extend scm.api.trait.SCMSourceTrait - this PR adds similar @Symbols to remaining classes.

Additionally, because GitBrowserSCMSourceTrait has a DataBoundConstructor which takes a GitRepositoryBrowser as an argument, I've added @Symbols to classes which extend GitRepositoryBrowser as well.

MarkEWaite and others added 30 commits April 27, 2020 07:49
Pipeline syntax creates the simpler form once symbols are defined.
Randomized testing checks the various forms of checkout scm extensions.
Don't test in the git plugin, that's the responsibility of the
plugin that provides the implementation.
@kshultzCB kshultzCB changed the title [JENKINS-62130] Add Symbols to extenders of SCMSourceTrait [JENKINS-62130] Add Symbols to extenders of SCMSourceTrait and friends May 5, 2020
Copy link
Member

@fcojfernandez fcojfernandez left a comment

Choose a reason for hiding this comment

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

The PR seems to be ok, but in those cases where the symbol changes the expected key word for CasC configuration, the yaml files have to be updated. For example, I would expect that https://github.com/jenkinsci/git-plugin/blob/master/src/test/resources/jenkins/plugins/git/browsers-casc.yaml should have to be updated. (See my comment in gitLabBrowser)
And for those cases we should add a warning in the README file.

}

@Extension
@Symbol("gitLabBrowser")
Copy link
Member

Choose a reason for hiding this comment

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

this is a change that would impact in the yaml configuration for CasC. So far, the exportation / configuration would have expected "gitLab":


But with this change, the key word would be "gitLabBrowser". The former yaml configuration files have to be changed.

Copy link

Choose a reason for hiding this comment

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

CasC is able to recognize several values for the same descriptor, but it should be verified both of them work now.

Copy link
Member

Choose a reason for hiding this comment

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

good to know! I thought CasC would only take into account one of them. That explains why browsers-casc.yaml didn't have to be updated

Copy link
Contributor

@MarkEWaite MarkEWaite May 6, 2020

Choose a reason for hiding this comment

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

This specific example is more complicated than you might expect (and thus even more interesting to assure that retain compatibility).

The GitLab plugin provides a repository browser with class name GitLabBrowser. It takes no arguments and appears in the pick list as "GitLab".

The Git plugin provides a repository browser with a class name GitLab. It takes one mandatory argument and an optional argument and appears in the pick list as "gitlab".

I assumed (possibly incorrectly) that the JCasC symbol "gitLabBrowser" was derived from the repository browser provided by the GitLab plugin, not from the repository browser provided by the Git plugin.

Copy link
Contributor

Choose a reason for hiding this comment

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

CasC is able to recognize several values for the same descriptor, but it should be verified both of them work now.

That gives me hope. We might be able to define a symbol for compatibility with existing JCasC YAML files and also define a shorter or clearer symbol as the preferred symbol.

What types of things would we need to test to confirm that works as expected?

  • JCasC config file for git plugin 4.2.2 (current release) loads correctly into new version
  • JCasC config file for git plugin 4.3 (next release) exports correctly from JCasC page
  • JCasC config file for git plugin 4.3 (next release) loads correctly
  • Pipeline definitions from git plugin 4.2.2 (current release) load correctly in new version
  • Pipeline syntax editor for git plugin 4.3 (next release)

Copy link
Member

Choose a reason for hiding this comment

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

What types of things would we need to test to confirm that works as expected?

Regarding the JCasC testing, that's what have to be done. Regarding the pipeline, I'm not sure

I assumed (possibly incorrectly) that the JCasC symbol "gitLabBrowser" was derived from the repository browser provided by the GitLab plugin, not from the repository browser provided by the Git plugin.

The BrowsersJCasCCompatibilityTest (via the browsers-casc.yaml) is testing the former gitlab key word and it's working. In a production environment where we have installed the gitlab-plugin and the git-plugin, if we can have both repository browsers, we have to check which key word is exported for each case. If they are not the same (gitLabBrowser vs gitlab), there should be no problem, since the configurators will be able to distinguish between them. But if they are the same with this new Symbol, then I foresee we'd get an error. I guess this check must be done with the current release and with this PR merged

Copy link
Member

Choose a reason for hiding this comment

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

CasC as of a few versions now considers all symbols on import and on export will show the first one in the array

@MarkEWaite MarkEWaite added the enhancement Improvement or new feature label May 7, 2020
@MarkEWaite MarkEWaite mentioned this pull request Jun 8, 2020
10 tasks
@MarkEWaite
Copy link
Contributor

I'm closing this pull request as idle. I will continue to track the work in my https://github.com/MarkEWaite/git-plugin/tree/add-symbols branch and will open a new pull request as time and testing capacity allows.

@MarkEWaite MarkEWaite closed this Sep 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement or new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants