-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d9cce7
commit fd0fe10
Showing
20 changed files
with
203 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated/internal/dagger" | ||
) | ||
|
||
func validateCompatibility( | ||
ctx context.Context, | ||
|
||
// +defaultPath="./" | ||
source *dagger.Directory, | ||
) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"dagger/replicated/internal/dagger" | ||
"time" | ||
) | ||
|
||
// CacheBustingExec is a helper function that will add a cache busting env var automatically | ||
// to the container. This is useful when Exec target is a dynamic event acting on an entity outside | ||
// of the container that you absolutely want to re-run every time. | ||
// | ||
// Temporary hack until cache controls are a thing: https://docs.dagger.io/cookbook/#invalidate-cache | ||
func CacheBustingExec(args []string, opts ...dagger.ContainerWithExecOpts) dagger.WithContainerFunc { | ||
return func(c *dagger.Container) *dagger.Container { | ||
if c == nil { | ||
panic("CacheBustingExec requires a container, but container was nil") | ||
} | ||
return c.WithEnvVariable("DAGGER_CACHEBUSTER_CBE", time.Now().String()).WithExec(args, opts...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated/internal/dagger" | ||
) | ||
|
||
func validateFunctionality( | ||
ctx context.Context, | ||
|
||
// +defaultPath="./" | ||
source *dagger.Directory, | ||
) error { | ||
goModCache := dag.CacheVolume("replicated-go-mod-122") | ||
goBuildCache := dag.CacheVolume("replicated-go-build-121") | ||
|
||
// unit tests | ||
unitTest := dag.Container(). | ||
From("golang:1.22"). | ||
WithMountedDirectory("/go/src/github.com/replicatedhq/replicated", source). | ||
WithWorkdir("/go/src/github.com/replicatedhq/replicated"). | ||
WithMountedCache("/go/pkg/mod", goModCache). | ||
WithEnvVariable("GOMODCACHE", "/go/pkg/mod"). | ||
WithMountedCache("/go/build-cache", goBuildCache). | ||
WithEnvVariable("GOCACHE", "/go/build-cache"). | ||
With(CacheBustingExec([]string{"make", "test-unit"})) | ||
|
||
_, err := unitTest.Stderr(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated/internal/dagger" | ||
) | ||
|
||
func validatePerformance( | ||
ctx context.Context, | ||
|
||
// +defaultPath="./" | ||
source *dagger.Directory, | ||
) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated/internal/dagger" | ||
) | ||
|
||
func validateSecurity( | ||
ctx context.Context, | ||
|
||
// +defaultPath="./" | ||
source *dagger.Directory, | ||
) error { | ||
goModCache := dag.CacheVolume("replicated-go-mod-122") | ||
goBuildCache := dag.CacheVolume("replicated-go-build-121") | ||
|
||
// run semgrep | ||
semgrep := dag.Container(). | ||
From("returntocorp/semgrep"). | ||
WithMountedDirectory("/go/src/github.com/replicatedhq/replicated", source). | ||
WithWorkdir("/go/src/github.com/replicatedhq/replicated"). | ||
WithMountedCache("/go/pkg/mod", goModCache). | ||
WithEnvVariable("GOMODCACHE", "/go/pkg/mod"). | ||
WithMountedCache("/go/build-cache", goBuildCache). | ||
WithEnvVariable("GOCACHE", "/go/build-cache"). | ||
With(CacheBustingExec([]string{"semgrep", "scan", "--config=p/golang", "."})) | ||
|
||
_, err := semgrep.Stderr(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated/internal/dagger" | ||
) | ||
|
||
func (r *Replicated) Validate( | ||
ctx context.Context, | ||
|
||
// +defaultPath="./" | ||
source *dagger.Directory, | ||
) error { | ||
if err := validateSecurity(ctx, source); err != nil { | ||
return err | ||
} | ||
|
||
if err := validateFunctionality(ctx, source); err != nil { | ||
return err | ||
} | ||
|
||
if err := validateCompatibility(ctx, source); err != nil { | ||
return err | ||
} | ||
|
||
if err := validatePerformance(ctx, source); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.