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

Exclude the coverage files from the annotate step #5773

Merged
merged 8 commits into from
Oct 15, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package mage

import (
"bytes"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -341,42 +340,6 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
}
}

// Generate an XML code coverage report.
var codecovReport string
if params.CoverageProfileFile != "" {
fmt.Println(">> go run gocover-cobertura:", params.CoverageProfileFile, "Started")

// execute gocover-cobertura in order to create cobertura report
// install pre-requisites
installCobertura := sh.RunCmd("go", "install", "github.com/boumenot/gocover-cobertura@latest")
if err = installCobertura(); err != nil {
return fmt.Errorf("failed to install gocover-cobertura: %w", err)
}

codecovReport = strings.TrimSuffix(params.CoverageProfileFile,
filepath.Ext(params.CoverageProfileFile)) + "-cov.xml"

coverage, err := os.ReadFile(params.CoverageProfileFile)
if err != nil {
return fmt.Errorf("failed to read code coverage report: %w", err)
}

coberturaFile, err := os.Create(codecovReport)
if err != nil {
return err
}
defer coberturaFile.Close()

coverToXML := exec.Command("gocover-cobertura")
coverToXML.Stdout = coberturaFile
coverToXML.Stderr = os.Stderr
coverToXML.Stdin = bytes.NewReader(coverage)
if err = coverToXML.Run(); err != nil {
return fmt.Errorf("failed to write XML code coverage report: %w", err)
}
fmt.Println(">> go run gocover-cobertura:", params.CoverageProfileFile, "Created")
}

// Return an error indicating that testing failed.
if goTestErr != nil {
fmt.Println(">> go test:", params.LogName, "Test Failed")
Expand Down