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;
}
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();
}
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;
}
Aggregations