You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
adding verbose log of cyclonedx (#4492)
* adding log of cyclonedx * fix test * fix integration test * fix assertion of test --------- Co-authored-by: asadu <aibyn_sadu@epam.com>
This commit is contained in:
@@ -570,7 +570,8 @@ func lookupGolangPrivateModulesRepositories(goModFile *modfile.File, globPattern
|
||||
}
|
||||
|
||||
func runBOMCreation(utils golangBuildUtils, outputFilename string) error {
|
||||
if err := utils.RunExecutable("cyclonedx-gomod", "mod", "-licenses", "-test", "-output", outputFilename, "-output-version", "1.4"); err != nil {
|
||||
|
||||
if err := utils.RunExecutable("cyclonedx-gomod", "mod", "-licenses", fmt.Sprintf("-verbose=%t", GeneralConfig.Verbose), "-test", "-output", outputFilename, "-output-version", "1.4"); err != nil {
|
||||
return fmt.Errorf("BOM creation failed: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -286,7 +286,7 @@ go 1.17`
|
||||
assert.Equal(t, "go", utils.ExecMockRunner.Calls[0].Exec)
|
||||
assert.Equal(t, []string{"install", "github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@v1.4.0"}, utils.ExecMockRunner.Calls[0].Params)
|
||||
assert.Equal(t, "cyclonedx-gomod", utils.ExecMockRunner.Calls[1].Exec)
|
||||
assert.Equal(t, []string{"mod", "-licenses", "-test", "-output", "bom-golang.xml", "-output-version", "1.4"}, utils.ExecMockRunner.Calls[1].Params)
|
||||
assert.Equal(t, []string{"mod", "-licenses", "-verbose=false", "-test", "-output", "bom-golang.xml", "-output-version", "1.4"}, utils.ExecMockRunner.Calls[1].Params)
|
||||
assert.Equal(t, "go", utils.ExecMockRunner.Calls[2].Exec)
|
||||
assert.Equal(t, []string{"build", "-trimpath"}, utils.ExecMockRunner.Calls[2].Params)
|
||||
})
|
||||
@@ -479,8 +479,9 @@ go 1.17`
|
||||
CreateBOM: true,
|
||||
TargetArchitectures: []string{"linux,amd64"},
|
||||
}
|
||||
GeneralConfig.Verbose = false
|
||||
utils := newGolangBuildTestsUtils()
|
||||
utils.ShouldFailOnCommand = map[string]error{"cyclonedx-gomod mod -licenses -test -output bom-golang.xml": fmt.Errorf("BOM creation failure")}
|
||||
utils.ShouldFailOnCommand = map[string]error{"cyclonedx-gomod mod -licenses -verbose=false -test -output bom-golang.xml -output-version 1.4": fmt.Errorf("BOM creation failure")}
|
||||
telemetryData := telemetry.CustomData{}
|
||||
|
||||
err := runGolangBuild(&config, &telemetryData, utils, &cpe)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestGolangIntegrationBuildProject1(t *testing.T) {
|
||||
"info golangBuild - DONE 8 tests",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml --jsonfile integration-report.out -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -verbose=false -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: go build -trimpath -o golang-app-linux.amd64 cmd/server/server.go",
|
||||
"info golangBuild - SUCCESS",
|
||||
)
|
||||
@@ -69,7 +69,7 @@ func TestGolangIntegrationBuildProject1MultiPackage(t *testing.T) {
|
||||
"info golangBuild - DONE 8 tests",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml --jsonfile integration-report.out -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -verbose=false -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: go build -trimpath -o golang-app-linux-amd64/ github.com/example/golang-app/cmd/server github.com/example/golang-app/cmd/helper",
|
||||
"info golangBuild - SUCCESS",
|
||||
)
|
||||
@@ -106,7 +106,7 @@ func TestGolangIntegrationBuildProject2(t *testing.T) {
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-go.xml --jsonfile unit-report.out -- -coverprofile=cover.out -tags=unit ./...",
|
||||
"info golangBuild - running command: go tool cover -html cover.out -o coverage.html",
|
||||
"info golangBuild - running command: gotestsum --junitfile TEST-integration.xml --jsonfile integration-report.out -- -tags=integration ./...",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -test -output bom-golang.xml",
|
||||
"info golangBuild - running command: cyclonedx-gomod mod -licenses -verbose=false -test -output bom-golang.xml",
|
||||
)
|
||||
|
||||
container.assertHasOutput(t,
|
||||
|
||||
Reference in New Issue
Block a user