From f84c650a71bba339da7f96303292717569d4caa6 Mon Sep 17 00:00:00 2001 From: joshhunt Date: Tue, 1 Jul 2025 13:23:46 +0100 Subject: [PATCH] add arg for sharding, but not using it yet --- pkg/build/e2e-playwright/e2e.go | 9 +++++++-- pkg/build/e2e-playwright/main.go | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pkg/build/e2e-playwright/e2e.go b/pkg/build/e2e-playwright/e2e.go index 8eb3db64411..573ba390b2b 100644 --- a/pkg/build/e2e-playwright/e2e.go +++ b/pkg/build/e2e-playwright/e2e.go @@ -38,10 +38,15 @@ func GetVersions(ctx context.Context, src *dagger.Directory) (Deps, error) { }, nil } +type RunTestOpts struct { + Shard string + GrafanaService *dagger.Service +} + func RunTest( ctx context.Context, d *dagger.Client, - grafanaService *dagger.Service, + opts RunTestOpts, ) (*dagger.Container, error) { grafanaDir := "." // TODO: arg @@ -97,7 +102,7 @@ func RunTest( WithExec([]string{"yarn", "e2e:plugin:build"}). WithEnvVariable("HOST", grafanaHost). WithEnvVariable("PORT", fmt.Sprint(grafanaPort)). - WithServiceBinding(grafanaHost, grafanaService). + WithServiceBinding(grafanaHost, opts.GrafanaService). WithEnvVariable("PLAYWRIGHT_HTML_OPEN", "never"). WithExec([]string{"yarn", "e2e:playwright"}, dagger.ContainerWithExecOpts{ Expect: dagger.ReturnTypeAny, diff --git a/pkg/build/e2e-playwright/main.go b/pkg/build/e2e-playwright/main.go index 4e0d860d559..bad95732065 100644 --- a/pkg/build/e2e-playwright/main.go +++ b/pkg/build/e2e-playwright/main.go @@ -52,6 +52,10 @@ func NewApp() *cli.Command { Validator: mustBeFile("license", true), TakesFile: true, }, + &cli.StringFlag{ + Name: "shard", + Usage: "Test shard to run. See Playwright docs", + }, // &cli.StringFlag{ // Name: "config", // Usage: "Path to the pa11y config file to use", @@ -78,6 +82,7 @@ func run(ctx context.Context, cmd *cli.Command) error { grafanaDir := cmd.String("grafana-dir") targzPath := cmd.String("package") licensePath := cmd.String("license") + pwShard := cmd.String("shard") // pa11yConfigPath := cmd.String("config") // pa11yResultsPath := cmd.String("results") // noThresholdFail := cmd.Bool("no-threshold-fail") @@ -116,7 +121,12 @@ func run(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("failed to create Grafana service: %w", err) } - c, runErr := RunTest(ctx, d, svc) + runOpts := RunTestOpts{ + GrafanaService: svc, + Shard: pwShard, + } + + c, runErr := RunTest(ctx, d, runOpts) if runErr != nil { return fmt.Errorf("failed to run e2e test suite: %w", runErr) }