Files
Kevin Minehart 13f4cf162e CI: move grafana-build into pkg/build (#105640)
* move grafana-build into pkg/build
2025-05-20 10:48:00 -05:00

46 lines
1.3 KiB
Go

package docker
import (
"context"
"fmt"
"dagger.io/dagger"
"github.com/grafana/grafana/pkg/build/daggerbuild/backend"
"github.com/grafana/grafana/pkg/build/daggerbuild/containers"
"github.com/grafana/grafana/pkg/build/daggerbuild/e2e"
"github.com/grafana/grafana/pkg/build/daggerbuild/frontend"
)
// Verify uses the given package (.docker.tar.gz) and grafana source code (src) to run the e2e smoke tests.
// the returned directory is the e2e artifacts created by cypress (screenshots and videos).
func Verify(
ctx context.Context,
d *dagger.Client,
image *dagger.File,
src *dagger.Directory,
yarnCache *dagger.CacheVolume,
distro backend.Distribution,
) error {
nodeVersion, err := frontend.NodeVersion(d, src).Stdout(ctx)
if err != nil {
return fmt.Errorf("failed to get node version from source code: %w", err)
}
var (
platform = backend.Platform(distro)
)
// This grafana service runs in the background for the e2e tests
service := d.Container(dagger.ContainerOpts{
Platform: platform,
}).
WithMountedTemp("/var/lib/grafana/plugins").
Import(image).
WithExposedPort(3000)
// TODO: Add LICENSE to containers and implement validation
container := e2e.ValidatePackage(d, service.AsService(), src, yarnCache, nodeVersion)
_, err = containers.ExitError(ctx, container)
return err
}