use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class GoPublish method createBuild.
private BuildInfo createBuild() {
BuildInfo buildInfo = new BuildInfo();
String moduleId = StringUtils.defaultIfBlank(buildInfoModuleId, moduleName);
Module module = new ModuleBuilder().type(ModuleType.GO).id(moduleId).repository(deploymentRepo).artifacts(artifactList).build();
buildInfo.setModules(Collections.singletonList(module));
return buildInfo;
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class GoRun method createBuild.
private BuildInfo createBuild() {
BuildInfo buildInfo = new BuildInfo();
String moduleId = StringUtils.defaultIfBlank(buildInfoModuleId, moduleName);
Module module = new ModuleBuilder().type(ModuleType.GO).id(moduleId).dependencies(dependenciesList).build();
buildInfo.setModules(Collections.singletonList(module));
return buildInfo;
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class GoExtractorTest method goRunPublishTest.
/*
* 1. Build project1 locally (with default Go proxy)
* 2. Publish project1 package to Artifactory. (Project1 is a dependency for project2)
* 3. Build project2 with Artifactory for resolution.
*/
@Test
public void goRunPublishTest() {
Path projectDir = null;
ArrayListMultimap<String, String> properties = ArrayListMultimap.create();
try {
// Run Go build on project1 locally
Project project = Project.PROJECT_1;
projectDir = createProjectDir(project.targetDir, project.projectOrigin);
GoRun goRun = new GoRun(GO_BUILD_CMD, projectDir, null, null, StringUtils.EMPTY, getUsername(), getAdminToken(), getLog(), env);
BuildInfo project1BuildInfo = goRun.execute();
// Check successful execution
assertNotNull(project1BuildInfo);
// Publish project1 to Artifactory
GoPublish goPublish = new GoPublish(artifactoryManagerBuilder, properties, localRepo1, projectDir, project.getVersion(), null, getLog());
BuildInfo publishBuildInfo = goPublish.execute();
// Check successful execution
assertNotNull(publishBuildInfo);
project1BuildInfo.append(publishBuildInfo);
// Check correctness of the module, dependencies and artifacts
assertEquals(project1BuildInfo.getModules().size(), 1);
Module module = project1BuildInfo.getModules().get(0);
assertEquals(module.getType(), "go");
assertEquals(module.getId(), project.getModuleId());
assertEquals(module.getRepository(), localRepo1);
Set<String> moduleDependencies = module.getDependencies().stream().map(Dependency::getId).collect(Collectors.toSet());
assertEquals(moduleDependencies, project.dependencies);
Set<String> moduleArtifacts = module.getArtifacts().stream().map(Artifact::getName).collect(Collectors.toSet());
assertEquals(moduleArtifacts, project.getArtifactSet());
String expectedRemotePath = project.getRemotePath();
module.getArtifacts().stream().map(BaseBuildFileBean::getRemotePath).forEach(remotePath -> assertEquals(remotePath, expectedRemotePath));
// Run Go build on project2 using Artifactory for resolution
project = Project.PROJECT_2;
projectDir = createProjectDir(project.targetDir, project.projectOrigin);
goRun = new GoRun(GO_BUILD_CMD, projectDir, null, artifactoryManagerBuilder, virtualRepo, getUsername(), getAdminToken(), getLog(), env);
BuildInfo project2BuildInfo = goRun.execute();
// Check successful execution and correctness of the module, dependencies and artifacts
assertNotNull(project2BuildInfo);
assertEquals(project2BuildInfo.getModules().size(), 1);
module = project2BuildInfo.getModules().get(0);
assertEquals(module.getId(), project.getModuleId());
moduleDependencies = module.getDependencies().stream().map(Dependency::getId).collect(Collectors.toSet());
assertEquals(moduleDependencies, project.dependencies);
} catch (Exception e) {
fail(ExceptionUtils.getStackTrace(e));
} finally {
if (projectDir != null) {
FileUtils.deleteQuietly(projectDir.toFile());
}
}
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class DockerExtractorTest method pushAndValidateImage.
private void pushAndValidateImage(DockerPush dockerPush, String repo, String imageTag, String shortImageTag) {
BuildInfo buildInfo = dockerPush.execute();
Module module = getAndValidateModule(buildInfo, SHORT_IMAGE_NAME + ":" + shortImageTag, repo);
List<Artifact> artifacts = module.getArtifacts();
validateImageArtifacts(artifacts, imageTag);
assertEquals(7, artifacts.size());
module.getArtifacts().forEach(artifact -> assertEquals(artifact.getRemotePath(), SHORT_IMAGE_NAME + "/" + shortImageTag));
assertEquals(5, module.getDependencies().size());
}
use of org.jfrog.build.extractor.ci.Module in project build-info by JFrogDev.
the class Utils method checkBuildInfoModules.
/**
* Check expected build info modules.
*
* @param buildInfo - The build info
* @param expectedModules - Number of expected modules.
* @param expectedArtifactsPerModule - Number of expected artifacts in each module.
*/
private static void checkBuildInfoModules(BuildInfo buildInfo, int expectedModules, int expectedArtifactsPerModule) {
List<Module> modules = buildInfo.getModules();
assertEquals(modules.size(), expectedModules);
for (Module module : modules) {
if (expectedArtifactsPerModule > 0) {
assertEquals(module.getArtifacts().size(), expectedArtifactsPerModule);
} else {
assertNull(module.getArtifacts());
}
switch(module.getId()) {
case "org.jfrog.test.gradle.publish:webservice:1.0-SNAPSHOT":
assertEquals(module.getDependencies().size(), 7);
if (expectedArtifactsPerModule > 0) {
checkWebserviceArtifact(module);
}
checkWebserviceDependency(module);
break;
case "org.jfrog.test.gradle.publish:api:1.0-SNAPSHOT":
assertEquals(module.getDependencies().size(), 5);
break;
case "org.jfrog.test.gradle.publish:shared:1.0-SNAPSHOT":
assertEquals(module.getDependencies().size(), 0);
break;
default:
fail("Unexpected module ID: " + module.getId());
}
}
}
Aggregations