Skip to content

Commit

Permalink
Exclude the coverage files from the annotate step (#5773) (#6330)
Browse files Browse the repository at this point in the history
* Exclude the coverage files from the annotate step

Signed-off-by: Alexandros Sapranidis <alexandros@elastic.co>
(cherry picked from commit 8ebaa7d)

Co-authored-by: Alexandros Sapranidis <alexandros@elastic.co>
  • Loading branch information
mergify[bot] and alexsapran authored Dec 30, 2024
1 parent 48525f5 commit b70c1d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ steps:
- label: ":junit: Junit annotate"
plugins:
- junit-annotate#v2.5.0:
artifacts: "build/*.xml"
artifacts: "**TEST-*.xml"
always-annotate: true
agents:
provider: "gcp"
Expand Down
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

0 comments on commit b70c1d3

Please sign in to comment.