protected override async Task <TContext> InitAsync(CancellationToken token) { if (Config is IFromGit { SshRepoUrl : string _ } gitCfg) { await _gitClone.CloneOrPullAsync(gitCfg, token, shallow : true, defaultBranchOnly : true); } var ctx = DotnetContext.Create <TContext, TConfig>(Config, c => _gitClone.ResolveFullClonePath(c)); if (File.Exists(ctx.EntryAssemblyPath)) { return(ctx); } _logger.LogDebug("Building {Project}", ctx.CsProjPath); var result = await Dotnet.BuildAsync(ctx.CsProjPath, token); if (!result.IsSuccess) { _logger.LogInformation("Build failed | {output}", result.Output); } return(ctx); }
public async Task CloneWorkspaceRepos(string workspacePath, string?outputDir = null, CancellationToken token = default) { using var _ = _logger.WithScope(nameof(CloneMaker), Phase.GIT); await _configurator.LoadAsync(new ConfiguratorPaths { WorkspacePath = workspacePath }, token); var haveValidGitUrl = _configurator.Current.Values.OfType <IFromGit>().ToLookup(x => !string.IsNullOrWhiteSpace(x.SshRepoUrl)); foreach (var invalidCfg in haveValidGitUrl[false].Cast <IRunnableConfig>()) { _logger.LogInformation("{parameter} is not specified for {runnableId}. Skipping.", nameof(IFromGit.SshRepoUrl), invalidCfg.Id); } foreach (var gitCfg in haveValidGitUrl[true].GroupBy(x => _gitClone.ResolveFullClonePath(x, outputDir)).Select(x => x.First())) { var output = await _gitClone.CloneOrPullAsync(gitCfg, token, rootPathOverride : outputDir); if (output.IsSuccess) { continue; } break; } }