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

[JENKINS-42971] GitSCMFileSystem consumes environment and expands branch name #1305

Merged

Conversation

MartinKosicky
Copy link
Contributor

@MartinKosicky MartinKosicky commented Aug 2, 2022

JENKINS-42971 Expand environment for branch names

GitSCMFileSystem now implements new SCM Builder APi that receives the Run that can is used to expand branch name with environment variables.

@MartinKosicky
Copy link
Contributor Author

Hmm i wonder what the "/* Unreliable on Windows and not a platform specific test */" means in the failing test...

@MarkEWaite
Copy link
Contributor

Hmm i wonder what the "/* Unreliable on Windows and not a platform specific test */" means in the failing test...

:) It means that the test has been unreliable in the past on Windows and the maintainers did not have time to understand why it was unreliable on Windows. History of that is captured in the commit messages in case you want to see the sordid details.

@MartinKosicky MartinKosicky force-pushed the lightweight_checkout_expand_params branch from af89b80 to a69a857 Compare August 2, 2022 13:09
@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Aug 2, 2022

:) It means that the test has been unreliable in the past on Windows and the maintainers did not have time to understand why it was unreliable on Windows. History of that is captured in the commit messages in case you want to see the sordid details.

Hmm so I understand that I should just ammend commit and run it again as there might be a chance I didnt break it. I was not able to debug the test in my Idea for some strange reason, so I cannot tell if this test was affected by my changes

Edit: Ok I was able to run it in debugger and it was probabbly not related to my changes :)

pom.xml Outdated Show resolved Hide resolved
pom.xml Outdated
Comment on lines 270 to 273
<pluginRepository><!-- TODO FOR DRAFT -->
<id>incrementals.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</pluginRepository>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<pluginRepository><!-- TODO FOR DRAFT -->
<id>incrementals.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/incrementals/</url>
</pluginRepository>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must say that I wasnt able to compile it locally without these temporary .pom changes, but I assume they will be removed before it will be merged

Co-authored-by: Jesse Glick <[email protected]>
@github-actions github-actions bot added the test label Aug 3, 2022
@MartinKosicky
Copy link
Contributor Author

I did a small refactor of the calculation of the headName. I dont know what is the best practice in this project, I made a dedicated public static method, so that it could be tested standalone. Do you prefer a utility class or can we leave it as is ?

@MartinKosicky MartinKosicky marked this pull request as ready for review August 3, 2022 19:35
@MartinKosicky MartinKosicky force-pushed the lightweight_checkout_expand_params branch from 4743bb8 to d7159dc Compare August 3, 2022 19:37
@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Aug 3, 2022

I need it in incrementals, so I can make an integration test in workflow-cps, so i converted it to to PR (removed draft)

@jglick
Copy link
Member

jglick commented Aug 5, 2022

I need it in incrementals, so I can make an integration test in workflow-cps, so i converted it to to PR (removed draft)

Incrementals are published from draft PRs.

@jglick jglick marked this pull request as draft August 5, 2022 14:08
@jglick jglick added enhancement Improvement or new feature and removed dependencies Dependency related change test labels Aug 5, 2022
pom.xml Outdated
@@ -61,7 +61,7 @@
<revision>4.11.5</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.303.3</jenkins.version>
<jenkins.version>2.319.3</jenkins.version>
Copy link
Member

Choose a reason for hiding this comment

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

Update

<artifactId>bom-2.303.x</artifactId>
accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok i updated it, I hope correctly

private final String headName;
private final String prefix;

public HeadNameResult(String headName, String prefix) {
Copy link
Member

Choose a reason for hiding this comment

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

Stylistically I would recommend

Suggested change
public HeadNameResult(String headName, String prefix) {
private HeadNameResult(String headName, String prefix) {

and then moving calculateHeadName inside this nested class, and renaming it accordingly (to simply calculate, or create, or make, or of, etc.).

@@ -283,15 +284,66 @@ public boolean supportsDescriptor(SCMSourceDescriptor descriptor) {
return AbstractGitSCMSource.class.isAssignableFrom(descriptor.clazz);
}

public static class HeadNameResult
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static class HeadNameResult
static class HeadNameResult

Not used outside this class and the test, right?

(In which case you could also simplify a bit by dropping private from the fields and removing the getters—this is just an internal struct, no need for accessors.)

src/main/java/jenkins/plugins/git/GitSCMFileSystem.java Outdated Show resolved Hide resolved
src/main/java/jenkins/plugins/git/GitSCMFileSystem.java Outdated Show resolved Hide resolved
Comment on lines 434 to 435
public void calculate_head_name_with_env() throws Exception
{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void calculate_head_name_with_env() throws Exception
{
public void calculate_head_name_with_env() throws Exception {

@@ -427,6 +429,43 @@ public void filesystem_supports_descriptor() throws Exception {
assertTrue(SCMFileSystem.supports(descriptor));
}

@Issue("JENKINS-42971")
@Test
Copy link
Member

Choose a reason for hiding this comment

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

May also want to assert behavior with a null env, undefined variable, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is one for null env, but this is internal method, and there are many checks already in the calling method

@jglick
Copy link
Member

jglick commented Aug 5, 2022

#898 (comment) should be investigated. Also that PR touches GitTelescope (whatever that is). Need to examine prior art.

@github-actions github-actions bot added dependencies Dependency related change test labels Aug 5, 2022
@jglick jglick requested a review from MarkEWaite August 5, 2022 15:15
@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Sep 12, 2022

Hello pinging again as this PR is opened too long, can we either finish it up somehow or probabbly add some improvements? @MarkEWaite or @dwnusbaum or @car-roll ?

@MartinKosicky
Copy link
Contributor Author

Hmm

@MartinKosicky
Copy link
Contributor Author

Ping again (i apolagize in advance for pinging)

@MarkEWaite
Copy link
Contributor

Thanks for the ping. I'll be busy all this weekend preparing for DevOps World and then busy all week at DevOps World. I may be able to start the review a week or two after DevOps World

@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Sep 26, 2022

Can we retrigger? If i force push (just to trigger build) the approvals will disapear and the test that failed seems to be some kind of unreliable test (should not affected by my change)

@MartinKosicky
Copy link
Contributor Author

Thanks for the ping. I'll be busy all this weekend preparing for DevOps World and then busy all week at DevOps World. I may be able to start the review a week or two after DevOps World

Hello is it time now? :)

@MarkEWaite
Copy link
Contributor

Thanks for the ping. I'll be busy all this weekend preparing for DevOps World and then busy all week at DevOps World. I may be able to start the review a week or two after DevOps World

Hello is it time now? :)

Not yet. I'm on vacation with family and friends and won't return until the end of this week. I hope to start the review early next week, after some restart time as I return.

@link89
Copy link

link89 commented Nov 1, 2022

Looking forward to this improvement to be merged. It suffers when working with a monorepo and not being able to turn on lightweight checkout.

@MartinKosicky
Copy link
Contributor Author

MartinKosicky commented Nov 14, 2022

@MarkEWaite Hello can we like do this quick, there are only 2 files in this, one is test and one is the file. I am afraid that the build system will change soon and i will have to start over on this. Can you find some hour at least or 15 minutes to quick check it? some guys already approved it. There are also tests added. Please :) Also there is another plugin in different repo that cannot even start PR process until this one is merged if you will be ok with that.

The branch name "master" is a default in many places.  Using a
non-default value in the tests (slightly) reduces the chances of a
default being returned instead of the expected expansion of the
variable.
@github-actions github-actions bot removed the dependencies Dependency related change label Nov 14, 2022
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Thanks for your patience @MartinKosicky . Approved..

I need to perform some interactive testing of an incremental build before it is released. I expect that release will happen later this week.

@MarkEWaite MarkEWaite removed the test label Nov 14, 2022
@MartinKosicky
Copy link
Contributor Author

Just to clarify, who will merge the branch, you after the manual test?

@MarkEWaite
Copy link
Contributor

Just to clarify, who will merge the branch, you after the manual test?

Yes, I'll merge the branch and I'll perform the release.

@github-actions github-actions bot added the test label Nov 22, 2022
@MarkEWaite
Copy link
Contributor

After building and installing the workflow-cps plugin with the change, I was able to confirm that this resolves JENKINS-42971. Thanks!

@MarkEWaite MarkEWaite merged commit 633a457 into jenkinsci:master Nov 23, 2022
@MartinKosicky
Copy link
Contributor Author

Thanks :)

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.

5 participants