Ejemplo n.º 1
0
        public static async Task <IRecorder> Create(string archiveFile, string workDir)
        {
            var extractedDirCleanup = DirectoryCleanup.CreateTempDir(workDir, async extractedDir => {
                await using (var stream = File.OpenRead(archiveFile)) {
                    await using var tarStream = new TarInputStream(stream);
                    await ArchiveUtil.ExtractTar(tarStream, extractedDir);
                }

                var dependencyMetadata = JsonConvert.DeserializeObject <JObject>(
                    await File.ReadAllTextAsync(Path.Combine(extractedDir, ArchiveRecorder.TransientMetadataPath))
                    );

                return(new ReplayRecorder(extractedDir, dependencyMetadata));
            });

            return(await extractedDirCleanup.Value());
        }
Ejemplo n.º 2
0
        private async Task JobFiber(CancellationToken cancellationToken)
        {
            try {
                var headers = new Metadata {
                    { ProtocolConstants.AgentKeyHeaderName, apiKey }
                };
                using var stream = buildServer.acceptBuildJob(headers, null, cancellationToken);


                var buildTask = await ReadBuildTask(stream, cancellationToken);

                if (buildTask == null)
                {
                    return;
                }


                await using var buildDir = DirectoryCleanup.CreateTempDir(workspacesDir);
                logger.LogInformation("Created workspace for build: {0}, exists: {1}", buildDir.Value, Directory.Exists(buildDir.Value));
                var buildRunner = new BuildJobRunner(logger, buildDir.Value, stream.ResponseStream, stream.RequestStream, cancellationToken);
                await buildRunner.RunJob(buildTask);

                await ProcessArtifacts(stream, buildRunner, cancellationToken);
            }
            catch (OperationCanceledException) { }
            catch (Exception ex) {
                logger.LogError(ex, "Error running build job");
                await Task.Delay(1000, cancellationToken);
            }
            finally {
                using (await jobLock.EnterAsync(cancellationToken)) {
                    --runningJobs;
                    jobLock.Pulse();
                }
            }
        }
Ejemplo n.º 3
0
 private static ICleanup <Func <Task <LaunchProperties> > > GetDockerLaunchProps(PlatformInfo platform, List <SdkInfo> sdks, string workDir, string?currentDir, string sourcesDir, Config conf, ISdkInstallManager sdkInstallManager, BuildSchema schema) =>
 DirectoryCleanup.CreateTempDir(workDir, async tempDir => {