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

fix: populate missing RepoUrl in CiCDPipelineCommit #7210

Merged
merged 1 commit into from
May 30, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/plugins/azuredevops_go/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestAzuredevopsBuildDataFlow(t *testing.T) {

dataflowTester.FlushTabler(&models.AzuredevopsBuild{})
dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_azuredevops_go_api_builds.csv", "_raw_azuredevops_go_api_builds")
dataflowTester.ImportCsvIntoTabler("./raw_tables/_tool_azuredevops_go_repos.csv", &models.AzuredevopsRepo{})
dataflowTester.Subtask(tasks.ExtractApiBuildsMeta, taskData)

// Omit the datetime columns to avoid test failures caused by the varying precision
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pipeline_id,commit_sha,commit_msg,branch,repo_id,repo_url
azuredevops_go:AzuredevopsBuild:1:12,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:13,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:14,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:15,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:16,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:17,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:18,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,
azuredevops_go:AzuredevopsBuild:1:12,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:13,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:14,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:15,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:16,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:17,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
azuredevops_go:AzuredevopsBuild:1:18,40c59264e73fc5e1a6cab192f1622d26b7bd5c2a,,refs/heads/main,0d50ba13-f9ad-49b0-9b21-d29eda50ca33,https://dev.azure.com/devlake/project-1/_git/first-repo
19 changes: 14 additions & 5 deletions backend/plugins/azuredevops_go/tasks/ci_cd_build_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ var ConvertBuildsMeta = plugin.SubTaskMeta{
},
}

type JoinedBuild struct {
models.AzuredevopsBuild

URL string
}

func ConvertBuilds(taskCtx plugin.SubTaskContext) errors.Error {
db := taskCtx.GetDal()
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RawPullRequestTable)
clauses := []dal.Clause{
dal.Select("*"),
dal.Select("_tool_azuredevops_go_builds.*, _tool_azuredevops_go_repos.url"),
dal.From(&models.AzuredevopsBuild{}),
dal.Where(`repository_id = ? and connection_id = ?`, data.Options.RepositoryId, data.Options.ConnectionId),
dal.Join(`left join _tool_azuredevops_go_repos
on _tool_azuredevops_go_builds.repository_id = _tool_azuredevops_go_repos.id`),
dal.Where(`_tool_azuredevops_go_builds.repository_id = ? and _tool_azuredevops_go_builds.connection_id = ?`,
data.Options.RepositoryId, data.Options.ConnectionId),
}

cursor, err := db.Cursor(clauses...)
Expand All @@ -64,10 +73,10 @@ func ConvertBuilds(taskCtx plugin.SubTaskContext) errors.Error {

converter, err := api.NewDataConverter(api.DataConverterArgs{
RawDataSubTaskArgs: *rawDataSubTaskArgs,
InputRowType: reflect.TypeOf(models.AzuredevopsBuild{}),
InputRowType: reflect.TypeOf(JoinedBuild{}),
Input: cursor,
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
build := inputRow.(*models.AzuredevopsBuild)
build := inputRow.(*JoinedBuild)
duration := 0.0

if build.FinishTime != nil {
Expand Down Expand Up @@ -100,7 +109,7 @@ func ConvertBuilds(taskCtx plugin.SubTaskContext) errors.Error {
CommitSha: build.SourceVersion,
Branch: build.SourceBranch,
RepoId: build.RepositoryId,
RepoUrl: "",
RepoUrl: build.URL,
}

return []interface{}{
Expand Down