E2E: Run playwright cloud plugins tests as part of github actions (#109055)

* add github workflow scaffolding

* update comments

* Add image and resource commands

* Add secrets paths

* Block workflow run for forks

* ignore via package.json, update CODEOWNERS

* fix workflow path

* remove old azure monitor test

* pull docker image first

* add permissions for docker pull step

* checkout first

* keep creds file

* try all in one job

* with creds...

* add cloud: 'azure'

* pass CLOUD to docker

* add -playwright

* actually use the env vars

* don't need to pass CLOUD env var

* remove commented out code and tidy up

* kick CI

* Update container names and set PLAYWRIGHT_CI

* Update path

* fix zizmor violation

* use bigger runner, add double quoting

* add separate command and increase timeout

* remove timeout

* parameterise the e2e command in CI

* move cloud-plugins-e2e-tests into normal e2e test workflow

* fix detect changes

* pass creds into dagger

* try remove quotes

* add a debug log

* exec playwright command after mounting file

* reassign e2eContainer, add change to check the tests fail correctly

* fix test

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
This commit is contained in:
Ashley Harrison
2025-08-19 09:25:16 +01:00
committed by GitHub
co-authored by Andreas Christou
parent 1e6719f571
commit 0687017595
8 changed files with 125 additions and 376 deletions
+16 -8
View File
@@ -23,6 +23,8 @@ type RunTestOpts struct {
HTMLReportExportDir string
BlobReportExportDir string
TestResultsExportDir string
PlaywrightCommand string
CloudPluginCreds *dagger.File
}
func RunTest(
@@ -47,10 +49,16 @@ func RunTest(
WithEnvVariable("bustcache", "1").
WithEnvVariable("PLAYWRIGHT_HTML_OPEN", "never").
WithEnvVariable("PLAYWRIGHT_HTML_OUTPUT_DIR", htmlResultsDir).
WithEnvVariable("PLAYWRIGHT_BLOB_OUTPUT_DIR", blobResultsDir).
WithExec(playwrightCommand, dagger.ContainerWithExecOpts{
Expect: dagger.ReturnTypeAny,
})
WithEnvVariable("PLAYWRIGHT_BLOB_OUTPUT_DIR", blobResultsDir)
if opts.CloudPluginCreds != nil {
fmt.Println("DEBUG: CloudPluginCreds file is provided, mounting to /tmp/outputs.json")
e2eContainer = e2eContainer.WithMountedFile("/tmp/outputs.json", opts.CloudPluginCreds)
}
e2eContainer = e2eContainer.WithExec(playwrightCommand, dagger.ContainerWithExecOpts{
Expect: dagger.ReturnTypeAny,
})
if opts.TestResultsExportDir != "" {
_, err := e2eContainer.Directory(testResultsDir).Export(ctx, opts.TestResultsExportDir)
@@ -89,14 +97,14 @@ func buildPlaywrightCommand(opts RunTestOpts) []string {
playwrightReporters = append(playwrightReporters, "blob")
}
playwrightCommand := []string{
"yarn",
"e2e:playwright",
playwrightExec := strings.Split(opts.PlaywrightCommand, " ")
playwrightCommand := append(playwrightExec,
"--reporter",
strings.Join(playwrightReporters, ","),
"--output",
testResultsDir,
}
)
if opts.Shard != "" {
playwrightCommand = append(playwrightCommand, "--shard", opts.Shard)
+20
View File
@@ -71,6 +71,17 @@ func NewApp() *cli.Command {
Usage: "Enables the blob reporter, exported to this directory. Useful with --shard (optional)",
Validator: mustBeDir("blob-dir", true, true),
},
&cli.StringFlag{
Name: "playwright-command",
Usage: "The playwright command to run.",
Value: "yarn e2e:playwright",
},
&cli.StringFlag{
Name: "cloud-plugin-creds",
Usage: "Path to the cloud plugin credentials file (only required for running @cloud-plugins e2e tests)",
Validator: mustBeFile("cloud-plugin-creds", true),
TakesFile: true,
},
},
Action: run,
}
@@ -80,10 +91,12 @@ func run(ctx context.Context, cmd *cli.Command) error {
grafanaDir := cmd.String("grafana-dir")
targzPath := cmd.String("package")
licensePath := cmd.String("license")
cloudPluginCredsPath := cmd.String("cloud-plugin-creds")
pwShard := cmd.String("shard")
resultsDir := cmd.String("results-dir")
htmlDir := cmd.String("html-dir")
blobDir := cmd.String("blob-dir")
playwrightCommand := cmd.String("playwright-command")
// pa11yConfigPath := cmd.String("config")
// pa11yResultsPath := cmd.String("results")
// noThresholdFail := cmd.Bool("no-threshold-fail")
@@ -156,6 +169,11 @@ func run(ctx context.Context, cmd *cli.Command) error {
license = d.Host().File(licensePath)
}
var cloudPluginCreds *dagger.File
if cloudPluginCredsPath != "" {
cloudPluginCreds = d.Host().File(cloudPluginCredsPath)
}
svc, err := GrafanaService(ctx, d, GrafanaServiceOpts{
HostSrc: grafanaHostSrc,
FrontendContainer: frontendContainer,
@@ -174,6 +192,8 @@ func run(ctx context.Context, cmd *cli.Command) error {
TestResultsExportDir: resultsDir,
HTMLReportExportDir: htmlDir,
BlobReportExportDir: blobDir,
PlaywrightCommand: playwrightCommand,
CloudPluginCreds: cloudPluginCreds,
}
c, runErr := RunTest(ctx, d, runOpts)