@@ -18,16 +18,20 @@ import (
1818 "context"
1919 "dagger/ci/internal/dagger"
2020 "fmt"
21- "sync"
21+ "sync"
2222)
2323
2424type Ci struct {}
2525
2626type Results struct {
27- LintOutput string
28- SecurityScan * dagger.File
27+ // haml-lint output as json
28+ LintOutput * dagger.File
29+ // brakeman output as plain text
30+ SecurityScan * dagger.File
31+ // trivy results as json
2932 VulnerabilityScan * dagger.File
30- Image * dagger.Container
33+ // the built image
34+ Image * dagger.Container
3135}
3236
3337// Returns a Container built from the Dockerfile in the provided Directory
@@ -36,14 +40,14 @@ func (m *Ci) Build(_ context.Context, dir *dagger.Directory) *dagger.Container {
3640}
3741
3842// Returns the result of haml-lint run against the sources in the provided Directory
39- func (m * Ci ) Lint (ctx context.Context , dir * dagger.Directory ) ( string , error ) {
43+ func (m * Ci ) Lint (ctx context.Context , dir * dagger.Directory ) * dagger. File {
4044 return dag .Container ().
4145 From ("ruby:latest" ).
4246 WithMountedDirectory ("/mnt" , dir ).
4347 WithWorkdir ("/mnt" ).
4448 WithExec ([]string {"gem" , "install" , "haml-lint" }).
45- WithExec ([]string {"haml-lint " , "-r " , "json" , ". " }).
46- Stdout ( ctx )
49+ WithExec ([]string {"sh " , "-c " , "haml-lint -r json . > lint.json || true " }).
50+ File ( "lint.json" )
4751}
4852
4953// Returns the Sast report as a file
@@ -151,7 +155,7 @@ func (m *Ci) Vulnscan(sbom *dagger.File) *dagger.File {
151155
152156// Executes all the steps and returns a Results object
153157func (m * Ci ) Ci (ctx context.Context , dir * dagger.Directory ) * Results {
154- lintOutput , _ := m .Lint (ctx , dir )
158+ lintOutput := m .Lint (ctx , dir )
155159 securityScan := m .Sast (ctx , dir )
156160 image := m .Build (ctx , dir )
157161 sbom := m .Sbom (image )
@@ -170,9 +174,9 @@ func (m *Ci) CiIntegration(ctx context.Context, dir *dagger.Directory) *Results
170174 var wg sync.WaitGroup
171175 wg .Add (3 )
172176
173- var lintOutput , _ = func () ( string , error ) {
177+ var lintOutput = func () * dagger. File {
174178 defer wg .Done ()
175- return "empty" , error ( nil ) // m.Lint(ctx, dir)
179+ return m .Lint (ctx , dir )
176180 }()
177181
178182 var securityScan = func () * dagger.File {
@@ -188,12 +192,12 @@ func (m *Ci) CiIntegration(ctx context.Context, dir *dagger.Directory) *Results
188192 }()
189193
190194 // This Blocks the execution until its counter become 0
191- wg .Wait ()
195+ wg .Wait ()
192196
193197 return & Results {
194- LintOutput : lintOutput ,
195- SecurityScan : securityScan ,
196- // VulnerabilityScan: vulnerabilityScan,
197- Image : image ,
198+ LintOutput : lintOutput ,
199+ SecurityScan : securityScan ,
200+ // VulnerabilityScan: vulnerabilityScan,
201+ Image : image ,
198202 }
199203}
0 commit comments