klesh commented on code in PR #2207: URL: https://github.com/apache/incubator-devlake/pull/2207#discussion_r901378858
########## plugins/github/e2e/pr_commit_test.go: ########## @@ -0,0 +1,101 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/code" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrCommitDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) Review Comment: Hardcode this as discussed in the other PR, since the filename wouldn't automatically change when `TableName` got updated. ########## plugins/github/e2e/pr_commit_test.go: ########## @@ -0,0 +1,101 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/code" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrCommitDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) Review Comment: Hardcode this as we discussed on the other PR, thanks ########## plugins/github/e2e/pr_review_test.go: ########## @@ -0,0 +1,65 @@ +/* Review Comment: I believe the filename should be `pr_reviewer_test.go` ########## plugins/github/e2e/pr_entrich_issue_test.go: ########## @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/crossdomain" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrEnrichIssueDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + Config: models.Config{ + PrType: "type/(.*)$", + PrComponent: "component/(.*)$", + PrBodyClosePattern: "(?mi)(fix|close|resolve|fixes|closes|resolves|fixed|closed|resolved)[\\s]*.*(((and )?(#|https:\\/\\/github.com\\/%s\\/%s\\/issues\\/)\\d+[ ]*)+)", + IssueSeverity: "severity/(.*)$", + IssuePriority: "^(highest|high|medium|low)$", + IssueComponent: "component/(.*)$", + IssueTypeBug: "^(bug|failure|error)$", + IssueTypeIncident: "", + IssueTypeRequirement: "^(feat|feature|proposal|requirement)$", + }, + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubIssue{}.TableName()), &models.GithubIssue{}) + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) + + // verify extraction + dataflowTester.FlushTabler(&models.GithubPullRequestIssue{}) + dataflowTester.Subtask(tasks.EnrichPullRequestIssuesMeta, taskData) + dataflowTester.VerifyTable( + models.GithubPullRequestIssue{}, + fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequestIssue{}.TableName()), Review Comment: Same as above ########## plugins/github/models/migrationscripts/archived/commit.go: ########## @@ -24,6 +24,7 @@ import ( ) type GithubCommit struct { + ConnectionId uint64 `gorm:"primaryKey"` Review Comment: Same as above ########## plugins/github/e2e/pr_commit_test.go: ########## @@ -0,0 +1,101 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/code" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrCommitDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) + dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_github_api_pull_request_commits.csv", "_raw_github_api_pull_request_commits") + + // verify extraction + dataflowTester.FlushTabler(&models.GithubCommit{}) Review Comment: Actually, there is no dependency between `commits` and `pull_request_commits`. I don't think we should put them together. But, we could live with this for the moment. ########## plugins/github/e2e/pr_commit_test.go: ########## @@ -0,0 +1,101 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/code" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrCommitDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) + dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_github_api_pull_request_commits.csv", "_raw_github_api_pull_request_commits") + + // verify extraction + dataflowTester.FlushTabler(&models.GithubCommit{}) + dataflowTester.FlushTabler(&models.GithubPullRequestCommit{}) + dataflowTester.Subtask(tasks.ExtractApiPullRequestCommitsMeta, taskData) + dataflowTester.VerifyTable( + models.GithubCommit{}, + fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubCommit{}.TableName()), + []string{"connection_id", "sha"}, + []string{ + "author_id", + "author_name", + "author_email", + "authored_date", + "committer_id", + "committer_name", + "committer_email", + "committed_date", + "message", + "url", + "additions", + "deletions", + "_raw_data_params", + "_raw_data_table", + "_raw_data_id", + "_raw_data_remark", + }, + ) + + dataflowTester.VerifyTable( + models.GithubPullRequestCommit{}, + fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequestCommit{}.TableName()), Review Comment: Same as above ########## plugins/github/models/commit.go: ########## @@ -24,6 +24,7 @@ import ( ) type GithubCommit struct { + ConnectionId uint64 `gorm:"primaryKey"` Review Comment: Commits should be universal across different connections. ########## plugins/github/e2e/pr_entrich_issue_test.go: ########## @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/crossdomain" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrEnrichIssueDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + Config: models.Config{ + PrType: "type/(.*)$", + PrComponent: "component/(.*)$", + PrBodyClosePattern: "(?mi)(fix|close|resolve|fixes|closes|resolves|fixed|closed|resolved)[\\s]*.*(((and )?(#|https:\\/\\/github.com\\/%s\\/%s\\/issues\\/)\\d+[ ]*)+)", + IssueSeverity: "severity/(.*)$", + IssuePriority: "^(highest|high|medium|low)$", + IssueComponent: "component/(.*)$", + IssueTypeBug: "^(bug|failure|error)$", + IssueTypeIncident: "", + IssueTypeRequirement: "^(feat|feature|proposal|requirement)$", + }, + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubIssue{}.TableName()), &models.GithubIssue{}) Review Comment: Same as above ########## plugins/github/e2e/pr_entrich_issue_test.go: ########## @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/crossdomain" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrEnrichIssueDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + Config: models.Config{ + PrType: "type/(.*)$", + PrComponent: "component/(.*)$", + PrBodyClosePattern: "(?mi)(fix|close|resolve|fixes|closes|resolves|fixed|closed|resolved)[\\s]*.*(((and )?(#|https:\\/\\/github.com\\/%s\\/%s\\/issues\\/)\\d+[ ]*)+)", + IssueSeverity: "severity/(.*)$", + IssuePriority: "^(highest|high|medium|low)$", + IssueComponent: "component/(.*)$", + IssueTypeBug: "^(bug|failure|error)$", + IssueTypeIncident: "", + IssueTypeRequirement: "^(feat|feature|proposal|requirement)$", + }, + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubIssue{}.TableName()), &models.GithubIssue{}) + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) Review Comment: Same as above ########## plugins/github/e2e/pr_commit_test.go: ########## @@ -0,0 +1,101 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/models/domainlayer/code" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrCommitDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) + dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_github_api_pull_request_commits.csv", "_raw_github_api_pull_request_commits") + + // verify extraction + dataflowTester.FlushTabler(&models.GithubCommit{}) + dataflowTester.FlushTabler(&models.GithubPullRequestCommit{}) + dataflowTester.Subtask(tasks.ExtractApiPullRequestCommitsMeta, taskData) + dataflowTester.VerifyTable( + models.GithubCommit{}, + fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubCommit{}.TableName()), + []string{"connection_id", "sha"}, + []string{ + "author_id", + "author_name", + "author_email", + "authored_date", + "committer_id", + "committer_name", + "committer_email", + "committed_date", + "message", + "url", + "additions", + "deletions", + "_raw_data_params", + "_raw_data_table", + "_raw_data_id", + "_raw_data_remark", + }, + ) + + dataflowTester.VerifyTable( + models.GithubPullRequestCommit{}, + fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequestCommit{}.TableName()), + []string{"connection_id", "commit_sha"}, + []string{ + "pull_request_id", + "_raw_data_params", + "_raw_data_table", + "_raw_data_id", + "_raw_data_remark", + }, + ) + + // verify extraction + dataflowTester.FlushTabler(&code.PullRequestCommit{}) + dataflowTester.Subtask(tasks.ConvertPullRequestCommitsMeta, taskData) + dataflowTester.VerifyTable( + code.PullRequestCommit{}, + fmt.Sprintf("./snapshot_tables/%s.csv", code.PullRequestCommit{}.TableName()), Review Comment: Same as above ########## plugins/github/e2e/pr_review_test.go: ########## @@ -0,0 +1,65 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrReviewDataFlow(t *testing.T) { + var plugin impl.Github + dataflowTester := e2ehelper.NewDataFlowTester(t, "gitlab", plugin) + + githubRepository := &models.GithubRepo{ + GithubId: 134018330, + } + taskData := &tasks.GithubTaskData{ + Options: &tasks.GithubOptions{ + ConnectionId: 1, + Owner: "panjf2000", + Repo: "ants", + }, + Repo: githubRepository, + } + + // import raw data table + dataflowTester.ImportCsvIntoTabler(fmt.Sprintf("./snapshot_tables/%s.csv", models.GithubPullRequest{}.TableName()), models.GithubPullRequest{}) Review Comment: Hardcode pls ########## plugins/github/e2e/pr_review_test.go: ########## @@ -0,0 +1,65 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + "fmt" + "github.com/apache/incubator-devlake/plugins/github/models" + "testing" + + "github.com/apache/incubator-devlake/helpers/e2ehelper" + "github.com/apache/incubator-devlake/plugins/github/impl" + "github.com/apache/incubator-devlake/plugins/github/tasks" +) + +func TestPrReviewDataFlow(t *testing.T) { Review Comment: Same problem as the filename mentioned above -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
