Search in sources :

Example 1 with GitPropertiesLocator

use of com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator in project teamscale-jacoco-agent by cqse.

the class AgentOptions method createDelayedTeamscaleUploader.

private IUploader createDelayedTeamscaleUploader(Instrumentation instrumentation) {
    DelayedUploader<ProjectRevision> uploader = new DelayedUploader<>(projectRevision -> {
        if (!StringUtils.isEmpty(projectRevision.getProject()) && !teamscaleServer.project.equals(projectRevision.getProject())) {
            logger.warn("Teamscale project '{}' specified in the agent configuration is not the same as the Teamscale project '{}' specified in git.properties file(s). Proceeding to upload to the" + " Teamscale project '{}' specified in the agent configuration.", teamscaleServer.project, projectRevision.getProject(), teamscaleServer.project);
        }
        teamscaleServer.revision = projectRevision.getRevision();
        return new TeamscaleUploader(teamscaleServer);
    }, outputDirectory);
    GitPropertiesLocator<ProjectRevision> locator = new GitPropertiesLocator<>(uploader, GitPropertiesLocatorUtils::getProjectRevisionFromGitProperties);
    instrumentation.addTransformer(new GitPropertiesLocatingTransformer(locator, getLocationIncludeFilter()));
    return uploader;
}
Also used : GitPropertiesLocatingTransformer(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatingTransformer) TeamscaleUploader(com.teamscale.jacoco.agent.upload.teamscale.TeamscaleUploader) GitPropertiesLocatorUtils(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatorUtils) GitPropertiesLocator(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator) DelayedUploader(com.teamscale.jacoco.agent.upload.delay.DelayedUploader)

Example 2 with GitPropertiesLocator

use of com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator in project teamscale-jacoco-agent by cqse.

the class DelayedCommitDescriptorRetrievalTest method locatorShouldTriggerUploadOfCachedXmls.

@Test
public void locatorShouldTriggerUploadOfCachedXmls(@TempDir Path outputPath) throws Exception {
    ExecutorService storeExecutor = Executors.newSingleThreadExecutor();
    Path coverageFilePath = outputPath.resolve(String.format("jacoco-%d.xml", ZonedDateTime.now().toInstant().toEpochMilli()));
    CoverageFile coverageFile = new CoverageFile(Files.createFile(coverageFilePath).toFile());
    InMemoryUploader destination = new InMemoryUploader();
    DelayedUploader<String> store = new DelayedUploader<>(commit -> destination, outputPath, storeExecutor);
    ExecutorService locatorExecutor = Executors.newSingleThreadExecutor();
    GitPropertiesLocator<String> locator = new GitPropertiesLocator<>(store, GitPropertiesLocatorUtils::getRevisionFromGitProperties, locatorExecutor);
    store.upload(coverageFile);
    locator.searchFileForGitPropertiesAsync(new File(getClass().getResource("git-properties.jar").toURI()), true);
    locatorExecutor.shutdown();
    locatorExecutor.awaitTermination(5, TimeUnit.SECONDS);
    storeExecutor.shutdown();
    storeExecutor.awaitTermination(5, TimeUnit.SECONDS);
    assertThat(Files.list(outputPath).anyMatch(path -> path.equals(coverageFilePath))).isFalse();
    assertThat(destination.getUploadedFiles().contains(coverageFile)).isTrue();
}
Also used : Path(java.nio.file.Path) CoverageFile(com.teamscale.report.jacoco.CoverageFile) InMemoryUploader(com.teamscale.jacoco.agent.util.InMemoryUploader) ExecutorService(java.util.concurrent.ExecutorService) GitPropertiesLocatorUtils(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatorUtils) GitPropertiesLocator(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator) CoverageFile(com.teamscale.report.jacoco.CoverageFile) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with GitPropertiesLocator

use of com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator in project teamscale-jacoco-agent by cqse.

the class AgentOptions method createDelayedArtifactoryUploader.

private IUploader createDelayedArtifactoryUploader(Instrumentation instrumentation) {
    DelayedUploader<ArtifactoryConfig.CommitInfo> uploader = new DelayedUploader<>(commitInfo -> {
        artifactoryConfig.commitInfo = commitInfo;
        return new ArtifactoryUploader(artifactoryConfig, additionalMetaDataFiles);
    }, outputDirectory);
    GitPropertiesLocator<ArtifactoryConfig.CommitInfo> locator = new GitPropertiesLocator<>(uploader, (file, isJarFile) -> ArtifactoryConfig.parseGitProperties(file, artifactoryConfig.gitPropertiesCommitTimeFormat));
    instrumentation.addTransformer(new GitPropertiesLocatingTransformer(locator, getLocationIncludeFilter()));
    return uploader;
}
Also used : GitPropertiesLocatingTransformer(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatingTransformer) GitPropertiesLocator(com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator) ArtifactoryUploader(com.teamscale.jacoco.agent.upload.artifactory.ArtifactoryUploader) DelayedUploader(com.teamscale.jacoco.agent.upload.delay.DelayedUploader)

Aggregations

GitPropertiesLocator (com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocator)3 GitPropertiesLocatingTransformer (com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatingTransformer)2 GitPropertiesLocatorUtils (com.teamscale.jacoco.agent.commit_resolution.git_properties.GitPropertiesLocatorUtils)2 DelayedUploader (com.teamscale.jacoco.agent.upload.delay.DelayedUploader)2 ArtifactoryUploader (com.teamscale.jacoco.agent.upload.artifactory.ArtifactoryUploader)1 TeamscaleUploader (com.teamscale.jacoco.agent.upload.teamscale.TeamscaleUploader)1 InMemoryUploader (com.teamscale.jacoco.agent.util.InMemoryUploader)1 CoverageFile (com.teamscale.report.jacoco.CoverageFile)1 File (java.io.File)1 Path (java.nio.file.Path)1 ExecutorService (java.util.concurrent.ExecutorService)1 Test (org.junit.jupiter.api.Test)1