rework pipeline
This commit is contained in:
18
pkg/tasks/golang/cache.go
Normal file
18
pkg/tasks/golang/cache.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package golang
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"dagger.io/dagger"
|
||||
)
|
||||
|
||||
func Cache(ctx context.Context, client *dagger.Client, container *dagger.Container) (*dagger.Container, error) {
|
||||
cacheKey := "gomods"
|
||||
cacheID, err := client.CacheVolume(cacheKey).ID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return container.
|
||||
WithMountedCache(cacheID, "/cache").
|
||||
WithEnvVariable("GOMODCACHE", "/cache"), nil
|
||||
}
|
22
pkg/tasks/golang/test.go
Normal file
22
pkg/tasks/golang/test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package golang
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"dagger.io/dagger"
|
||||
)
|
||||
|
||||
func Test(ctx context.Context, container *dagger.Container) error {
|
||||
log.Printf("testing: image")
|
||||
c := container.Exec(dagger.ContainerExecOpts{
|
||||
Args: []string{"go", "test", "./..."},
|
||||
})
|
||||
|
||||
_, err := c.ExitCode(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user