use of org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo in project bacon by project-ncl.
the class EmptyProjectBuildTest method shouldBuildEmpty.
@Test
void shouldBuildEmpty(@TempDir Path targetDir) {
String suffix = init(Paths.get("src", "test", "resources", "empty"), true, Optional.empty(), targetDir);
PigFacade.configure(true, false);
GroupBuildInfo build = PigFacade.build(false, false, RebuildMode.EXPLICIT_DEPENDENCY_CHECK, true, false);
assertThat(build.getBuilds()).isNotEmpty();
assertThat(build.getBuilds().keySet()).contains(format(emptyNameBase1, suffix), format(emptyNameBase2, suffix));
assertThat(build.getBuilds().values().stream()).allMatch(b -> b.getBuildStatus() == BuildStatus.SUCCESS);
}
use of org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo in project bacon by project-ncl.
the class PigFacade method run.
public static GroupBuildInfo run(boolean skipPncUpdate, boolean skipBuilds, boolean skipSources, boolean skipJavadoc, boolean skipLicenses, boolean skipSharedContent, boolean removeGeneratedM2Dups, String repoZipPath, boolean tempBuild, boolean dryRun, boolean tempBuildTS, RebuildMode rebuildMode, boolean skipBranchCheck, boolean strictLicenseCheck, boolean strictDownloadSource, Path configurationDirectory) {
PigContext context = context();
ImportResult importResult;
if (skipPncUpdate) {
importResult = readPncEntities();
} else {
importResult = configure(skipBranchCheck, tempBuild);
}
context.setPncImportResult(importResult);
context.storeContext();
GroupBuildInfo groupBuildInfo;
if (skipBuilds) {
log.info("Skipping builds");
groupBuildInfo = getBuilds(importResult, tempBuild);
} else {
groupBuildInfo = build(tempBuild, tempBuildTS, rebuildMode, true, dryRun);
}
context.setBuilds(groupBuildInfo.getBuilds());
context.storeContext();
// TODO: there seems to be a gap between the build configs assigned to the product version
// TODO: and build group
// TODO: It is possible that someone adds a build config to the product version but not to the build group
// TODO: should we bother with this case?
RepositoryData repo = null;
if (repoZipPath != null || context.getPigConfiguration().getFlow().getRepositoryGeneration().getStrategy() != RepoGenerationStrategy.IGNORE) {
if (repoZipPath != null) {
repo = parseRepository(new File(repoZipPath));
} else {
repo = generateRepo(removeGeneratedM2Dups, configurationDirectory, strictLicenseCheck, strictDownloadSource);
}
context.setRepositoryData(repo);
context.storeContext();
} else {
log.info("Skipping Repo Generation");
}
if (!(skipSources || context().getPigConfiguration().getFlow().getSourcesGeneration().getStrategy() == SourcesGenerationStrategy.IGNORE)) {
generateSources();
} else {
log.info("Skipping Source Generation");
context.getDeliverables().setSourceZipName(null);
}
if (!(skipJavadoc || context.getPigConfiguration().getFlow().getJavadocGeneration().getStrategy() == JavadocGenerationStrategy.IGNORE)) {
generateJavadoc();
} else {
log.info("Skipping Javadoc Generation");
context.getDeliverables().setJavadocZipName(null);
}
if (!(skipLicenses || context.getPigConfiguration().getFlow().getLicensesGeneration().getStrategy() == LicenseGenerationStrategy.IGNORE)) {
generateLicenses(strictLicenseCheck);
} else {
log.info("Skipping License Generation");
context.getDeliverables().setLicenseZipName(null);
}
if (!skipSharedContent && repo != null) {
prepareSharedContentAnalysis();
}
triggerAddOns();
if (repo != null) {
generateDocuments();
} else {
log.info("Skipping Document Generation");
}
log.info("PiG run completed, the results are in: {}", Paths.get(context().getTargetPath()).toAbsolutePath());
return groupBuildInfo;
}
use of org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo in project bacon by project-ncl.
the class EmptyProjectBuildTest method shouldReturnPreviousBuildsOnRebuild.
@Test
void shouldReturnPreviousBuildsOnRebuild(@TempDir Path targetDir) {
String suffix = init(Paths.get("src", "test", "resources", "empty"), true, Optional.empty(), targetDir);
PigFacade.configure(true, false);
GroupBuildInfo build = PigFacade.build(false, false, RebuildMode.EXPLICIT_DEPENDENCY_CHECK, true, false);
Map<String, PncBuild> builds = build.getBuilds();
assertThat(builds).isNotEmpty();
assertThat(builds.keySet()).contains(format(emptyNameBase1, suffix), format(emptyNameBase2, suffix));
assertThat(builds.values().stream()).allMatch(b -> b.getBuildStatus() == BuildStatus.SUCCESS);
List<String> successfulBuilds = buildIds(build);
GroupBuildInfo rebuild = PigFacade.build(false, false, RebuildMode.EXPLICIT_DEPENDENCY_CHECK, true, false);
assertThat(buildIds(rebuild)).containsAll(successfulBuilds);
}
use of org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo in project bacon by project-ncl.
the class BuildInfoCollector method getBuildsFromLatestGroupConfiguration.
/**
* Get the latest GroupBuildInfo from the groupConfiguration id. If there are no group builds, a runtime exception
* is thrown.
*
* @param groupConfigurationId the group configuration id
* @param temporaryBuild whether the group build is temporary or not
* @return GroupBuildInfo data of the group build and the list of builds
*/
public GroupBuildInfo getBuildsFromLatestGroupConfiguration(String groupConfigurationId, boolean temporaryBuild) {
try {
RemoteCollection<BuildConfiguration> configs = groupConfigurationClient.getBuildConfigs(groupConfigurationId);
Map<String, PncBuild> builds = new HashMap<>();
for (BuildConfiguration config : configs) {
PncBuild build = getLatestBuild(config.getId(), temporaryBuild ? BuildSearchType.ANY : BuildSearchType.PERMANENT);
builds.put(config.getName(), build);
}
// TODO: builds should be enough, getting latest build group to satisfy the current API
return new GroupBuildInfo(getLatestGroupBuild(groupConfigurationId, temporaryBuild), builds);
} catch (RemoteResourceException e) {
throw new RuntimeException("Cannot get list of group builds for group configuration " + groupConfigurationId);
}
}
use of org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo in project bacon by project-ncl.
the class BuildInfoCollector method getBuildsFromGroupBuild.
/**
* Get all the builds done in a build group. If the build finished with 'NO_REBUILD_REQUIRED', get the 'original'
* successful build and return it instead If the build was successful, we don't grab the logs since they can be
* quite long.
*
* @param groupBuild the group build to get the builds
* @return The information on the group build and the builds performed
*/
public GroupBuildInfo getBuildsFromGroupBuild(GroupBuild groupBuild) {
Map<String, PncBuild> result = new HashMap<>();
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setLatest(false);
filter.setRunning(false);
try {
Collection<Build> builds = groupBuildClient.getBuilds(groupBuild.getId(), filter).getAll();
for (Build build : builds) {
PncBuild pncBuild;
if (build.getStatus() == BuildStatus.NO_REBUILD_REQUIRED) {
BuildRef buildRef = build.getNoRebuildCause();
Build realBuild = buildClient.getSpecific(buildRef.getId());
pncBuild = new PncBuild(realBuild);
} else {
pncBuild = new PncBuild(build);
}
pncBuild.addBuiltArtifacts(toList(buildClient.getBuiltArtifacts(pncBuild.getId())));
result.put(pncBuild.getName(), pncBuild);
}
return new GroupBuildInfo(groupBuild, result);
} catch (RemoteResourceException e) {
throw new RuntimeException("Failed to get group build info for " + groupBuild.getId(), e);
}
}
Aggregations