kostas-petrakis opened a new issue, #8188: URL: https://github.com/apache/incubator-devlake/issues/8188
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues. ### What happened I was evaluating the data collected from the GitHub integration when I noticed an issue with a small subset of deployments, more specifically some deployments reported a deployment time of 30 weeks. Since I knew from GitHub itself that this was not the case I started investigating and I feel there is an issue with the `getDeploymentCommit` functionality related to `EnrichPrevSuccessDeploymentCommit`. For example the following is the PR I used for the investigation: ``` { "pull_requests": [ { "id" : "github:GithubPullRequest:4:1806504909", "created_at" : "2024-11-12 08:34:13.134", "updated_at" : "2024-11-12 08:34:13.134", "_raw_data_params" : "{\"ConnectionId\":4,\"Name\":\"********\"}", "_raw_data_table" : "_raw_github_api_pull_requests", "_raw_data_id" : 4499, "_raw_data_remark" : "", "base_repo_id" : "github:GithubRepo:4:***********", "base_ref" : "main", "base_commit_sha" : "a51af0dabd2d9e9bd7b23e432688842cf086c248", "head_repo_id" : "github:GithubRepo:4:*******", "head_ref" : "feature\***************", "head_commit_sha" : "e6a73f3095d1c97d4d4576e3c06719fb07938bd1", "merge_commit_sha" : "b297c73092685c4b1a0ee62c2326d77115a86e94", "status" : "MERGED", "original_status" : "closed", "type" : "", "component" : "", "title" : "****************************", "description" : "null", "url" : "https:\/\/github.com\/******\/*******\/pull\/1025", "author_name" : "***************", "author_id" : "github:GithubAccount:4:***********", "parent_pr_id" : "", "pull_request_key" : 1025, "created_date" : "2024-04-04 09:08:03", "merged_date" : "2024-04-05 09:00:16", "closed_date" : "2024-04-05 09:00:16", "additions" : 0, "deletions" : 0, "merged_by_name" : "", "merged_by_id" : "github:GithubAccount:4:0", "is_draft" : 0 } ]} ``` As you can see this PR was merged `2024-04-05 09:00:16` yet the deployment linked is incorrect: ``` { "project_pr_metrics": [ { "id" : "github:GithubPullRequest:4:1806504909", "created_at" : "2024-11-12 08:38:29.797", "updated_at" : "2024-11-12 08:38:29.797", "_raw_data_params" : "", "_raw_data_table" : "", "_raw_data_id" : 0, "_raw_data_remark" : "", "project_name" : "adoption_and_collaboration_tribe", "first_commit_sha" : "3726ef9fce54e1f95717ab0fbe695403cbf850ff", "pr_coding_time" : 1, "first_review_id" : "github:GithubPrReview:4:******", "pr_pickup_time" : 4, "pr_review_time" : 1429, "deployment_commit_id" : "github:GithubRun:4:435823930:11612162783:https:\/\/github.com\/*****\/****", "pr_deploy_time" : 301201, "pr_cycle_time" : 302635, "first_commit_authored_date" : "2024-04-04 09:07:51", "pr_created_date" : "2024-04-04 09:08:03", "first_comment_date" : "2024-04-04 09:11:44", "pr_merged_date" : "2024-04-05 09:00:16", "pr_deployed_date" : "2024-10-31 13:00:17" } ]} ``` Manually checking in the `cicd_deployment_commits` for the `merge_commit_sha` (`b297c73092685c4b1a0ee62c2326d77115a86e94`) I can see that the deployment is there: ``` { "cicd_deployment_commits": [ { "id" : "github:GithubRun:4:435823930:8567339272:https:\/\/github.com\/l*****\/****", "created_at" : "2024-11-12 11:17:32.066", "updated_at" : "2024-11-12 11:17:33.602", "_raw_data_params" : "{\"ConnectionId\":4,\"Name\":\"*****\/****\"}", "_raw_data_table" : "_raw_github_api_runs", "_raw_data_id" : 2338, "_raw_data_remark" : "prev_deployment_commit_id_enricher,", "cicd_scope_id" : "github:GithubRepo:4:435823930", "cicd_deployment_id" : "github:GithubRun:4:435823930:8567339272", "name" : "CI\/CD", "result" : "SUCCESS", "original_result" : "success", "status" : "DONE", "original_status" : "completed", "environment" : "PRODUCTION", "original_environment" : "", "created_date" : "2024-04-05 09:00:19", "queued_date" : null, "queued_duration_sec" : null, "started_date" : "2024-04-05 09:00:19", "finished_date" : "2024-04-05 09:14:22", "duration_sec" : 843.0, "commit_sha" : "b297c73092685c4b1a0ee62c2326d77115a86e94", "ref_name" : "main", "repo_id" : "github:GithubRepo:4:435823930", "repo_url" : "https:\/\/github.com\/*****\/****", "prev_success_deployment_commit_id" : "", "commit_msg" : "", "subtask_name" : "dora.generateDeploymentCommits", "display_title" : "Merge pull request #1025 from *****\/****", "url" : "https:\/\/github.com\/*****\/****/actions\/runs\/8567339272" } ]} ``` As you notice the `prev_success_deployment_commit_id` is empty here, which I think affects the results of the [query](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/dora/tasks/change_lead_time_calculator.go#L221) in the `change_lead_time_calculator.go` module, I am not sure if that query should return null in this condition, as the `prev_success_deployment_commit_id` is empty always (?) for the first deployment recorded for the repo for the given time period (6 months) according to the [code](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/dora/tasks/prev_deployment_commit_enricher.go#L99) grouping. The linked `"deployment_commit_id" : "github:GithubRun:4:435823930:11612162783` is actually the last entry in the `cicd_deployment_commits` table for the `cicd_scope_id/repo_url/env` grouping. ### What do you expect to happen PR deployment should be linked to the proper run for this example (`github:GithubRun:4:435823930:8567339272:https:\/\/github.com\/l*****\/****`) ### How to reproduce I will just describe what the status of that repo is, GitHub, deployment through CI/CD workflow, explore for the first PR deployment recorded by Devlake and evaluate the linked deployment. This issue is only related to the first deployment for each cicd_scope_id/repo_url/env grouping. ### Anything else _No response_ ### Version v1.0.1@e061ef2 ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org