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

Sb bazel pipeline #71

Merged
merged 54 commits into from Oct 8, 2019
Merged

Sb bazel pipeline #71

merged 54 commits into from Oct 8, 2019

Conversation

stevebillings
Copy link
Contributor

This is a rewrite of the bazel extractor, which is a lot more flexible than the previous version.
I believe it's now far more likely we'll be able to plug in support for future languages/rules
without big changes to the code.

Because it's a rewrite, the PR diffs probably aren't useful. A logical sequence of classes to look
at might be:

  • Pipelines.java: The currently-supported pipelines. These are like linux pipelines, where each step
    does further processing on the output of the previous step, until a list of
    maven coordinates (group:artifact:version) strings is produced.
  • StepExecutor*.java: these are the types of pipeline steps we currently support
  • PipelineChooser.java: selects which pipeline to run based on WORKSPACE file contents or override property
  • BazelExtractor.extract(): executes the pipeline

Steve Billings added 30 commits September 27, 2019 15:26
# Conflicts:
#	detectable/src/main/java/com/synopsys/integration/detectable/detectables/bazel/parse/RuleConverter.java
@blackduck-copilot
Copy link

blackduck-copilot bot commented Oct 4, 2019

Black Duck Security Report

Merging #71 into master will not change security risk.

Click here to see full report

@stevebillings
Copy link
Contributor Author

I've incorporated all of the review feedback:

  • a pipeline is now a list of StepExecutor objects (object instantiated from subclasses of StepExecutor); the List args is replaced with constructor arguments. The following have been removed: Step, StepType, StepExecutors.
  • ${0} is now ${input.item}
  • PipelineChooser is now WorkspaceRuleChooser
  • the extractor has been simplified

@@ -42,18 +40,12 @@
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final ExternalIdFactory externalIdFactory;
private final MutableDependencyGraph dependencyGraph;
private File workspaceDir;

public BazelCodeLocationBuilder(final ExternalIdFactory externalIdFactory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm skeptical you are getting much benefit from this class and BazelExternalId. Why not just parse to an external id and add to a graph?

Instead of:
BazelExternalId externalId = BazelExternalId.fromBazelArtifactString(artifactString, ":");
bazelCodeLocationBuilder.add(externalId)

Do something like
ExternalId externalId = BazelExternalIdParser.Parse(artifactString, ":")
dependencyGraph.add(externalId);

Or even have a BazelDependencyParser if you would have to have a new Dependency there as well.

@@ -59,6 +62,11 @@ public DetectableResult applicable() {
if (StringUtils.isBlank(bazelDetectableOptions.getTargetName())) {
return new PropertyInsufficientDetectableResult();
}
final File workspaceFile = fileFinder.findFile(environment.getDirectory(), WORKSPACE_FILENAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense putting the WORKSPACE_FILENAME part in extractable too so that if I provide the target I still get some kind of error?

logger.debug("Bazel extractAndPublishResults()");
public Extraction extract(final File bazelExe, final File workspaceDir, final BazelWorkspace bazelWorkspace, final String bazelTarget,
final BazelProjectNameGenerator bazelProjectNameGenerator, final String providedBazelDependencyType) {
logger.debug("Bazel extraction:");
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the new extractor!

public class WorkspaceRuleChooser {

@NotNull
public WorkspaceRule choose(final WorkspaceRule ruleFromWorkspaceFile, final String providedBazelDependencyType) throws IntegrationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove this method (and maybe rename deriveDependencyType to 'choose').

public class BazelExtractorTest {

@Test
public void testMavenJar() throws ExecutableRunnerException, IntegrationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests seem extremely large. Can they be broken down into smaller tests?

@stevebillings stevebillings merged commit ea8b62b into master Oct 8, 2019
@stevebillings stevebillings deleted the sb_bazelPipeline branch October 10, 2019 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants