Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix. Empty base-commit should consider complete diff #38

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/core/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type DiffManager interface {
// TestDiscoveryService services discovery of tests
type TestDiscoveryService interface {
// Discover executes the test discovery scripts.
Discover(ctx context.Context, tasConfig *TASConfig, payload *Payload, secretData map[string]string, diff map[string]int) error
Discover(ctx context.Context, tasConfig *TASConfig, payload *Payload, secretData map[string]string, diff map[string]int, diffExists bool) error
}

// TestBlockListService is used for fetching blocklisted tests
Expand Down
13 changes: 9 additions & 4 deletions pkg/core/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,20 @@ func (pl *Pipeline) Start(ctx context.Context) (err error) {
}

pl.Logger.Infof("Identifying changed files ...")
diffExists := true
diff, err := pl.DiffManager.GetChangedFiles(ctx, payload, oauth.Data.AccessToken)
if err != nil {
pl.Logger.Errorf("Unable to identify changed files %s", err)
errRemark = "Error occurred in fetching diff from GitHub"
return err
if errors.Is(err, errs.ErrGitDiffNotFound) {
diffExists = false
} else {
pl.Logger.Errorf("Unable to identify changed files %s", err)
errRemark = "Error occurred in fetching diff from GitHub"
return err
}
}

// discover test cases
err = pl.TestDiscoveryService.Discover(ctx, tasConfig, pl.Payload, secretMap, diff)
err = pl.TestDiscoveryService.Discover(ctx, tasConfig, pl.Payload, secretMap, diff, diffExists)
if err != nil {
pl.Logger.Errorf("Unable to perform test discovery: %+v", err)
errRemark = "Error occurred in discovering tests"
Expand Down
4 changes: 0 additions & 4 deletions pkg/diffmanager/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ func (dm *diffManager) GetChangedFiles(ctx context.Context, payload *core.Payloa
} else {
diff, err = dm.getCommitDiff(payload.GitProvider, payload.RepoLink, cloneToken, payload.BaseCommit, payload.TargetCommit)
if err != nil {
if errors.Is(err, errs.ErrGitDiffNotFound) {
dm.logger.Debugf("failed to get commit diff for gitprovider: %s error: %v", payload.GitProvider, err)
return nil, nil
}
dm.logger.Errorf("failed to get commit diff for gitprovider: %s error: %v", payload.GitProvider, err)
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/testdiscoveryservice/testdiscovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (tds *testDiscoveryService) Discover(ctx context.Context,
tasConfig *core.TASConfig,
payload *core.Payload,
secretData map[string]string,
diff map[string]int) error {
diff map[string]int,
diffExists bool) error {
var target []string
var envMap map[string]string
if payload.EventType == core.EventPullRequest {
Expand All @@ -51,7 +52,7 @@ func (tds *testDiscoveryService) Discover(ctx context.Context,

args := []string{"--command", "discover"}
if !discoverAll {
if len(diff) == 0 {
if len(diff) == 0 && diffExists {
// empty diff; in PR, a commit added and then reverted to cause an overall empty PR diff
args = append(args, "--diff")
} else {
Expand Down