Skip to content
Open
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
13 changes: 13 additions & 0 deletions .github/workflows/checks-codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ jobs:
id: acceptance_test
run: E2E_INSTRUMENTATION=true make acceptance

- name: Print profiling report
if: always()
run: cat /tmp/ec-profile/report.txt 2>/dev/null || echo "No profiling report found"

- name: Upload profiling data
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: acceptance-profiling
path: /tmp/ec-profile/
retention-days: 7
if-no-files-found: ignore

- name: Upload acceptance coverage artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
Expand Down
7 changes: 7 additions & 0 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/conforma/cli/acceptance/kubernetes"
"github.com/conforma/cli/acceptance/log"
"github.com/conforma/cli/acceptance/pipeline"
"github.com/conforma/cli/acceptance/profile"
"github.com/conforma/cli/acceptance/registry"
"github.com/conforma/cli/acceptance/rekor"
"github.com/conforma/cli/acceptance/tekton"
Expand Down Expand Up @@ -131,11 +132,13 @@ func initializeScenario(sc *godog.ScenarioContext) {
sc.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
logger, ctx := log.LoggerFor(ctx)
logger.Name(sc.Name)
ctx = profile.ScenarioStart(ctx)

return context.WithValue(ctx, testenv.Scenario, sc), nil
})

sc.After(func(ctx context.Context, scenario *godog.Scenario, scenarioErr error) (context.Context, error) {
profile.ScenarioEnd(ctx, scenario.Name, scenario.Uri)
// Log scenario end with status - write to /dev/tty to bypass capture
if tty, err := os.OpenFile("/dev/tty", os.O_WRONLY, 0); err == nil {
// Strip the working directory prefix to show relative paths
Expand Down Expand Up @@ -196,6 +199,9 @@ func TestFeatures(t *testing.T) {

ctx := setupContext(t)

profile.Init()
defer profile.Report()

opts := godog.Options{
Format: "pretty",
Paths: []string{featuresDir},
Expand All @@ -221,6 +227,7 @@ func TestFeatures(t *testing.T) {

if exitCode != 0 {
// Exit directly without t.Fatal to avoid verbose Go test output
profile.Report()
os.Exit(1)
}
}
Expand Down
4 changes: 4 additions & 0 deletions acceptance/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/testcontainers/testcontainers-go/wait"

"github.com/conforma/cli/acceptance/log"
"github.com/conforma/cli/acceptance/profile"
"github.com/conforma/cli/acceptance/testenv"
)

Expand Down Expand Up @@ -179,16 +180,19 @@ func startStubGitServer(ctx context.Context) (context.Context, error) {

logger, ctx := log.LoggerFor(ctx)

endContainer := profile.BeginContainer("git")
git, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
Logger: logger,
})
if err != nil {
endContainer()
return ctx, err
}

port, err := git.MappedPort(ctx, "443/tcp")
endContainer()
if err != nil {
return ctx, err
}
Expand Down
16 changes: 16 additions & 0 deletions acceptance/kubernetes/kind/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/conforma/cli/acceptance/kubernetes/types"
"github.com/conforma/cli/acceptance/kustomize"
"github.com/conforma/cli/acceptance/log"
"github.com/conforma/cli/acceptance/profile"
"github.com/conforma/cli/acceptance/registry"
)

Expand Down Expand Up @@ -133,6 +134,8 @@ func Start(givenCtx context.Context) (ctx context.Context, kCluster types.Cluste

create.Do(func() {
logger.Log("Starting Kind cluster")
endKindTotal := profile.Begin("kind-cluster-total")
defer endKindTotal()

var configDir string
configDir, err = os.MkdirTemp("", "ec-acceptance.*")
Expand Down Expand Up @@ -172,6 +175,7 @@ func Start(givenCtx context.Context) (ctx context.Context, kCluster types.Cluste
kCluster.registryPort = int32(port) //nolint:gosec // G115 - ports shouldn't be larger than int32
}

endNodeCreate := profile.Begin("kind-node-create")
if err = kCluster.provider.Create(kCluster.name,
k.CreateWithV1Alpha4Config(&v1alpha4.Cluster{
TypeMeta: v1alpha4.TypeMeta{
Expand All @@ -197,9 +201,11 @@ func Start(givenCtx context.Context) (ctx context.Context, kCluster types.Cluste
},
}),
k.CreateWithKubeconfigPath(kCluster.kubeconfigPath)); err != nil {
endNodeCreate()
logger.Errorf("Unable launch the Kind cluster: %v", err)
return
}
endNodeCreate()

rules := clientcmd.NewDefaultClientConfigLoadingRules()
rules.ExplicitPath = kCluster.kubeconfigPath
Expand Down Expand Up @@ -231,30 +237,40 @@ func Start(givenCtx context.Context) (ctx context.Context, kCluster types.Cluste
kCluster.mapper = restmapper.NewDiscoveryRESTMapper(resources)
}

endApplyConfig := profile.Begin("kind-apply-config")
var yaml []byte
yaml, err = renderTestConfiguration(&kCluster)
if err != nil {
endApplyConfig()
logger.Errorf("Unable to kustomize test configuration: %v", err)
return
}

err = applyConfiguration(ctx, &kCluster, yaml)
if err != nil {
endApplyConfig()
logger.Errorf("Unable apply cluster configuration: %v", err)
return
}
endApplyConfig()

endBuildCli := profile.Begin("kind-build-cli-image")
err = kCluster.buildCliImage(ctx)
if err != nil {
endBuildCli()
logger.Errorf("Unable to build CLI image: %v", err)
return
}
endBuildCli()

endBuildBundle := profile.Begin("kind-build-task-bundle")
err = kCluster.buildTaskBundleImage(ctx)
if err != nil {
endBuildBundle()
logger.Errorf("Unable to build Task image: %v", err)
return
}
endBuildBundle()

globalCluster = &kCluster

Expand Down
Loading
Loading