Skip to content

Commit

Permalink
moar logging
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero committed Apr 15, 2024
1 parent ebf5784 commit 3d86fb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/neptune/gateway/config/root_config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (b *Builder) build(ctx context.Context, commit *RepoCommit, installationTok
b.Logger.Info(fmt.Sprintf("localRepo is: full repo name: %s, commit sha: %s, commit branch: %s, commit repo name: %s, repodir: %s", commit.Repo.FullName, commit.Sha, commit.Branch, commit.Repo.Name, repoDir))

// Run pre-workflow hooks
b.Logger.Info(fmt.Sprintf("running pre-workflow hooks"))

Check failure on line 138 in server/neptune/gateway/config/root_config_builder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
err = b.HooksRunner.Run(ctx, localRepo.Repo, localRepo.Dir)
if err != nil {
return nil, errors.Wrap(err, "running pre-workflow hooks")
Expand All @@ -144,16 +145,19 @@ func (b *Builder) build(ctx context.Context, commit *RepoCommit, installationTok
// TODO: rename project to roots
var mergedRootCfgs []*valid.MergedProjectCfg

b.Logger.Info(fmt.Sprintf("parsing repo config"))

Check failure on line 148 in server/neptune/gateway/config/root_config_builder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
repoCfg, err := b.ParserValidator.ParseRepoCfg(localRepo.Dir, localRepo.Repo.ID())
if err != nil {
return nil, errors.Wrapf(err, "parsing %s", config.AtlantisYAMLFilename)
}

b.Logger.Info(fmt.Sprintf("getting matching roots"))

Check failure on line 154 in server/neptune/gateway/config/root_config_builder.go

View workflow job for this annotation

GitHub Actions / runner / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
matchingRoots, err := b.getMatchingRoots(ctx, repoCfg, localRepo, installationToken, rootNames)
if err != nil {
return nil, errors.Wrap(err, "getting matching roots")
}

b.Logger.Info(fmt.Sprintf("merging roots for %s", localRepo.Repo.FullName))
for _, mr := range matchingRoots {
mergedRootCfg := b.GlobalCfg.MergeProjectCfg(localRepo.Repo.ID(), mr, repoCfg)
mergedRootCfgs = append(mergedRootCfgs, &mergedRootCfg)
Expand Down
4 changes: 4 additions & 0 deletions server/vcs/provider/github/repo_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ func (g *RepoFetcher) Fetch(ctx context.Context, repo models.Repo, branch string
authURL := fmt.Sprintf("://x-access-token:%s", ghToken)
repo.CloneURL = strings.Replace(repo.CloneURL, "://:", authURL, 1)
repo.SanitizedCloneURL = strings.Replace(repo.SanitizedCloneURL, "://:", "://x-access-token:", 1)
g.Logger.Info(fmt.Sprintf("about to clone inside RepoFetcher Fetch with params: repo: %v. branch: %s, sha: %s", repo, branch, sha))
path, cleanup, err := g.clone(ctx, repo, branch, sha, options)
if err != nil {
g.Scope.Counter(metrics.ExecutionErrorMetric).Inc(1)
return path, cleanup, err
}
g.Scope.Counter(metrics.ExecutionSuccessMetric).Inc(1)
g.Logger.Info(fmt.Sprintf("cloned repo %s to path %s", repo.Name, path))
return path, cleanup, err
}

Expand All @@ -79,6 +81,7 @@ func (g *RepoFetcher) clone(ctx context.Context, repo models.Repo, branch string
}

// Create the directory and parents if necessary.
g.Logger.Info("creating new directory inside clone at path: " + destinationPath)
if err := os.MkdirAll(destinationPath, 0700); err != nil {
return "", nil, errors.Wrap(err, "creating new directory")
}
Expand Down Expand Up @@ -144,6 +147,7 @@ func (g *RepoFetcher) run(ctx context.Context, args []string, destinationPath st
}

func (g *RepoFetcher) Cleanup(ctx context.Context, filePath string) {
g.Logger.Info(fmt.Sprintf("cleaning up cloned repo at path %s", filePath))
if err := os.RemoveAll(filePath); err != nil {
g.Logger.ErrorContext(ctx, "failed deleting cloned repo", map[string]interface{}{
"err": err,
Expand Down

0 comments on commit 3d86fb5

Please sign in to comment.