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

Add skip parameter to base plugin configuration #911

Merged
merged 7 commits into from
Aug 31, 2018
Merged

Conversation

loosebazooka
Copy link
Member

  • can use system property -Djib.skip=true to skip if part of
    lifecycle
  • still requires "required parameters" on jib to be configured
    even if skipping, since maven doesn't provide a api for actual
    goal skipping

fixes #865

- can use system property -Djib.skip=true to skip if part of
  lifecycle
- still requires "required parameters" on jib to be configured
  even if skipping, since maven doesn't provide a api for actual
  goal skipping
@loosebazooka loosebazooka requested a review from a team August 30, 2018 21:02
@loosebazooka
Copy link
Member Author

If anyone has any decent testing strategies for this, let me know. It's kind of hard to do since maven doesn't actually define "skipping" a goal like gradle does.

@briandealwis
Copy link
Member

You could run something like the BuildImageMojoIntegrationTest and use the Verifier#verifyTextInLog() that your log string appeared.

@loosebazooka
Copy link
Member Author

@briandealwis I was hoping to ensure that the return was called, maybe I can ensure the log has no more writes after that?

Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

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

It would be nice to centralize this duplicate code.

verifier.setSystemProperty("jib.skip", "true");

verifier.executeGoal("jib:" + BuildDockerMojo.GOAL_NAME);
File logFile = new File(verifier.getBasedir(), verifier.getLogFileName());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use Path? And new String(Files.readAllBytes(logFile), StandardCharsets.UTF_8)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that way, it will remove the Guava dependency.

Copy link
Member

Choose a reason for hiding this comment

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

It's a test class, and we use Guava everywhere!

If I had a concern about this code, it would be with the line endings. You could consider using java.nio.file.Files#readAllLines(), which also handles multiple line endings and then compare the last three lines.


verifier.executeGoal("jib:" + BuildDockerMojo.GOAL_NAME);
File logFile = new File(verifier.getBasedir(), verifier.getLogFileName());
Assert.assertTrue(
Copy link
Contributor

Choose a reason for hiding this comment

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

Assert.assertThat(string, CoreMatchers.containsString())


Path logFile = Paths.get(verifier.getBasedir(), verifier.getLogFileName());
Assert.assertThat(
new String(Files.readAllBytes(logFile), Charset.forName("UTF-8")),
Copy link
Contributor

Choose a reason for hiding this comment

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

StandardCharsets.UTF_8

import org.hamcrest.CoreMatchers;
import org.junit.Assert;

public class SkippedGoalVerifier {
Copy link
Contributor

Choose a reason for hiding this comment

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

short javadoc


public class SkippedGoalVerifier {

public static void verifyGoalIsSkipped(TestProject testProject, String goal)
Copy link
Contributor

Choose a reason for hiding this comment

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

visibility can all be package-private?

String targetImage = "neverbuilt:maven" + System.nanoTime();

Verifier verifier = new Verifier(testProject.getProjectRoot().toString());
verifier.setSystemProperty("_TARGET_IMAGE", targetImage);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove this line?

Copy link
Member Author

@loosebazooka loosebazooka Aug 31, 2018

Choose a reason for hiding this comment

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

without target image specified, it will fail? oh I see, yeah lemme look.

/** A simple verifier utility to test goal skipping accross all our jib goals. */
class SkippedGoalVerifier {

private SkippedGoalVerifier() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: non-static below static

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right

/** Verify that a jib goal is skipped */
static void verifyGoalIsSkipped(TestProject testProject, String goal)
throws VerificationException, IOException {

Copy link
Contributor

Choose a reason for hiding this comment

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

extra newline?

@@ -0,0 +1,51 @@
/*
* Copyright 2018 Google LLC. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

I meant to ask about this All rights reserved. It's not normally seen on ASL headers, and @elharo indicated that there was some internal discussion about whether to include it or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, yeah I just looked at the updating docs, and All rights reserved is gone. I'll update that, and then push a larger update across the codebase.

@loosebazooka loosebazooka merged commit e9e55b4 into master Aug 31, 2018
@TadCordle TadCordle deleted the skipGoals branch August 31, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add configuration to skip in Maven plugin
5 participants