Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove Slack notification integration #978

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions internal/cmd/run/cucumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func runCucumber(cmd *cobra.Command, isCLIDriven bool) (int, error) {
usage.Artifacts(p.Artifacts),
usage.NPM(p.Npm),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
usage.Sharding(cucumber.GetShardTypes(p.Suites), cucumber.GetShardOpts(p.Suites)),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.Reporters),
Expand Down Expand Up @@ -142,19 +141,16 @@ func runCucumber(cmd *cobra.Command, isCLIDriven bool) (int, error) {
r := saucecloud.CucumberRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"cucumber", "sauce", gFlags.async,
),
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(p.Reporters, gFlags.async),
Async: gFlags.async,
FailFast: gFlags.failFast,
MetadataSearchStrategy: framework.NewSearchStrategy(p.Playwright.Version, p.RootDir),
Expand Down
25 changes: 10 additions & 15 deletions internal/cmd/run/cypress.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func runCypress(cmd *cobra.Command, cflags cypressFlags, isCLIDriven bool) (int,
usage.Artifacts(p.GetArtifactsCfg()),
usage.NPM(p.GetNpm()),
usage.NumSuites(len(p.GetSuites())),
usage.Slack(p.GetNotifications().Slack),
usage.Sharding(p.GetShardTypes(), p.GetShardOpts()),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.GetReporters()),
Expand Down Expand Up @@ -175,20 +174,16 @@ func runCypress(cmd *cobra.Command, cflags cypressFlags, isCLIDriven bool) (int,
r := saucecloud.CypressRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
ProjectUploader: &appsClient,
JobService: jobService,
MetadataService: &testcompClient,
TunnelService: &restoClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.IsShowConsoleLog(),
Reporters: createReporters(
p.GetReporters(), p.GetNotifications(),
p.GetSauceCfg().Metadata, &testcompClient,
"cypress", "sauce", gFlags.async,
),
ProjectUploader: &appsClient,
JobService: jobService,
MetadataService: &testcompClient,
TunnelService: &restoClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.IsShowConsoleLog(),
Reporters: createReporters(p.GetReporters(), gFlags.async),
Async: gFlags.async,
FailFast: gFlags.failFast,
MetadataSearchStrategy: framework.NewSearchStrategy(p.GetVersion(), p.GetRootDir()),
Expand Down
12 changes: 4 additions & 8 deletions internal/cmd/run/espresso.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func runEspresso(cmd *cobra.Command, espressoFlags espressoFlags, isCLIDriven bo
usage.SauceConfig(p.Sauce),
usage.Artifacts(p.Artifacts),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
usage.Sharding(espresso.GetShardTypes(p.Suites), nil),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.Reporters),
Expand Down Expand Up @@ -168,13 +167,10 @@ func runEspressoInCloud(p espresso.Project, regio region.Region) (int, error) {
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"espresso", "sauce", gFlags.async,
),
Framework: framework.Framework{Name: espresso.Kind},
Async: gFlags.async,
FailFast: gFlags.failFast,
Reporters: createReporters(p.Reporters, gFlags.async),
Framework: framework.Framework{Name: espresso.Kind},
Async: gFlags.async,
FailFast: gFlags.failFast,
Retrier: &retry.JunitRetrier{
JobService: jobService,
},
Expand Down
24 changes: 10 additions & 14 deletions internal/cmd/run/playwright.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func runPlaywright(cmd *cobra.Command, pf playwrightFlags, isCLIDriven bool) (in
usage.Artifacts(p.Artifacts),
usage.NPM(p.Npm),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
usage.Sharding(playwright.GetShardTypes(p.Suites), playwright.GetShardOpts(p.Suites)),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.Reporters),
Expand Down Expand Up @@ -187,19 +186,16 @@ func runPlaywright(cmd *cobra.Command, pf playwrightFlags, isCLIDriven bool) (in
r := saucecloud.PlaywrightRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"playwright", "sauce", gFlags.async,
),
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(p.Reporters, gFlags.async),
Async: gFlags.async,
FailFast: gFlags.failFast,
MetadataSearchStrategy: framework.NewSearchStrategy(p.Playwright.Version, p.RootDir),
Expand Down
20 changes: 8 additions & 12 deletions internal/cmd/run/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func runReplay(cmd *cobra.Command, isCLIDriven bool) (int, error) {
usage.SauceConfig(p.Sauce),
usage.Artifacts(p.Artifacts),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
)
_ = tracker.Close()
}()
Expand Down Expand Up @@ -146,17 +145,14 @@ func runPuppeteerReplayInSauce(p replay.Project, regio region.Region) (int, erro
TestComposer: testcompClient,
ArtifactDownloadConfig: p.Artifacts.Download,
},
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"puppeteer-replay", "sauce", gFlags.async,
),
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(p.Reporters, gFlags.async),
Async: gFlags.async,
FailFast: gFlags.failFast,
MetadataSearchStrategy: framework.ExactStrategy{},
Expand Down
14 changes: 1 addition & 13 deletions internal/cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/imagerunner"
"github.com/saucelabs/saucectl/internal/msg"
"github.com/saucelabs/saucectl/internal/notification/slack"
"github.com/saucelabs/saucectl/internal/playwright"
"github.com/saucelabs/saucectl/internal/puppeteer/replay"
"github.com/saucelabs/saucectl/internal/report"
Expand Down Expand Up @@ -266,8 +265,7 @@ func checkForUpdates() {
}
}

func createReporters(c config.Reporters, ntfs config.Notifications, metadata config.Metadata,
svc slack.Service, framework, env string, async bool) []report.Reporter {
func createReporters(c config.Reporters, async bool) []report.Reporter {
githubReporter := github.NewJobSummaryReporter()

reps := []report.Reporter{
Expand Down Expand Up @@ -300,16 +298,6 @@ func createReporters(c config.Reporters, ntfs config.Notifications, metadata con
buildReporter := buildtable.New()
reps = append(reps, &buildReporter)

reps = append(reps, &slack.Reporter{
Channels: ntfs.Slack.Channels,
Framework: framework,
Metadata: metadata,
TestEnv: env,
TestResults: []report.TestResult{},
Config: ntfs,
Service: svc,
})

return reps
}

Expand Down
24 changes: 10 additions & 14 deletions internal/cmd/run/testcafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func runTestcafe(cmd *cobra.Command, tcFlags testcafeFlags, isCLIDriven bool) (i
usage.Artifacts(p.Artifacts),
usage.NPM(p.Npm),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
usage.Sharding(testcafe.GetShardTypes(p.Suites), nil),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.Reporters),
Expand Down Expand Up @@ -210,19 +209,16 @@ func runTestcafe(cmd *cobra.Command, tcFlags testcafeFlags, isCLIDriven bool) (i
r := saucecloud.TestcafeRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"testcafe", "sauce", gFlags.async,
),
ProjectUploader: &appsClient,
JobService: jobService,
TunnelService: &restoClient,
MetadataService: &testcompClient,
InsightsService: &insightsClient,
UserService: &iamClient,
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(p.Reporters, gFlags.async),
Async: gFlags.async,
FailFast: gFlags.failFast,
MetadataSearchStrategy: framework.NewSearchStrategy(p.Testcafe.Version, p.RootDir),
Expand Down
12 changes: 4 additions & 8 deletions internal/cmd/run/xcuitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func runXcuitest(cmd *cobra.Command, xcuiFlags xcuitestFlags, isCLIDriven bool)
usage.SauceConfig(p.Sauce),
usage.Artifacts(p.Artifacts),
usage.NumSuites(len(p.Suites)),
usage.Slack(p.Notifications.Slack),
usage.Sharding(xcuitest.GetShardTypes(p.Suites), nil),
usage.SmartRetry(p.IsSmartRetried()),
usage.Reporters(p.Reporters),
Expand Down Expand Up @@ -169,13 +168,10 @@ func runXcuitestInCloud(p xcuitest.Project, regio region.Region) (int, error) {
BuildService: &buildService,
Region: regio,
ShowConsoleLog: p.ShowConsoleLog,
Reporters: createReporters(
p.Reporters, p.Notifications, p.Sauce.Metadata, &testcompClient,
"xcuitest", "sauce", gFlags.async,
),
Framework: framework.Framework{Name: xcuitest.Kind},
Async: gFlags.async,
FailFast: gFlags.failFast,
Reporters: createReporters(p.Reporters, gFlags.async),
Framework: framework.Framework{Name: xcuitest.Kind},
Async: gFlags.async,
FailFast: gFlags.failFast,
Retrier: &retry.JunitRetrier{
JobService: jobService,
},
Expand Down
11 changes: 0 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,6 @@ type ArtifactDownload struct {
AllAttempts bool `yaml:"allAttempts,omitempty" json:"allAttempts"`
}

// Notifications represents the test notifications configuration.
type Notifications struct {
Slack Slack `yaml:"slack,omitempty" json:"slack"`
}

// Slack represents slack configuration.
type Slack struct {
Channels []string `yaml:"channels,omitempty" json:"channels"`
Send When `yaml:"send,omitempty" json:"send"`
}

// Artifacts represents the test artifacts configuration.
type Artifacts struct {
Retain map[string]string `yaml:"retain,omitempty" json:"retain"`
Expand Down
51 changes: 18 additions & 33 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,24 @@ func TestCleanNpmPackages(t *testing.T) {

func TestConfig_ExpandEnv(t *testing.T) {
envMap := map[string]string{
"REGION": "us-west-1",
"TAG1": "my_tag1",
"TAG2": "my_tag2",
"BUILD": "my_build",
"TUNNEL_ID": "my_tunnel_id",
"APP": "espresso_app",
"OTHER_APP1": "espresso_other_app1",
"NOT_CLASS1": "not_class1",
"NOT_CLASS2": "not_class2",
"CLASS1": "test_class1",
"CLASS2": "test_class2",
"PACKAGE": "my_package",
"SUITE_NAME": "my_suite_name",
"TIMEOUT": "10s",
"DEVICE_ID": "my_device_id",
"ARTIFACT_MATCH1": "artifact_match1",
"ARTIFACT_MATCH2": "artifact_match2",
"ARTIFACT_WHEN": "always",
"NOTIFICATION_SLACK_CHANNEL1": "channel1",
"NOTIFICATION_SLACK_CHANNEL2": "channel2",
"NOTIFICATION_SLACK_SEND": "always",
"REGION": "us-west-1",
"TAG1": "my_tag1",
"TAG2": "my_tag2",
"BUILD": "my_build",
"TUNNEL_ID": "my_tunnel_id",
"APP": "espresso_app",
"OTHER_APP1": "espresso_other_app1",
"NOT_CLASS1": "not_class1",
"NOT_CLASS2": "not_class2",
"CLASS1": "test_class1",
"CLASS2": "test_class2",
"PACKAGE": "my_package",
"SUITE_NAME": "my_suite_name",
"TIMEOUT": "10s",
"DEVICE_ID": "my_device_id",
"ARTIFACT_MATCH1": "artifact_match1",
"ARTIFACT_MATCH2": "artifact_match2",
"ARTIFACT_WHEN": "always",
}

for key, val := range envMap {
Expand Down Expand Up @@ -99,12 +96,6 @@ func TestConfig_ExpandEnv(t *testing.T) {
"when": "$ARTIFACT_WHEN",
},
},
"notifications": map[string]interface{}{
"slack": map[string]interface{}{
"channels": []interface{}{"$NOTIFICATION_SLACK_CHANNEL1", "$NOTIFICATION_SLACK_CHANNEL2"},
"send": "$NOTIFICATION_SLACK_SEND",
},
},
}

expectObj := map[string]interface{}{
Expand Down Expand Up @@ -141,12 +132,6 @@ func TestConfig_ExpandEnv(t *testing.T) {
"when": "always",
},
},
"notifications": map[string]interface{}{
"slack": map[string]interface{}{
"channels": []interface{}{"channel1", "channel2"},
"send": "always",
},
},
}

testCases := []struct {
Expand Down
27 changes: 13 additions & 14 deletions internal/cucumber/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ type Project struct {
CLIFlags map[string]interface{} `yaml:"-" json:"-"`
Sauce config.SauceConfig `yaml:"sauce,omitempty" json:"sauce"`
// Suite is only used as a workaround to parse adhoc suites that are created via CLI args.
Suite Suite `yaml:"suite,omitempty" json:"-"`
Suites []Suite `yaml:"suites,omitempty" json:"suites"`
BeforeExec []string `yaml:"beforeExec,omitempty" json:"beforeExec"`
Playwright Playwright `yaml:"playwright,omitempty" json:"playwright"`
Npm config.Npm `yaml:"npm,omitempty" json:"npm"`
RootDir string `yaml:"rootDir,omitempty" json:"rootDir"`
RunnerVersion string `yaml:"runnerVersion,omitempty" json:"runnerVersion"`
Artifacts config.Artifacts `yaml:"artifacts,omitempty" json:"artifacts"`
Reporters config.Reporters `yaml:"reporters,omitempty" json:"-"`
Defaults config.Defaults `yaml:"defaults,omitempty" json:"defaults"`
Env map[string]string `yaml:"env,omitempty" json:"env"`
EnvFlag map[string]string `yaml:"-" json:"-"`
Notifications config.Notifications `yaml:"notifications,omitempty" json:"-"`
NodeVersion string `yaml:"nodeVersion,omitempty" json:"nodeVersion,omitempty"`
Suite Suite `yaml:"suite,omitempty" json:"-"`
Suites []Suite `yaml:"suites,omitempty" json:"suites"`
BeforeExec []string `yaml:"beforeExec,omitempty" json:"beforeExec"`
Playwright Playwright `yaml:"playwright,omitempty" json:"playwright"`
Npm config.Npm `yaml:"npm,omitempty" json:"npm"`
RootDir string `yaml:"rootDir,omitempty" json:"rootDir"`
RunnerVersion string `yaml:"runnerVersion,omitempty" json:"runnerVersion"`
Artifacts config.Artifacts `yaml:"artifacts,omitempty" json:"artifacts"`
Reporters config.Reporters `yaml:"reporters,omitempty" json:"-"`
Defaults config.Defaults `yaml:"defaults,omitempty" json:"defaults"`
Env map[string]string `yaml:"env,omitempty" json:"env"`
EnvFlag map[string]string `yaml:"-" json:"-"`
NodeVersion string `yaml:"nodeVersion,omitempty" json:"nodeVersion,omitempty"`
}

// Playwright represents the playwright setting
Expand Down
Loading
Loading