-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(sonarcloud): add org to the connections table * feat: add sonarqube cloud connection config * fix: sonarcloud now working * fix: linting * fix: copywriting for sonarqube cloud * feat: added cq_issue_impacts table * fix: unit test * fix: adjust sonarqube cloud config * feat: add sonarcloud dashboard (#8140) Co-authored-by: Startrekzky <kaiyun.zhang@merico.dev> --------- Co-authored-by: mintsweet <0x1304570@gmail.com> Co-authored-by: Louis.z <louis.s4372121@gmail.com> Co-authored-by: Startrekzky <kaiyun.zhang@merico.dev>
- Loading branch information
1 parent
7e058d1
commit 2cadbf8
Showing
17 changed files
with
1,915 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
backend/core/models/migrationscripts/20241010_add_ca_issue_impacts.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
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 migrationscripts | ||
|
||
import ( | ||
"github.com/apache/incubator-devlake/core/context" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
) | ||
|
||
var _ plugin.MigrationScript = (*addCqIssueImpacts)(nil) | ||
|
||
type cqIssueImpacts struct { | ||
archived.NoPKModel | ||
CqIssueId string `gorm:"primaryKey;type:varchar(255)"` | ||
SoftwareQuality string `gorm:"primaryKey;type:varchar(255)"` | ||
Severity string `gorm:"type:varchar(100)"` | ||
} | ||
|
||
type addCqIssueImpacts struct { | ||
} | ||
|
||
func (script *addCqIssueImpacts) Up(basicRes context.BasicRes) errors.Error { | ||
return basicRes.GetDal().AutoMigrate(&cqIssueImpacts{}) | ||
} | ||
|
||
func (*addCqIssueImpacts) Version() uint64 { | ||
return 20241010162658 | ||
} | ||
|
||
func (*addCqIssueImpacts) Name() string { | ||
return "add cq_issue_impacts table" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
backend/plugins/sonarqube/models/migrationscripts/20240930_add_connection_orgs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
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 migrationscripts | ||
|
||
import ( | ||
"github.com/apache/incubator-devlake/core/context" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
"github.com/apache/incubator-devlake/helpers/migrationhelper" | ||
) | ||
|
||
var _ plugin.MigrationScript = (*addOrgToConn)(nil) | ||
|
||
type connection20240930 struct { | ||
Organization string | ||
} | ||
|
||
func (connection20240930) TableName() string { | ||
return "_tool_sonarqube_connections" | ||
} | ||
|
||
type addOrgToConn struct { | ||
} | ||
|
||
func (script *addOrgToConn) Up(basicRes context.BasicRes) errors.Error { | ||
return migrationhelper.AutoMigrateTables(basicRes, &connection20240930{}) | ||
} | ||
|
||
func (*addOrgToConn) Version() uint64 { | ||
return 20240930151715 | ||
} | ||
|
||
func (*addOrgToConn) Name() string { | ||
return "add organizations to the connections table" | ||
} |
55 changes: 55 additions & 0 deletions
55
backend/plugins/sonarqube/models/migrationscripts/20241010_add_issue_impacts.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
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 migrationscripts | ||
|
||
import ( | ||
"github.com/apache/incubator-devlake/core/context" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/models/migrationscripts/archived" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
"github.com/apache/incubator-devlake/helpers/migrationhelper" | ||
) | ||
|
||
var _ plugin.MigrationScript = (*addIssueImpacts)(nil) | ||
|
||
type issueImpacts20241010 struct { | ||
ConnectionId uint64 `gorm:"primaryKey"` | ||
IssueKey string `gorm:"primaryKey;type:varchar(100)"` | ||
SoftwareQuality string `gorm:"primaryKey;type:varchar(255)"` | ||
Severity string `gorm:"type:varchar(100)"` | ||
archived.NoPKModel | ||
} | ||
|
||
func (issueImpacts20241010) TableName() string { | ||
return "_tool_sonarqube_issue_impacts" | ||
} | ||
|
||
type addIssueImpacts struct { | ||
} | ||
|
||
func (script *addIssueImpacts) Up(basicRes context.BasicRes) errors.Error { | ||
return migrationhelper.AutoMigrateTables(basicRes, &issueImpacts20241010{}) | ||
} | ||
|
||
func (*addIssueImpacts) Version() uint64 { | ||
return 20241010162943 | ||
} | ||
|
||
func (*addIssueImpacts) Name() string { | ||
return "add issue_impacts table for sonarcloud" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
backend/plugins/sonarqube/tasks/issue_impacts_convertor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
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 tasks | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/apache/incubator-devlake/core/dal" | ||
"github.com/apache/incubator-devlake/core/errors" | ||
"github.com/apache/incubator-devlake/core/models/domainlayer/codequality" | ||
"github.com/apache/incubator-devlake/core/models/domainlayer/didgen" | ||
"github.com/apache/incubator-devlake/core/plugin" | ||
"github.com/apache/incubator-devlake/helpers/pluginhelper/api" | ||
sonarqubeModels "github.com/apache/incubator-devlake/plugins/sonarqube/models" | ||
) | ||
|
||
var ConvertIssueImpactsMeta = plugin.SubTaskMeta{ | ||
Name: "convertIssueImpacts", | ||
EntryPoint: ConvertIssueImpacts, | ||
EnabledByDefault: true, | ||
Description: "Convert tool layer table sonarqube_issue_impacts into domain layer table cq_issue_impacts", | ||
DomainTypes: []string{plugin.DOMAIN_TYPE_CODE_QUALITY}, | ||
} | ||
|
||
func ConvertIssueImpacts(taskCtx plugin.SubTaskContext) errors.Error { | ||
db := taskCtx.GetDal() | ||
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_ISSUES_TABLE) | ||
cursor, err := db.Cursor( | ||
dal.From("_tool_sonarqube_issue_impacts p"), | ||
dal.Join("LEFT JOIN _tool_sonarqube_issues i ON (i.connection_id = p.connection_id AND i.issue_key = p.issue_key)"), | ||
dal.Where("i.connection_id = ? AND i.project_key = ?", data.Options.ConnectionId, data.Options.ProjectKey)) | ||
if err != nil { | ||
return err | ||
} | ||
defer cursor.Close() | ||
|
||
issueIdGen := didgen.NewDomainIdGenerator(&sonarqubeModels.SonarqubeIssue{}) | ||
converter, err := api.NewDataConverter(api.DataConverterArgs{ | ||
InputRowType: reflect.TypeOf(sonarqubeModels.SonarqubeIssueImpact{}), | ||
Input: cursor, | ||
RawDataSubTaskArgs: *rawDataSubTaskArgs, | ||
Convert: func(inputRow interface{}) ([]interface{}, errors.Error) { | ||
impact := inputRow.(*sonarqubeModels.SonarqubeIssueImpact) | ||
domainIssueImpact := &codequality.CqIssueImpact{ | ||
CqIssueId: issueIdGen.Generate(data.Options.ConnectionId, impact.IssueKey), | ||
SoftwareQuality: impact.SoftwareQuality, | ||
Severity: impact.Severity, | ||
} | ||
return []interface{}{ | ||
domainIssueImpact, | ||
}, nil | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return converter.Execute() | ||
} |
Oops, something went wrong.