diff --git a/.sauce/playwright.yml b/.sauce/playwright.yml index e1dd4551f..65a1ea6af 100644 --- a/.sauce/playwright.yml +++ b/.sauce/playwright.yml @@ -9,20 +9,10 @@ sauce: build: "$BUILD_ID" defaults: timeout: 5m -docker: - fileTransfer: mount rootDir: tests/e2e/playwright/ playwright: version: 1.31.1 suites: - - name: "firefox test in docker" - mode: docker - testMatch: ['.*.js'] - env: - hello: world - params: - browserName: "firefox" - - name: "chromium test in sauce" platformName: "Windows 10" testMatch: ['.*.js'] diff --git a/Makefile b/Makefile index 154e93f3d..601c33d5b 100644 --- a/Makefile +++ b/Makefile @@ -31,10 +31,6 @@ coverage: go tool cover -func=coverage.out @rm coverage.out -#playwright-ci: @ Run tests against playwright in CI mode -playwright-ci: build-linux - docker run --name playwright-ci -e "CI=true" -v $(shell pwd):/home/gitty/ -w "/home/gitty" --rm saucelabs/stt-playwright-node:latest "/home/gitty/saucectl" run -c ./.sauce/playwright.yml --verbose - #testcafe-ci: @ Run tests against testcafe in CI mode testcafe-ci: build-linux docker run --name testcafe-ci -e "CI=true" -v $(shell pwd):/home/gitty/ -w "/home/gitty" --rm saucelabs/stt-testcafe-node:latest "/home/gitty/saucectl" run -c ./.sauce/testcafe.yml --verbose diff --git a/api/saucectl.schema.json b/api/saucectl.schema.json index 1d6206906..cc4bcf212 100644 --- a/api/saucectl.schema.json +++ b/api/saucectl.schema.json @@ -1250,33 +1250,6 @@ { "$ref": "#/allOf/0/then/allOf/0" }, - { - "$schema": "https://json-schema.org/draft-07/schema", - "title": "saucectl docker specific schema", - "description": "Subschema for docker specific settings", - "type": "object", - "properties": { - "docker": { - "description": "Properties specific to docker.", - "type": "object", - "properties": { - "fileTransfer": { - "description": "Control how files are made available to the docker image.", - "enum": [ - "copy", - "mount" - ] - }, - "image": { - "description": "Override which docker image to use (in case you have a custom image).", - "type": "string" - } - }, - "additionalProperties": false - } - }, - "additionalProperties": true - }, { "$ref": "#/allOf/0/then/allOf/1" }, @@ -1301,13 +1274,6 @@ "description": "Settings that are applied onto every suite by default, if no value is set on a suite explicitly.", "type": "object", "properties": { - "mode": { - "description": "Instructs saucectl run tests remotely through Sauce Labs (sauce) or locally on docker.", - "enum": [ - "docker", - "sauce" - ] - }, "timeout": { "$ref": "#/allOf/9/then/definitions/suite/properties/timeout" } @@ -1361,9 +1327,6 @@ "description": "The name of the test suite, which will be reflected in the test results in Sauce Labs.", "type": "string" }, - "mode": { - "$ref": "#/allOf/3/then/properties/defaults/properties/mode" - }, "playwrightVersion": { "$ref": "#/allOf/8/then/properties/playwright/properties/version" }, @@ -1617,7 +1580,31 @@ "$ref": "#/allOf/0/then/allOf/0" }, { - "$ref": "#/allOf/3/then/allOf/1" + "$schema": "https://json-schema.org/draft-07/schema", + "title": "saucectl docker specific schema", + "description": "Subschema for docker specific settings", + "type": "object", + "properties": { + "docker": { + "description": "Properties specific to docker.", + "type": "object", + "properties": { + "fileTransfer": { + "description": "Control how files are made available to the docker image.", + "enum": [ + "copy", + "mount" + ] + }, + "image": { + "description": "Override which docker image to use (in case you have a custom image).", + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": true }, { "$ref": "#/allOf/0/then/allOf/1" @@ -1644,7 +1631,11 @@ "type": "object", "properties": { "mode": { - "$ref": "#/allOf/3/then/properties/defaults/properties/mode" + "description": "Instructs saucectl run tests remotely through Sauce Labs (sauce) or locally on docker.", + "enum": [ + "docker", + "sauce" + ] }, "timeout": { "$ref": "#/allOf/9/then/definitions/suite/properties/timeout" @@ -1747,7 +1738,7 @@ "$ref": "#/allOf/0/then/properties/env" }, "mode": { - "$ref": "#/allOf/3/then/properties/defaults/properties/mode" + "$ref": "#/allOf/5/then/properties/defaults/properties/mode" }, "shard": { "description": "When sharding is configured, saucectl automatically splits the tests (e.g. by spec or concurrency) so that they can easily run in parallel.", @@ -2283,7 +2274,7 @@ "$ref": "#/allOf/0/then/allOf/0" }, { - "$ref": "#/allOf/3/then/allOf/1" + "$ref": "#/allOf/5/then/allOf/1" }, { "$ref": "#/allOf/0/then/allOf/1" @@ -2310,7 +2301,7 @@ "type": "object", "properties": { "mode": { - "$ref": "#/allOf/3/then/properties/defaults/properties/mode" + "$ref": "#/allOf/5/then/properties/defaults/properties/mode" }, "timeout": { "$ref": "#/allOf/9/then/definitions/suite/properties/timeout" @@ -2423,7 +2414,7 @@ ] }, "mode": { - "$ref": "#/allOf/3/then/properties/defaults/properties/mode" + "$ref": "#/allOf/5/then/properties/defaults/properties/mode" }, "shard": { "description": "When sharding is configured, saucectl automatically splits the tests (e.g. by spec or concurrency) so that they can easily run in parallel.", diff --git a/api/v1alpha/framework/playwright.schema.json b/api/v1alpha/framework/playwright.schema.json index b62b81b63..7c8498c43 100644 --- a/api/v1alpha/framework/playwright.schema.json +++ b/api/v1alpha/framework/playwright.schema.json @@ -7,9 +7,6 @@ { "$ref": "../subschema/artifacts.schema.json" }, - { - "$ref": "../subschema/docker.schema.json" - }, { "$ref": "../subschema/npm.schema.json" }, @@ -34,9 +31,6 @@ "description": "Settings that are applied onto every suite by default, if no value is set on a suite explicitly.", "type": "object", "properties": { - "mode": { - "$ref": "../subschema/common.schema.json#/definitions/mode" - }, "timeout": { "$ref": "../subschema/common.schema.json#/definitions/timeout" } @@ -90,9 +84,6 @@ "description": "The name of the test suite, which will be reflected in the test results in Sauce Labs.", "type": "string" }, - "mode": { - "$ref": "../subschema/common.schema.json#/definitions/mode" - }, "playwrightVersion": { "$ref": "../subschema/common.schema.json#/definitions/version" }, diff --git a/internal/cmd/run/playwright.go b/internal/cmd/run/playwright.go index 6cf3bf33c..ccab93dee 100644 --- a/internal/cmd/run/playwright.go +++ b/internal/cmd/run/playwright.go @@ -17,7 +17,6 @@ import ( "github.com/saucelabs/saucectl/internal/ci" "github.com/saucelabs/saucectl/internal/config" "github.com/saucelabs/saucectl/internal/credentials" - "github.com/saucelabs/saucectl/internal/docker" "github.com/saucelabs/saucectl/internal/flags" "github.com/saucelabs/saucectl/internal/framework" "github.com/saucelabs/saucectl/internal/msg" @@ -150,7 +149,7 @@ func runPlaywright(cmd *cobra.Command, isCLIDriven bool) (int, error) { go func() { props := usage.Properties{} props.SetFramework("playwright").SetFVersion(p.Playwright.Version).SetFlags(cmd.Flags()).SetSauceConfig(p.Sauce). - SetArtifacts(p.Artifacts).SetDocker(p.Docker).SetNPM(p.Npm).SetNumSuites(len(p.Suites)).SetJobs(captor.Default.TestResults). + SetArtifacts(p.Artifacts).SetNPM(p.Npm).SetNumSuites(len(p.Suites)).SetJobs(captor.Default.TestResults). SetSlack(p.Notifications.Slack).SetSharding(playwright.IsSharded(p.Suites)).SetLaunchOrder(p.Sauce.LaunchOrder) tracker.Collect(cases.Title(language.English).String(cmds.FullName(cmd)), props) _ = tracker.Close() @@ -158,38 +157,7 @@ func runPlaywright(cmd *cobra.Command, isCLIDriven bool) (int, error) { cleanupArtifacts(p.Artifacts) - dockerProject, sauceProject := playwright.SplitSuites(p) - if len(dockerProject.Suites) != 0 { - exitCode, err := runPlaywrightInDocker(dockerProject) - if err != nil || exitCode != 0 { - return exitCode, err - } - } - if len(sauceProject.Suites) != 0 { - return runPlaywrightInSauce(sauceProject, regio) - } - - return 0, nil -} - -func runPlaywrightInDocker(p playwright.Project) (int, error) { - log.Info().Msg("Running Playwright in Docker") - printTestEnv("docker") - - cd, err := docker.NewPlaywright(p, &testcompClient, &testcompClient, &restoClient, &restoClient, createReporters(p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient, &restoClient, - "playwright", "docker")) - if err != nil { - return 1, err - } - - p.Npm.Packages = cleanPlaywrightPackages(p.Npm, p.Playwright.Version) - return cd.RunProject() -} - -func runPlaywrightInSauce(p playwright.Project, regio region.Region) (int, error) { log.Info().Msg("Running Playwright in Sauce Labs") - printTestEnv("sauce") - r := saucecloud.PlaywrightRunner{ Project: p, CloudRunner: saucecloud.CloudRunner{ diff --git a/internal/docker/playwright.go b/internal/docker/playwright.go deleted file mode 100644 index 5c8baa54b..000000000 --- a/internal/docker/playwright.go +++ /dev/null @@ -1,88 +0,0 @@ -package docker - -import ( - "context" - - "github.com/saucelabs/saucectl/internal/framework" - "github.com/saucelabs/saucectl/internal/job" - "github.com/saucelabs/saucectl/internal/playwright" - "github.com/saucelabs/saucectl/internal/report" -) - -// PlaywrightRunner represents the docker implementation of a test runner. -type PlaywrightRunner struct { - ContainerRunner - Project playwright.Project -} - -// NewPlaywright creates a new PlaywrightRunner instance. -func NewPlaywright(c playwright.Project, ms framework.MetadataService, wr job.Writer, jr job.Reader, dl job.ArtifactDownloader, reps []report.Reporter) (*PlaywrightRunner, error) { - r := PlaywrightRunner{ - Project: c, - ContainerRunner: ContainerRunner{ - Ctx: context.Background(), - docker: nil, - containerConfig: &containerConfig{}, - Framework: framework.Framework{ - Name: c.Kind, - Version: c.Playwright.Version, - }, - FrameworkMeta: ms, - ShowConsoleLog: c.ShowConsoleLog, - JobWriter: wr, - JobReader: jr, - ArtfactDownloader: dl, - Reporters: reps, - MetadataSearchStrategy: framework.NewSearchStrategy(c.Playwright.Version, c.RootDir), - }, - } - - var err error - r.docker, err = Create() - if err != nil { - return nil, err - } - - return &r, nil -} - -// RunProject runs the tests defined in config.Project. -func (r *PlaywrightRunner) RunProject() (int, error) { - verifyFileTransferCompatibility(r.Project.Sauce.Concurrency, &r.Project.Docker) - - if err := r.fetchImage(&r.Project.Docker); err != nil { - return 1, err - } - - sigChan := r.registerSkipSuitesOnSignal() - defer unregisterSignalCapture(sigChan) - - containerOpts, results := r.createWorkerPool(r.Project.Sauce.Concurrency) - defer close(results) - - go func() { - for _, suite := range r.Project.Suites { - containerOpts <- containerStartOptions{ - Docker: r.Project.Docker, - BeforeExec: r.Project.BeforeExec, - Project: r.Project, - Browser: suite.Params.BrowserName, - DisplayName: suite.Name, - SuiteName: suite.Name, - Environment: suite.Env, - RootDir: r.Project.RootDir, - Sauceignore: r.Project.Sauce.Sauceignore, - ConfigFilePath: r.Project.ConfigFilePath, - CLIFlags: r.Project.CLIFlags, - Timeout: suite.Timeout, - } - } - close(containerOpts) - }() - - hasPassed := r.collectResults(r.Project.Artifacts.Download, results, len(r.Project.Suites)) - if !hasPassed { - return 1, nil - } - return 0, nil -} diff --git a/internal/playwright/config.go b/internal/playwright/config.go index 6e41bbd5b..1f3c51742 100644 --- a/internal/playwright/config.go +++ b/internal/playwright/config.go @@ -42,7 +42,6 @@ type Project struct { Suite Suite `yaml:"suite,omitempty" json:"-"` Suites []Suite `yaml:"suites,omitempty" json:"suites"` BeforeExec []string `yaml:"beforeExec,omitempty" json:"beforeExec"` - Docker config.Docker `yaml:"docker,omitempty" json:"docker"` Npm config.Npm `yaml:"npm,omitempty" json:"npm"` RootDir string `yaml:"rootDir,omitempty" json:"rootDir"` RunnerVersion string `yaml:"runnerVersion,omitempty" json:"runnerVersion"` @@ -128,11 +127,6 @@ func SetDefaults(p *Project) { p.Sauce.Concurrency = 2 } - // Set default docker file transfer to mount - if p.Docker.FileTransfer == "" { - p.Docker.FileTransfer = config.DockerFileMount - } - // Default rootDir to . if p.RootDir == "" { p.RootDir = "." @@ -271,26 +265,6 @@ func shardSuitesByNumShards(suites []Suite) []Suite { return shardedSuites } -// SplitSuites divided Suites to dockerSuites and sauceSuites -func SplitSuites(p Project) (Project, Project) { - var dockerSuites []Suite - var sauceSuites []Suite - for _, s := range p.Suites { - if s.Mode == "docker" || (s.Mode == "" && p.Defaults.Mode == "docker") { - dockerSuites = append(dockerSuites, s) - } else { - sauceSuites = append(sauceSuites, s) - } - } - - dockerProject := p - dockerProject.Suites = dockerSuites - sauceProject := p - sauceProject.Suites = sauceSuites - - return dockerProject, sauceProject -} - // Validate validates basic configuration of the project and returns an error if any of the settings contain illegal // values. This is not an exhaustive operation and further validation should be performed both in the client and/or // server side depending on the workflow that is executed.