From 535d6445e906e6d13635b3a7e4c1d059c95f9271 Mon Sep 17 00:00:00 2001 From: Reto Galante Date: Tue, 12 Nov 2024 14:56:09 +0100 Subject: [PATCH] add all step --- ci/main.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ci/main.go b/ci/main.go index 621109f1..03258b9f 100644 --- a/ci/main.go +++ b/ci/main.go @@ -22,6 +22,13 @@ import ( type Ci struct{} +type Results struct { + LintOutput string + SecurityScan *dagger.File + VulnerabilityScan *dagger.File + Image *dagger.Container +} + // Returns a Container built from the Dockerfile in the provided Directory func (m *Ci) Build(_ context.Context, dir *dagger.Directory) *dagger.Container { return dag.Container().Build(dir) @@ -34,7 +41,7 @@ func (m *Ci) Lint(ctx context.Context, dir *dagger.Directory) (string, error) { WithMountedDirectory("/mnt", dir). WithWorkdir("/mnt"). WithExec([]string{"gem", "install", "haml-lint"}). - WithExec([]string{"haml-lint", "--reporter", "json", "."}). + WithExec([]string{"haml-lint", "-r", "json", "."}). Stdout(ctx) } @@ -128,3 +135,17 @@ func (m *Ci) Vulnscan(ctx context.Context, sbom *dagger.File) *dagger.File { return trivy.Sbom(sbom).Report("json") } + +// Executes all the steps and returns a Results object +func (m *Ci) Ci(ctx context.Context, dir *dagger.Directory) *Results { + lintOutput, _ := m.Lint(ctx, dir) + securityScan := m.Sast(ctx, dir) + vulnerabilityScan := m.Vulnscan(ctx, m.SbomBuild(ctx, dir)) + image := m.Build(ctx, dir) + return &Results{ + LintOutput: lintOutput, + SecurityScan: securityScan, + VulnerabilityScan: vulnerabilityScan, + Image: image, + } +}