Skip to content

Commit f8b14a0

Browse files
ci(renovate): add renovate for cyclonedx (#5400)
Co-authored-by: Googlom <[email protected]>
1 parent 0cdbf78 commit f8b14a0

File tree

4 files changed

+93
-11
lines changed

4 files changed

+93
-11
lines changed

.github/renovate.json

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,107 @@
33
"extends": [
44
"config:base"
55
],
6-
"ignorePaths": [
7-
"integration/testdata/**",
8-
"test/resources/**"
9-
],
106
"labels": [
117
"dependencies"
128
],
139
"packageRules": [
1410
{
1511
"description": "Create PRs to roll back Go module if the current version is not found in the registry.",
1612
"matchManagers": ["gomod"],
17-
"rollbackPrs": true
13+
"rollbackPrs": true,
14+
"matchPaths": [
15+
"!integration/testdata/**",
16+
"!test/resources/**"
17+
]
1818
},
1919
{
2020
"description": "Automerge patch version updates for Go modules (except versions 0.x as they could have breaking changes)",
2121
"matchManagers": ["gomod"],
2222
"matchUpdateTypes": ["patch"],
2323
"matchCurrentVersion": "!/^(v?0)/",
2424
"automerge": true,
25-
"addLabels": ["renovate-automerge"]
25+
"addLabels": ["renovate-automerge"],
26+
"matchPaths": [
27+
"!integration/testdata/**",
28+
"!test/resources/**"
29+
]
30+
}
31+
],
32+
"customManagers": [
33+
{
34+
"customType": "regex",
35+
"matchStringsStrategy": "any",
36+
"managerFilePatterns": [
37+
"cmd\/golangBuild.go"
38+
],
39+
"matchStrings": [
40+
"\"github.com\/CycloneDX\/(?<depName>cyclonedx-gomod)\/cmd\/cyclonedx-gomod@v(?<currentValue>[^\"]+)\""
41+
],
42+
"depTypeTemplate": "dependencies",
43+
"datasourceTemplate": "github-releases",
44+
"depNameTemplate": "CycloneDX/{{{depName}}}",
45+
"extractVersionTemplate": "v(?<version>.*)",
46+
"autoReplaceStringTemplate": "\"github.com/{{{depName}}}/cmd/cyclonedx-gomod@v{{{newValue}}}\""
47+
},
48+
{
49+
"customType": "regex",
50+
"matchStringsStrategy": "any",
51+
"managerFilePatterns": [
52+
"cmd\/gradleExecuteBuild.go"
53+
],
54+
"matchStrings": [
55+
"\"org.cyclonedx:(?<depName>cyclonedx-gradle-plugin):(?<currentValue>[^\"\n]+)\""
56+
],
57+
"depTypeTemplate": "dependencies",
58+
"datasourceTemplate": "gradle-version",
59+
"depNameTemplate": "org.cyclonedx:{{{depName}}}",
60+
"extractVersionTemplate": "^(?<version>.*)",
61+
"autoReplaceStringTemplate": "\"{{{depName}}}:{{{newValue}}}\""
62+
},
63+
{
64+
"customType": "regex",
65+
"matchStringsStrategy": "any",
66+
"managerFilePatterns": [
67+
"cmd\/mavenBuild.go"
68+
],
69+
"matchStrings": [
70+
"\"org.cyclonedx:(?<depName>cyclonedx-maven-plugin):(?<currentValue>[^\"]+)\""
71+
],
72+
"depTypeTemplate": "dependencies",
73+
"datasourceTemplate": "maven",
74+
"depNameTemplate": "org.cyclonedx:{{{depName}}}",
75+
"extractVersionTemplate": "^(?<version>.*)",
76+
"autoReplaceStringTemplate": "\"{{{depName}}}:{{{newValue}}}\""
77+
},
78+
{
79+
"customType": "regex",
80+
"matchStringsStrategy": "any",
81+
"managerFilePatterns": [
82+
"integration\/testdata\/TestGradleIntegration\/java-project-with-bom-plugin\/build.gradle"
83+
],
84+
"matchStrings": [
85+
"id \"(?<depName>org.cyclonedx.bom)\" version \"(?<currentValue>.*)\""
86+
],
87+
"depTypeTemplate": "dependencies",
88+
"datasourceTemplate": "gradle-version",
89+
"depNameTemplate": "{{depName}}",
90+
"extractVersionTemplate": "(?<version>.*)",
91+
"autoReplaceStringTemplate": "id \"{{depName}}\" version \"{{newValue}}\""
92+
},
93+
{
94+
"customType": "regex",
95+
"matchStringsStrategy": "any",
96+
"managerFilePatterns": [
97+
"integration\/integration_golang_test.go"
98+
],
99+
"matchStrings": [
100+
"\"github.com\/CycloneDX\/(?<depName>cyclonedx-gomod)\/cmd\/cyclonedx-gomod@v(?<currentValue>[^\"]+)\""
101+
],
102+
"depTypeTemplate": "dependencies",
103+
"datasourceTemplate": "github-releases",
104+
"depNameTemplate": "CycloneDX/{{{depName}}}",
105+
"extractVersionTemplate": "v(?<version>.*)",
106+
"autoReplaceStringTemplate": "\"github.com/{{{depName}}}/cmd/cyclonedx-gomod@v{{{newValue}}}\""
26107
}
27108
],
28109
"postUpdateOptions": [

cmd/golangBuild_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ go 1.17`
284284
assert.NoError(t, err)
285285
assert.Equal(t, 3, len(utils.ExecMockRunner.Calls))
286286
assert.Equal(t, "go", utils.ExecMockRunner.Calls[0].Exec)
287-
assert.Equal(t, []string{"install", "github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]"}, utils.ExecMockRunner.Calls[0].Params)
287+
assert.Equal(t, []string{"install", golangCycloneDXPackage}, utils.ExecMockRunner.Calls[0].Params)
288288
assert.Equal(t, "cyclonedx-gomod", utils.ExecMockRunner.Calls[1].Exec)
289289
assert.Equal(t, []string{"mod", "-licenses", "-verbose=false", "-test", "-output", "bom-golang.xml", "-output-version", "1.4"}, utils.ExecMockRunner.Calls[1].Params)
290290
assert.Equal(t, "go", utils.ExecMockRunner.Calls[2].Exec)
@@ -330,7 +330,7 @@ go 1.17`
330330
CreateBOM: true,
331331
}
332332
utils := newGolangBuildTestsUtils()
333-
utils.ShouldFailOnCommand = map[string]error{"go install github.com/CycloneDX/cyclonedx-gomod/cmd/[email protected]": fmt.Errorf("install failure")}
333+
utils.ShouldFailOnCommand = map[string]error{"go install " + golangCycloneDXPackage: fmt.Errorf("install failure")}
334334
telemetryData := telemetry.CustomData{}
335335

336336
err := runGolangBuild(&config, &telemetryData, utils, &cpe)

cmd/mavenBuild.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
const (
2525
mvnBomFilename = "bom-maven"
2626
mvnSimpleBomFilename = "simple-bom-maven"
27+
mvnCycloneDXPackage = "org.cyclonedx:cyclonedx-maven-plugin:2.9.1"
2728
)
2829

2930
func mavenBuild(config mavenBuildOptions, telemetryData *telemetry.CustomData, commonPipelineEnvironment *mavenBuildCommonPipelineEnvironment) {
@@ -66,7 +67,7 @@ func runMakeBOMGoal(config *mavenBuildOptions, utils maven.Utils) error {
6667
}
6768
defines = append(defines, createBOMConfig...)
6869

69-
goals := []string{"org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeBom"}
70+
goals := []string{mvnCycloneDXPackage + ":makeBom"}
7071

7172
if config.Flatten {
7273
goals = append(goals, "flatten:flatten")
@@ -110,7 +111,7 @@ func runMavenBuild(config *mavenBuildOptions, _ *telemetry.CustomData, utils mav
110111

111112
if config.CreateBOM {
112113
// Append the makeAggregateBOM goal to the rest of the goals
113-
goals = append(goals, "org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeAggregateBom")
114+
goals = append(goals, mvnCycloneDXPackage+":makeAggregateBom")
114115
createBOMConfig := []string{
115116
"-DschemaVersion=1.4",
116117
"-DincludeBomSerialNumber=true",

cmd/mavenBuild_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestMavenBuild(t *testing.T) {
5757
assert.Nil(t, err)
5858
if assert.Equal(t, 2, len(mockedUtils.Calls), "Expected two Maven invocations (default + makeAggregateBom)") {
5959
assert.Equal(t, "mvn", mockedUtils.Calls[1].Exec)
60-
assert.Contains(t, mockedUtils.Calls[0].Params, "org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeAggregateBom")
60+
assert.Contains(t, mockedUtils.Calls[0].Params, mvnCycloneDXPackage+":makeAggregateBom")
6161
assert.Contains(t, mockedUtils.Calls[0].Params, "-DoutputName=bom-maven")
6262
}
6363
})

0 commit comments

Comments
 (0)