status-react/ci/tests/Jenkinsfile.e2e-prs

156 lines
4.2 KiB
Plaintext
Raw Permalink Normal View History

2023-06-29 13:40:43 +00:00
#!/usr/bin/env groovy
library 'status-jenkins-lib@v1.9.4'
pipeline {
agent { label 'linux' }
parameters {
string(
name: 'BRANCH_NAME',
description: 'Name of the branch to checkout and build.',
defaultValue: 'develop',
)
string(
name: 'PR_ID',
description: 'ID of the Pull Request triggering this build.',
)
string(
name: 'APK_URL',
description: 'Optional, set if job require APK to be downloaded from URL.',
)
2021-12-29 16:10:22 +00:00
string(
name: 'KEYWORD_EXPRESSION',
description: 'This will run tests which contain names that match the given string expression (Optional)',
defaultValue: '',
)
string(
name: 'TR_CASE_IDS',
2021-12-29 16:10:22 +00:00
description: 'IDs of the TestRail case, separated by a comma (Optional)',
defaultValue: '',
)
/* FIXME: Remove this no longer relevant argument */
string(
name: 'APK_NAME',
description: 'OBSOLETE ARGUMENT TO BE REMOVED',
defaultValue: 'DUMMY',
)
string(
name: 'TEST_MARKERS',
description: 'Marker expression for matching tests to run.',
2024-07-12 16:29:44 +00:00
defaultValue: 'smoke',
)
}
options {
disableConcurrentBuilds()
timeout(time: 90, unit: 'MINUTES')
buildDiscarder(logRotator(
numToKeepStr: '10',
daysToKeepStr: '30',
artifactNumToKeepStr: '1',
))
}
environment {
/* Avoid race conditions with other builds using virtualenv. */
VIRTUAL_ENV = "${WORKSPACE_TMP}/venv"
PATH = "${VIRTUAL_ENV}/bin:${PATH}"
}
stages {
stage('Prep') {
steps { script {
currentBuild.displayName = "PR-${params.PR_ID}"
if (params.PR_ID == null) {
error("PR_ID parameter not set!")
}
} }
}
stage('Fetch') {
when { expression { !params.APK_URL } }
steps { script {
copyArtifacts(
projectName: "status-mobile/prs/android-e2e/PR-${params.PR_ID}",
/* WARNING: This copies the latest available artifact. */
selector: lastWithArtifacts(),
)
apk_path = "${env.WORKSPACE}/${utils.findFile('result/*.apk')}"
} }
}
stage('Setup') {
steps { script {
dir('test/appium') {
sh "python3 -m venv ${VIRTUAL_ENV}"
sh 'pip3 install -r requirements.txt'
}
} }
}
stage('Test') {
steps { script {
/* for managing optional arguments */
def extraPytestOpts = ''
if (params.TR_CASE_IDS != '') {
extraPytestOpts = "--run_testrail_ids='${params.TR_CASE_IDS}'"
2022-05-17 02:52:15 +00:00
} else {
extraPytestOpts = "-m \"${params.TEST_MARKERS}\""
}
withCredentials([
usernamePassword(
credentialsId: 'status-im-auto',
usernameVariable: 'GIT_HUB_USER', /* ignored */
passwordVariable: 'GIT_HUB_TOKEN'
),
usernamePassword(
credentialsId: 'test-rail-api',
usernameVariable: 'TESTRAIL_USER',
passwordVariable: 'TESTRAIL_PASS'
),
usernamePassword(
credentialsId: 'sauce-labs-api',
usernameVariable: 'SAUCE_USERNAME',
passwordVariable: 'SAUCE_ACCESS_KEY'
),
string(
credentialsId: 'etherscan-api-key',
variable: 'ETHERSCAN_API_KEY'
),
string(
credentialsId: 'infura-e2e-token',
variable: 'WEB3_INFURA_PROJECT_ID'
),
2022-03-07 21:17:39 +00:00
file(
credentialsId: "mobile-tests-eth-accounts",
variable: 'TEST_ETH_ACCOUNTS_FILE'
),
]) {
dir('test/appium/tests') {
2022-03-07 21:17:39 +00:00
/* Provide Eth test account secrets. */
sh 'cp -f $TEST_ETH_ACCOUNTS_FILE users.py'
sh """
python3 -m pytest \
2023-09-06 00:36:33 +00:00
--numprocesses 8 \
--rerun_count=2 \
--testrail_report=True \
2021-12-29 16:10:22 +00:00
-k \"${params.KEYWORD_EXPRESSION}\" \
--apk=${params.APK_URL ?: apk_path} \
--build=PR-${params.PR_ID}-${utils.timestamp()} \
--pr_number=${params.PR_ID} \
${extraPytestOpts}
"""
}
}
} }
}
}
post {
cleanup {
sh 'make purge'
}
}
}