Search in sources :

Example 51 with BuildConfiguration

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

the class BuildConfigurationAuditedRepositoryImpl method createAudited.

private BuildConfigurationAudited createAudited(Object entity, Object revision) {
    BuildConfiguration buildConfiguration = (BuildConfiguration) entity;
    DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision;
    // preload generic parameters
    buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null));
    return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, revisionEntity.getId());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) DefaultRevisionEntity(org.hibernate.envers.DefaultRevisionEntity)

Example 52 with BuildConfiguration

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

the class BuildConfigurationAuditedRepositoryImpl method queryById.

@Override
public BuildConfigurationAudited queryById(IdRev idRev) {
    logger.trace("Querying for BuildConfigurationAudited.idRev: {}.", idRev);
    BuildConfiguration buildConfiguration = AuditReaderFactory.get(entityManager).find(BuildConfiguration.class, idRev.getId(), idRev.getRev());
    if (buildConfiguration == null) {
        return null;
    }
    // preload generic parameters
    buildConfiguration.getGenericParameters().forEach((k, v) -> k.equals(null));
    return BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, idRev.getRev());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration)

Example 53 with BuildConfiguration

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

the class DefaultDatastore method requiresRebuild.

@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public boolean requiresRebuild(BuildConfigurationAudited buildConfigurationAudited, boolean checkImplicitDependencies, boolean temporaryBuild, AlignmentPreference alignmentPreference, Set<Integer> processedDependenciesCache, Consumer<BuildRecord> nonRebuildCauseSetter) {
    IdRev idRev = buildConfigurationAudited.getIdRev();
    // Step 1 - Check the existence of a build with the same revision
    BuildRecord latestSuccessfulBuildRecord = buildRecordRepository.getAnyLatestSuccessfulBuildRecordWithRevision(idRev, temporaryBuild);
    if (latestSuccessfulBuildRecord == null) {
        logger.debug("Rebuild of buildConfiguration.idRev: {} required as there is no successful BuildRecord.", idRev);
        return true;
    }
    // Step 2 - Check the existence of more recent builds with different revision
    if (!isLatestSuccessBRFromThisBCA(buildConfigurationAudited, temporaryBuild)) {
        return true;
    }
    // Step 3 - check implicit dependencies
    if (checkImplicitDependencies) {
        logger.debug("Checking if BCA: {} has implicit dependencies that need rebuild", idRev);
        boolean rebuild = hasARebuiltImplicitDependency(latestSuccessfulBuildRecord, temporaryBuild, alignmentPreference, processedDependenciesCache);
        logger.debug("Implicit dependency check for rebuild of buildConfiguration.idRev: {} required: {}.", idRev, rebuild);
        if (rebuild) {
            return true;
        }
    }
    // Step 4 - check explicit dependencies
    Set<BuildConfiguration> dependencies = buildConfigurationAudited.getBuildConfiguration().getDependencies();
    boolean rebuild = hasARebuiltExplicitDependency(latestSuccessfulBuildRecord, dependencies, temporaryBuild, alignmentPreference);
    logger.debug("Explicit dependency check for rebuild of buildConfiguration.idRev: {} required: {}.", idRev, rebuild);
    if (!rebuild) {
        nonRebuildCauseSetter.accept(latestSuccessfulBuildRecord);
    }
    return rebuild;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) IdRev(org.jboss.pnc.model.IdRev) BuildRecord(org.jboss.pnc.model.BuildRecord) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 54 with BuildConfiguration

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

the class BuildConfigProviderTest method fill.

@Before
public void fill() {
    User currentUser = prepareNewUser();
    when(userService.currentUser()).thenReturn(currentUser);
    when(buildEnvironmentRepository.queryById(anyInt())).thenAnswer(i -> mockEnvironment(12));
    final BuildConfiguration a = prepareBuildConfig("First!", 1, 1, 1);
    final BuildConfiguration b = prepareBuildConfig("Second!!", 1, 2, 2, a);
    final BuildConfiguration c = prepareBuildConfig("THIRD!!!", 2, 2, 3, a, b);
    final BuildConfiguration d = prepareBuildConfig("Fourth-_-", 3, 3, 3, a, b, c);
    List<BuildConfiguration> configs = new ArrayList<>(Arrays.asList(new BuildConfiguration[] { a, b, c, d, bc }));
    fillRepository(configs);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) User(org.jboss.pnc.model.User) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 55 with BuildConfiguration

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

the class GroupConfigurationProviderTest method testRemoveConfiguration.

@Test
public void testRemoveConfiguration() {
    // With
    // 
    org.jboss.pnc.dto.GroupConfiguration groupConfiguration = provider.getSpecific("1");
    BuildConfiguration toRemove = bcs.getBuildConfigurations().stream().findFirst().get();
    when(buildConfigurationRepository.queryById(toRemove.getId())).thenReturn(toRemove);
    assertThat(groupConfiguration.getBuildConfigs()).containsKey(toRemove.getId().toString());
    // When
    provider.removeConfiguration(groupConfiguration.getId(), toRemove.getId().toString());
    // Then
    org.jboss.pnc.dto.GroupConfiguration refreshed = provider.getSpecific(groupConfiguration.getId());
    assertThat(refreshed.getBuildConfigs().values()).doNotHave(new Condition<>(toRemove::equals, "BC is equal to 'toRemove' bc"));
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) Test(org.junit.Test)

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