Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions internal/project/auto/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ type CustomSteps struct {

// CustomStep defines a custom step to be built.
type CustomStep struct {
Name string `yaml:"name"`
Inputs []string `yaml:"inputs"`
Toplevel bool `yaml:"toplevel"`
Name string `yaml:"name"`
Inputs []string `yaml:"inputs"`
Dependants []string `yaml:"dependants"`
Toplevel bool `yaml:"toplevel"`
}

// CI defines CI settings.
Expand Down
10 changes: 10 additions & 0 deletions internal/project/auto/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func (builder *builder) BuildCustom() error {
step.AddInput(input)
}

for _, dependantName := range spec.Dependants {
dependant := dag.FindByName(dependantName, append(builder.targets, createdSteps...)...)

if dependant == nil {
return fmt.Errorf("failed to find dependant node %q for custom step %q", dependantName, spec.Name)
}

dependant.AddInput(step)
}

createdSteps = append(createdSteps, step)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/project/auto/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (builder *builder) BuildGolang() error {
builder.targets = append(builder.targets, unitTests)
allUnitTests = append(allUnitTests, unitTests)

coverage.InputPaths = append(coverage.InputPaths, fmt.Sprintf("coverage-%s.txt", unitTests.Name()))
coverage.AddDiscoveredInputs(fmt.Sprintf("coverage-%s.txt", unitTests.Name()))
}

builder.targets = append(builder.targets, coverage)
Expand Down
17 changes: 16 additions & 1 deletion internal/project/auto/integration_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
package auto

import (
"fmt"
"path/filepath"
"strings"

"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/xslices"

"github.com/siderolabs/kres/internal/project/common"
"github.com/siderolabs/kres/internal/project/golang"
Expand All @@ -31,7 +36,17 @@ func (builder *builder) BuildIntegrationTests() error {
}

for _, spec := range integrationTests.Tests {
build := golang.NewBuild(builder.meta, spec.Name, spec.Path, "go test -c -covermode=atomic")
build := golang.NewBuild(builder.meta, spec.Name, spec.Path,
fmt.Sprintf(

@smira smira Jun 9, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'd be nice to merge the output coverage of this step, and unit-tests step, and push the combined to gocov codecov step for visualization

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it merged by putting everything into a single long coverage.txt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, but I would assume it can pick up multiple files and merge them itself - but you need to experiment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've figured it out

"go test -c -covermode=atomic -coverpkg=%s",
strings.Join(
xslices.Map(builder.meta.CanonicalPaths, func(s string) string {
return filepath.Join(s, "/...")
}),
",",
),
),
)

build.Outputs = maps.Map(spec.Outputs, func(k string, m map[string]string) (string, golang.CompileConfig) {
return k, golang.CompileConfig(m)
Expand Down
8 changes: 7 additions & 1 deletion internal/project/service/codecov.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type CodeCov struct {

meta *meta.Options

discoveredPaths []string
InputPaths []string `yaml:"inputPaths"`
TargetThreshold int `yaml:"targetThreshold"`
Enabled bool `yaml:"enabled"`
Expand All @@ -42,6 +43,11 @@ func NewCodeCov(meta *meta.Options) *CodeCov {
}
}

// AddDiscoveredInputs sets automatically discovered codecov.txt files.
func (coverage *CodeCov) AddDiscoveredInputs(inputs ...string) {
coverage.discoveredPaths = append(coverage.discoveredPaths, inputs...)
}

// CompileDrone implements drone.Compiler.
func (coverage *CodeCov) CompileDrone(output *drone.Output) error {
if !coverage.Enabled {
Expand All @@ -62,7 +68,7 @@ func (coverage *CodeCov) CompileGitHubWorkflow(output *ghworkflow.Output) error
return nil
}

paths := xslices.Map(coverage.InputPaths, func(path string) string {
paths := xslices.Map(append(coverage.discoveredPaths, coverage.InputPaths...), func(path string) string {
return fmt.Sprintf("%s/%s", coverage.meta.ArtifactsPath, path)
})

Expand Down