Ejemplo n.º 1
0
        public bool ShouldShortCircuit(RunnerRepoInfo info)
        {
            if (!_settingsProvider.Shortcircuit)
            {
                return(false);
            }
            var meta = _metaFileReader.Read(info.MetaPath);

            if (meta == null)
            {
                return(false);
            }
            if (meta.Sha != info.Target.TargetSha)
            {
                return(false);
            }
            if (meta.MutagenVersion != info.TargetVersions.Mutagen)
            {
                return(false);
            }
            if (meta.SynthesisVersion != info.TargetVersions.Synthesis)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
 public void WriteMeta(RunnerRepoInfo info)
 {
     WriteMeta(info.MetaPath, new GitCompilationMeta()
     {
         MutagenVersion   = info.TargetVersions.Mutagen ?? string.Empty,
         SynthesisVersion = info.TargetVersions.Synthesis ?? string.Empty,
         Sha = info.Target.TargetSha
     });
 }
Ejemplo n.º 3
0
        public async Task <ErrorResponse> Compile(RunnerRepoInfo info, CancellationToken cancel)
        {
            try
            {
                if (_shortCircuitCompilation.ShouldShortCircuit(info))
                {
                    _logger.Information("Short circuiting {Path} compilation because meta matched", info.ProjPath);
                    return(ErrorResponse.Success);
                }
            }
            catch (Exception e)
            {
                _logger.Warning(e, "Failed when checking if we could short circuit compilation");
            }

            try
            {
                _logger.Information("Clearing short circuit meta");
                _fs.File.Delete(info.MetaPath);
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed when clearing short circuit meta");
            }

            var resp = await _build.Compile(info.ProjPath, cancel).ConfigureAwait(false);

            if (resp.Failed)
            {
                return(resp);
            }

            try
            {
                _writeShortCircuitMeta.WriteMeta(info);
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed when saving short circuit meta");
                return(ErrorResponse.Fail(e));
            }

            return(resp);
        }
Ejemplo n.º 4
0
        public async Task <ConfigurationState <RunnerRepoInfo> > Checkout(
            CheckoutInput checkoutInput,
            CancellationToken cancel)
        {
            try
            {
                cancel.ThrowIfCancellationRequested();

                _logger.Information("Targeting {PatcherVersioning}", checkoutInput.PatcherVersioning);

                using var repoCheckout = RepoCheckouts.Get(RunnerRepoDirectoryProvider.Path);

                var target = ResetToTarget.Reset(repoCheckout.Repository, checkoutInput.PatcherVersioning, cancel);
                if (target.Failed)
                {
                    return(target.BubbleFailure <RunnerRepoInfo>());
                }

                cancel.ThrowIfCancellationRequested();

                checkoutInput.LibraryNugets.Log(_logger);

                var slnPath = SolutionFileLocator.GetPath(RunnerRepoDirectoryProvider.Path);
                if (slnPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail("Could not locate solution to run."));
                }

                var foundProjSubPath = RunnerRepoProjectPathRetriever.Get(slnPath.Value, checkoutInput.Proj);
                if (foundProjSubPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail($"Could not locate target project file: {checkoutInput.Proj}."));
                }

                cancel.ThrowIfCancellationRequested();

                ModifyRunnerProjects.Modify(
                    slnPath.Value,
                    drivingProjSubPath: foundProjSubPath.SubPath,
                    versions: checkoutInput.LibraryNugets.ReturnIfMatch(new NugetVersionPair(null, null)),
                    listedVersions: out var listedVersions);

                var runInfo = new RunnerRepoInfo(
                    SolutionPath: slnPath,
                    ProjPath: foundProjSubPath.FullPath,
                    MetaPath: _metaFilePathProvider.Path,
                    Target: target.Value.Target,
                    CommitMessage: target.Value.CommitMessage,
                    CommitDate: target.Value.CommitDate,
                    ListedVersions: listedVersions,
                    TargetVersions: checkoutInput.LibraryNugets.ReturnIfMatch(listedVersions));

                return(GetResponse <RunnerRepoInfo> .Succeed(runInfo));
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                return(GetResponse <RunnerRepoInfo> .Fail(ex));
            }
        }