From 612828f7da54558d8def9f1e3bd9e62f7c1a8dd1 Mon Sep 17 00:00:00 2001 From: Christoph Raaflaub Date: Tue, 12 Nov 2024 16:24:31 +0100 Subject: [PATCH] run steps in parallel --- ci/main.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ci/main.go b/ci/main.go index 856efca8..30f0f9c4 100644 --- a/ci/main.go +++ b/ci/main.go @@ -18,6 +18,7 @@ import ( "context" "dagger/ci/internal/dagger" "fmt" + "sync" ) type Ci struct{} @@ -158,3 +159,36 @@ func (m *Ci) Ci(ctx context.Context, dir *dagger.Directory) *Results { Image: image, } } + +// Executes all the steps and returns a Results object +func (m *Ci) CiIntegration(ctx context.Context, dir *dagger.Directory) *Results { + var wg sync.WaitGroup + wg.Add(3) + + var lintOutput, _ = func() (string, error) { + defer wg.Done() + return "empty", error(nil) //m.Lint(ctx, dir) + }() + + var securityScan = func() *dagger.File { + defer wg.Done() + return m.Sast(ctx, dir) + }() + + //vulnerabilityScan := m.Vulnscan(ctx, m.SbomBuild(ctx, dir)) + + var image = func() *dagger.Container { + defer wg.Done() + return m.Build(ctx, dir) + }() + + // This Blocks the execution until its counter become 0 + wg.Wait() + + return &Results{ + LintOutput: lintOutput, + SecurityScan: securityScan, + // VulnerabilityScan: vulnerabilityScan, + Image: image, + } +}