Skip to content

Commit

Permalink
add all step
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Nov 12, 2024
1 parent ee5266e commit 535d644
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down Expand Up @@ -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,
}
}

0 comments on commit 535d644

Please sign in to comment.