Skip to content

Commit

Permalink
fix: pr should be connected to failed deployment commit
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh committed Oct 18, 2023
1 parent 6307f12 commit 152525d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestCalculateCLTimeDataFlow(t *testing.T) {
dataflowTester.ImportCsvIntoTabler("./change_lead_time/cicd_scopes.csv", &devops.CicdScope{})
dataflowTester.ImportCsvIntoTabler("./change_lead_time/pull_requests.csv", &code.PullRequest{})
dataflowTester.ImportCsvIntoTabler("./change_lead_time/cicd_deployment_commits.csv", &devops.CicdDeploymentCommit{})
dataflowTester.ImportCsvIntoTabler("./change_lead_time/commits_diffs.csv", &code.CommitsDiff{})
dataflowTester.ImportNullableCsvIntoTabler("./change_lead_time/commits_diffs.csv", &code.CommitsDiff{})
dataflowTester.ImportCsvIntoTabler("./change_lead_time/pull_request_comments.csv", &code.PullRequestComment{})
dataflowTester.ImportCsvIntoTabler("./change_lead_time/pull_request_commits.csv", &code.PullRequestCommit{})

Expand Down
3 changes: 2 additions & 1 deletion backend/plugins/dora/e2e/change_lead_time/commits_diffs.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ old_commit_sha,new_commit_sha,commit_sha
commit1,commit5,pr_merge_commit1
commit1,commit5,pr_merge_commit2
commit2,commit6,pr_merge_commit3
commit7,commit8,pr_merge_commit4
commit7,commit8,pr_merge_commit4
,commit11,pr_merge_commit5
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ project1,cicd_scopes,cicd1
project1,repos,repo1
project1,repos,repo2
project2,cicd_scopes,cicd3
project2,repos,repo3
project2,repos,repo3
project1,cicd_scopes,cicd2
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pr1,project1,08d2f2b6de0fa8de4d0e2b55b4b9a2e244214029,1440,comment02,5,55,5,2978
pr2,project1,2537845559d8db99e9cda6190f32b50ec979c722,,comment04,1,60,5,1538,1598
pr3,project1,55f445997abbd5918da59d202d28762cd56fbd44,5883,comment07,,5760,6,,
pr4,project1,5ad0c09c447c19338f1dfbb65d89a3728962b3b7,11704,comment10,1500,,,,
pr5,project1,62535543802631a0d3daf0b0b78c6a7e05e508fb,13144,comment12,,313068,,,
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pr1,repo1,a,pr_merge_commit1,2023-4-11 4:51:47,2023-4-11 5:51:47,deployment_comm
pr2,repo1,a,pr_merge_commit2,2023-4-12 4:51:47,2023-4-12 5:51:47,deployment_commit 5,,
pr3,repo1,a,pr_merge_commit3,2023-4-11 6:53:51,2023-4-14 6:53:51,deployment_commit 6,,
pr4,repo1,,pr_merge_commit4,2023-4-13 7:55:01,2023-4-13 8:55:01,,,
pr5,repo1,,pr_merge_commit5,2023-4-13 7:55:01,,,,
pr5,repo1,,pr_merge_commit5,2023-4-13 7:55:01,2023-4-13 8:55:01,,,
pr6,repo1,,pr_merge_commit6,2023-4-13 7:55:01,,,,
2 changes: 1 addition & 1 deletion backend/plugins/dora/tasks/change_lead_time_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func getDeploymentCommit(mergeSha string, projectName string, db dal.Dal) (*devo
dal.Join("LEFT JOIN project_mapping pm ON (pm.table = 'cicd_scopes' AND pm.row_id = dc.cicd_scope_id)"),
dal.Join("INNER JOIN commits_diffs cd ON (cd.new_commit_sha = dc.commit_sha AND cd.old_commit_sha = COALESCE (p.commit_sha, ''))"),
dal.Where("dc.environment = 'PRODUCTION'"), // TODO: remove this when multi-environment is supported
dal.Where("pm.project_name = ? AND cd.commit_sha = ?", projectName, mergeSha),
dal.Where("pm.project_name = ? AND cd.commit_sha = ? AND dc.RESULT = ?", projectName, mergeSha, devops.RESULT_SUCCESS),
dal.Orderby("dc.started_date, dc.id ASC"),
dal.Limit(1),
)
Expand Down

0 comments on commit 152525d

Please sign in to comment.