Search in sources :

Example 56 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class GroupConfigurationProviderTest method testAddConfiguration.

@Test
public void testAddConfiguration() {
    // With
    final int bcId = 3773;
    final BuildConfiguration buildConfiguration = mockBuildConfig(bcId, "NEWCOMER");
    when(buildConfigurationRepository.queryById(bcId)).thenReturn(buildConfiguration);
    // When
    provider.addConfiguration(bcs.getId().toString(), Integer.toString(bcId));
    // Then
    org.jboss.pnc.dto.GroupConfiguration refreshed = provider.getSpecific(bcs.getId().toString());
    assertThat(refreshed.getBuildConfigs()).containsKey(buildConfiguration.getId().toString());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Test(org.junit.Test)

Example 57 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class DatastoreAdapter method loadBuildConfigurations.

/**
 * Fetch build configurations of project to be able access it outside transaction
 *
 * @param buildConfigAudited build config for which the build configurations are to be fetched
 */
private void loadBuildConfigurations(BuildConfigurationAudited buildConfigAudited) {
    Project project = buildConfigAudited.getProject();
    project.getBuildConfigurations().forEach(BuildConfiguration::getId);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Project(org.jboss.pnc.model.Project)

Example 58 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class AbstractDependentBuildTest method config.

protected BuildConfiguration config(String name, BuildConfiguration... dependencies) {
    BuildConfiguration config = buildConfig(name, dependencies);
    saveConfig(config);
    return config;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration)

Example 59 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class BuildTasksInitializer method createBuildSetTask.

/**
 * Create a BuildSetTask of BuildConfigurations contained in the BuildConfigurationSet.
 *
 * A specific revision of the BuildConfigurations contained in the set is used, if it's available in the
 * buildConfigurationAuditedsMap parameter. If it's not available, latest revision of the BuildConfiguration is
 * used.
 *
 * @param buildConfigurationSet BuildConfigurationSet to be built
 * @param buildConfigurationAuditedsMap A map BuildConfiguration::id:BuildConfigurationAudited of specific revisions
 *        of BuildConfigurations contained in the buildConfigurationSet
 * @param user A user, who triggered the build
 * @param buildOptions Build options
 * @param buildTaskIdProvider Provider to get build task ID
 * @param submittedBuildTasks Already submitted build tasks
 * @return Prepared BuildSetTask
 * @throws CoreException Thrown if the BuildConfigSetRecord cannot be stored
 */
public BuildSetTask createBuildSetTask(BuildConfigurationSet buildConfigurationSet, Map<Integer, BuildConfigurationAudited> buildConfigurationAuditedsMap, User user, BuildOptions buildOptions, Supplier<String> buildTaskIdProvider, Set<BuildTask> submittedBuildTasks) throws CoreException {
    BuildSetTask buildSetTask = initBuildSetTask(buildConfigurationSet, user, buildOptions);
    Set<BuildConfigurationAudited> buildConfigurationAuditeds = new HashSet<>();
    for (BuildConfiguration buildConfiguration : datastoreAdapter.getBuildConfigurations(buildConfigurationSet)) {
        BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedsMap.get(buildConfiguration.getId());
        if (buildConfigurationAudited == null) {
            buildConfigurationAudited = datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(buildConfiguration.getId());
        }
        buildConfigurationAuditeds.add(buildConfigurationAudited);
    }
    // initializeBuildTasksInSet
    log.debug("Initializing BuildTasks In Set for BuildConfigurationAuditeds: {}.", buildConfigurationAuditeds.stream().map(BuildConfigurationAudited::toString).collect(Collectors.joining("; ")));
    fillBuildTaskSet(buildSetTask, user, buildTaskIdProvider, buildConfigurationSet.getCurrentProductMilestone(), buildConfigurationAuditeds, submittedBuildTasks, buildOptions);
    return buildSetTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) HashSet(java.util.HashSet)

Example 60 with BuildConfiguration

use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.

the class BuildTasksInitializer method collectDependentConfigurations.

/**
 * Collects all BuildConfigurationAudited entities, that needs to be built.
 *
 * @param buildConfiguration Current BuildConfiguration used to resolve dependencies.
 * @param buildConfigurationAudited Specific revision of a BuildConfiguration (passed as first parameter) to be
 *        potentially built
 * @param toBuild Set of BuildConfigurationAudited entities planned to be built
 * @param visited Set of BuildConfigurations, which were already evaluated, if should be built
 * @param checkImplicitDependencies if implicit check of dependencies needs to be done
 * @param forceRebuild if force build is required
 * @param temporaryBuild if build is temporary
 * @param processedDependenciesCache list containing any dependency which was already processed in previous
 *        iterations
 * @return Returns true, if the buildConfiguration should be rebuilt, otherwise returns false.
 */
private boolean collectDependentConfigurations(BuildConfiguration buildConfiguration, BuildConfigurationAudited buildConfigurationAudited, Set<BuildConfigurationAudited> toBuild, Set<BuildConfiguration> visited, boolean checkImplicitDependencies, boolean forceRebuild, boolean temporaryBuild, AlignmentPreference alignmentPreference, Set<Integer> processedDependenciesCache) {
    if (visited.contains(buildConfiguration)) {
        return toBuild.contains(buildConfigurationAudited);
    }
    visited.add(buildConfiguration);
    boolean requiresRebuild = forceRebuild || datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild, alignmentPreference, processedDependenciesCache);
    for (BuildConfiguration dependency : buildConfiguration.getDependencies()) {
        boolean dependencyRequiresRebuild = collectDependentConfigurations(dependency, datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(dependency.getId()), toBuild, visited, checkImplicitDependencies, forceRebuild, temporaryBuild, alignmentPreference, processedDependenciesCache);
        requiresRebuild = requiresRebuild || dependencyRequiresRebuild;
    }
    log.debug("Configuration {} requires rebuild: {}", buildConfiguration.getId(), requiresRebuild);
    if (requiresRebuild) {
        toBuild.add(buildConfigurationAudited);
    }
    return requiresRebuild;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration)

Aggregations

BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)65 Test (org.junit.Test)23 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)11 HashSet (java.util.HashSet)10 BuildRecord (org.jboss.pnc.model.BuildRecord)9 Project (org.jboss.pnc.model.Project)9 BuildOptions (org.jboss.pnc.spi.BuildOptions)9 BuildResult (org.jboss.pnc.spi.BuildResult)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 List (java.util.List)8 Set (java.util.Set)8 Inject (javax.inject.Inject)8 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)8 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)8 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)8 IdRev (org.jboss.pnc.model.IdRev)7 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)7 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)7 Collectors (java.util.stream.Collectors)5