Skip to content

Commit

Permalink
Playwright: replace build configuration objects with a function. (#55963
Browse files Browse the repository at this point in the history
)

* Replace build configuration objects with a function.

* Add UUID to the param.

* Rename param to buildUuid

* Hopefully fix indent
  • Loading branch information
worldomonation authored Sep 2, 2021
1 parent 167e554 commit 0f1f4cd
Showing 1 changed file with 174 additions and 24 deletions.
198 changes: 174 additions & 24 deletions .teamcity/_self/projects/WPComTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object WPComTests : Project({
// Keep the previous ID in order to preserve the historical data
buildType(gutenbergBuildType("desktop", "aee94c18-ee11-4c80-b6aa-245b967a97db"));
buildType(gutenbergBuildType("mobile","2af2eaed-87d5-41f4-ab1d-4ed589d5ae82"));
buildType(GutenbergPlaywrightE2EDesktop);
buildType(GutenbergPlaywrightE2EMobile);
buildType(gutenbergPlaywrightBuildType("desktop", "fab2e82e-d27b-4ba2-bbd7-232df944e75c"));
buildType(gutenbergPlaywrightBuildType("mobile", "77a5a0f1-9644-4c04-9d27-0066cd2d4ada"));
buildType(jetpackBuildType("desktop"));
buildType(jetpackBuildType("mobile"));
buildType(VisualRegressionTests);
Expand Down Expand Up @@ -207,6 +207,178 @@ fun gutenbergBuildType(screenSize: String, buildUuid: String): BuildType {
}
}

fun gutenbergPlaywrightBuildType( viewportName: String, buildUuid: String ): BuildType {
return BuildType {
id("WPComTests_gutenberg_Playwright_$viewportName")
uuid=buildUuid
name = "Playwright E2E Tests ($viewportName)"
description = "Runs Gutenberg E2E tests in $viewportName size using Playwright"


artifactRules = """
reports => reports
logs.tgz => logs.tgz
screenshots => screenshots
""".trimIndent()

vcs {
root(Settings.WpCalypso)
cleanCheckout = true
}

params {
text(
name = "URL",
value = "https://wordpress.com",
label = "Test URL",
description = "URL to test against",
allowEmpty = false
)
checkbox(
name = "GUTENBERG_EDGE",
value = "false",
label = "Use gutenberg-edge",
description = "Use a blog with gutenberg-edge sticker",
checked = "true",
unchecked = "false"
)
checkbox(
name = "COBLOCKS_EDGE",
value = "false",
label = "Use coblocks-edge",
description = "Use a blog with coblocks-edge sticker",
checked = "true",
unchecked = "false"
)
}

steps {
bashNodeScript {
name = "Prepare environment"
scriptContent = """
export NODE_ENV="test"
export PLAYWRIGHT_BROWSERS_PATH=0
# Install modules
${_self.yarn_install_cmd}
# Build packages
yarn workspace @automattic/calypso-e2e build
"""
}
bashNodeScript {
name = "Run e2e tests ($viewportName)"
scriptContent = """
shopt -s globstar
set -x
chmod +x ./bin/get-calypso-live-url.sh
URL=${'$'}(./bin/get-calypso-live-url.sh ${BuildDockerImage.depParamRefs.buildNumber})
if [[ ${'$'}? -ne 0 ]]; then
// Command failed. URL contains stderr
echo ${'$'}URL
exit 1
fi
cd test/e2e
mkdir temp
export LIVEBRANCHES=true
export NODE_CONFIG_ENV=test
export PLAYWRIGHT_BROWSERS_PATH=0
export TEAMCITY_VERSION=2021
# Decrypt config
openssl aes-256-cbc -md sha1 -d -in ./config/encrypted.enc -out ./config/local-test.json -k "%CONFIG_E2E_ENCRYPTION_KEY%"
# Run the test
export VIEWPORT_NAME=$viewportName
export LOCALE=en
export NODE_CONFIG="{\"calypsoBaseURL\":\"${'$'}{URL%/}\"}"
export DEBUG=pw:api
xvfb-run yarn jest --reporters=jest-teamcity --reporters=default --testNamePattern @parallel --maxWorkers=%E2E_WORKERS% specs/specs-playwright-wpcom
""".trimIndent()
dockerRunParameters = "-u %env.UID% --security-opt seccomp=.teamcity/docker-seccomp.json --shm-size=8gb"
}
bashNodeScript {
name = "Collect results"
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
scriptContent = """
set -x
mkdir -p screenshots
find test/e2e -type f -path '*/screenshots/*' -print0 | xargs -r -0 mv -t screenshots
mkdir -p logs
find test/e2e -name '*.log' -print0 | xargs -r -0 tar cvfz logs.tgz
""".trimIndent()
}
}

features {
perfmon {
}
notifications {
notifierSettings = slackNotifier {
connection = "PROJECT_EXT_11"
sendTo = "#gutenberg-e2e"
messageFormat = verboseMessageFormat {
addBranch = true
addStatusText = true
maximumNumberOfChanges = 10
}
}
branchFilter = "+:<default>"
buildFailed = true
buildFinishedSuccessfully = true
}
commitStatusPublisher {
vcsRootExtId = "${Settings.WpCalypso.id}"
publisher = github {
githubUrl = "https://api.github.com"
authType = personalToken {
token = "credentialsJSON:57e22787-e451-48ed-9fea-b9bf30775b36"
}
}
}
}

failureConditions {
executionTimeoutMin = 20
// Don't fail if the runner exists with a non zero code. This allows a build to pass if the failed tests have
// been muted previously.
nonZeroExitCode = false

// Fail if the number of passing tests is 50% or less than the last build. This will catch the case where the test runner
// crashes and no tests are run.
failOnMetricChange {
metric = BuildFailureOnMetric.MetricType.PASSED_TEST_COUNT
threshold = 50
units = BuildFailureOnMetric.MetricUnit.PERCENTS
comparison = BuildFailureOnMetric.MetricComparison.LESS
compareTo = build {
buildRule = lastSuccessful()
}
}
}

triggers {
schedule {
schedulingPolicy = daily {
hour = 4
}
branchFilter = """
+:trunk
""".trimIndent()
triggerBuild = always()
withPendingChangesOnly = false
}
}
}
}


fun jetpackBuildType(screenSize: String): BuildType {
return BuildType {
id("WPComTests_jetpack_$screenSize")
Expand Down Expand Up @@ -332,28 +504,6 @@ fun jetpackBuildType(screenSize: String): BuildType {
}
}

private object GutenbergPlaywrightE2EDesktop: BuildType ({
name = "Playwright WPCOM E2E Tests (desktop)"
description = "Runs Gutenberg E2E tests in desktop size using Playwright"

steps {
bashNodeScript {
scriptContent = "echo 'Hello world!'"
}
}
})

private object GutenbergPlaywrightE2EMobile: BuildType ({
name = "Playwright WPCOM E2E Tests (mobile)"
description = "Runs Gutenberg E2E tests in mobile size using Playwright"

steps {
bashNodeScript {
scriptContent = "echo 'Hello world!'"
}
}
})

private object VisualRegressionTests : BuildType({
name = "Visual Regression Tests"
description = "Runs visual regression tests"
Expand Down

0 comments on commit 0f1f4cd

Please sign in to comment.