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

Add extra options for Jenkins to improve test reliability. #48

Merged
merged 6 commits into from
Nov 17, 2022
Merged
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
42 changes: 26 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
def runPlaywrightTests(resultDir) {
sh 'mkdir -p ./test-results'
sh """
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project webkit --project iphoneSE --reporter=junit || true
"""
junit 'results.xml'
sh """
mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
mkdir -p ./test-results
mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
"""
def runPlaywrightTests(resultDir, browser, grep) {
try {
timeout(20) {
sh 'mkdir -p ./test-results'
sh """
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project $browser --reporter=junit --workers 10 --grep "$grep"|| true
"""
}
} finally {
junit 'results.xml'
sh """
mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
mkdir -p ./test-results
mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
"""
}
}

def withEnvFile(envfile, Closure cb) {
Expand All @@ -19,9 +24,11 @@ def withEnvFile(envfile, Closure cb) {
}

pipeline {
agent { label 'crawler-autoconsent' }
agent { label 'autoconsent-crawler' }
parameters {
string(name: 'TEST_RESULT_ROOT', defaultValue: '/mnt/efs/users/smacbeth/autoconsent/ci', description: 'Where test results and configuration are stored')
choice(name: 'BROWSER', choices: ['webkit', 'iphoneSE', 'chrome', 'firefox'], description: 'Browser')
string(name: 'GREP', defaultValue: '', description: 'filter for tests matching a specific string')
}
environment {
NODENV_VERSION = "14.15.4"
Expand All @@ -41,37 +48,40 @@ pipeline {
npm ci
npx playwright install webkit
'''
script {
currentBuild.description = "${params.BROWSER} - ${params.GREP}"
}
}
}

stage('Test: DE') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/de.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: US') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/us.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: GB') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/gb.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: FR') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/fr.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}
Expand Down