2023-09-28 12:44:13 +00:00
|
|
|
#!/usr/bin/env groovy
|
2024-02-13 11:17:42 +00:00
|
|
|
library 'status-jenkins-lib@v1.8.6'
|
2023-09-28 12:44:13 +00:00
|
|
|
|
|
|
|
pipeline {
|
|
|
|
|
2023-10-19 16:49:52 +00:00
|
|
|
agent {
|
2023-12-06 14:03:15 +00:00
|
|
|
label "${params.AGENT} && x86_64 && qt-5.15.2"
|
2023-09-28 12:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
parameters {
|
2023-10-09 09:38:48 +00:00
|
|
|
gitParameter(
|
2023-10-19 18:12:14 +00:00
|
|
|
name: 'GIT_REF',
|
|
|
|
description: 'Git branch to checkout.',
|
2023-10-09 09:38:48 +00:00
|
|
|
branchFilter: 'origin/(.*)',
|
2023-10-19 18:12:14 +00:00
|
|
|
branch: '',
|
2023-10-09 09:38:48 +00:00
|
|
|
defaultValue: 'master',
|
|
|
|
quickFilterEnabled: false,
|
|
|
|
selectedValue: 'DEFAULT',
|
|
|
|
sortMode: 'ASCENDING_SMART',
|
|
|
|
tagFilter: '*',
|
|
|
|
type: 'PT_BRANCH'
|
|
|
|
)
|
2023-09-28 12:44:13 +00:00
|
|
|
string(
|
2023-10-19 18:12:14 +00:00
|
|
|
name: 'BUILD_SOURCE',
|
|
|
|
description: 'URL to tar.gz file OR path to Jenkins build.',
|
2023-11-06 15:45:43 +00:00
|
|
|
defaultValue: getDefaultBuildSource()
|
2023-09-28 12:44:13 +00:00
|
|
|
)
|
|
|
|
string(
|
|
|
|
name: 'TEST_NAME',
|
2023-10-09 09:38:48 +00:00
|
|
|
description: 'Paste test name/part of test name to run specific test.',
|
2023-09-28 12:44:13 +00:00
|
|
|
defaultValue: ''
|
|
|
|
)
|
|
|
|
string(
|
2023-12-22 16:17:34 +00:00
|
|
|
name: 'TEST_SCOPE_FLAG',
|
2023-12-18 12:07:51 +00:00
|
|
|
description: 'Paste a known mark to run tests labeled with this mark',
|
2023-12-22 16:17:34 +00:00
|
|
|
defaultValue: getDefaultTestScopeFlag()
|
2023-09-28 12:44:13 +00:00
|
|
|
)
|
|
|
|
string(
|
2023-11-02 16:08:22 +00:00
|
|
|
name: 'TESTRAIL_RUN_NAME',
|
2023-11-15 08:42:02 +00:00
|
|
|
description: 'Test run name in Test Rail.',
|
2023-09-28 12:44:13 +00:00
|
|
|
defaultValue: ''
|
|
|
|
)
|
2023-12-01 13:57:36 +00:00
|
|
|
choice(
|
|
|
|
name: 'LOG_LEVEL',
|
|
|
|
description: 'Log level for pytest.',
|
|
|
|
choices: ['INFO', 'DEBUG', 'TRACE', 'WARNING', 'CRITICAL']
|
|
|
|
)
|
2023-10-19 16:49:52 +00:00
|
|
|
/* FIXME: This is temporary and should be removed. */
|
|
|
|
choice(
|
|
|
|
name: 'AGENT',
|
|
|
|
description: 'Agent name to run tests on it.',
|
|
|
|
choices: ['linux', 'linux-01', 'linux-02', 'linux-03', 'linux-04', 'linux-05']
|
|
|
|
)
|
2023-10-13 11:22:50 +00:00
|
|
|
}
|
|
|
|
|
2023-09-28 12:44:13 +00:00
|
|
|
options {
|
|
|
|
timestamps()
|
|
|
|
/* Prevent Jenkins jobs from running forever */
|
|
|
|
timeout(time: 120, unit: 'MINUTES')
|
|
|
|
/* manage how many builds we keep */
|
|
|
|
buildDiscarder(logRotator(
|
2023-10-24 16:09:32 +00:00
|
|
|
daysToKeepStr: '60',
|
|
|
|
numToKeepStr: '50',
|
|
|
|
artifactNumToKeepStr: '50',
|
2023-09-28 12:44:13 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2023-10-19 16:49:52 +00:00
|
|
|
environment {
|
2023-12-01 19:04:11 +00:00
|
|
|
SQUISH_DIR = '/opt/squish-runner-7.2.1'
|
2023-10-19 16:49:52 +00:00
|
|
|
PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}"
|
|
|
|
LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}"
|
2024-08-15 14:43:48 +00:00
|
|
|
|
|
|
|
/* To stop e2e tests using port 8545 */
|
|
|
|
STATUS_RUNTIME_HTTP_API = 'False'
|
|
|
|
STATUS_RUNTIME_WS_API = 'False'
|
2023-10-19 16:49:52 +00:00
|
|
|
|
2024-04-15 12:02:00 +00:00
|
|
|
/* Avoid race conditions with other builds using virtualenv. */
|
|
|
|
VIRTUAL_ENV = "${WORKSPACE_TMP}/venv"
|
|
|
|
PATH = "${VIRTUAL_ENV}/bin:${PATH}"
|
|
|
|
|
2023-10-19 16:49:52 +00:00
|
|
|
TESTRAIL_URL = 'https://ethstatus.testrail.net'
|
2024-07-16 12:54:15 +00:00
|
|
|
TESTRAIL_PROJECT_ID = 18
|
2024-06-20 11:35:04 +00:00
|
|
|
/* Override QT xcb plugin with linux to avoid errors like:
|
|
|
|
* "Could not load the Qt platform plugin "xcb" in "" even though it was found." */
|
|
|
|
QT_QPA_PLATFORM = "linuxfb"
|
2023-11-16 09:05:39 +00:00
|
|
|
|
2023-11-22 10:42:26 +00:00
|
|
|
/* Runtime flag to make testing of the app easier. Switched off: unpredictable app behavior under new tests */
|
2024-02-20 09:35:22 +00:00
|
|
|
/* STATUS_RUNTIME_TEST_MODE = 'True' */
|
2024-06-26 07:21:20 +00:00
|
|
|
|
|
|
|
/* Logging rules let you enable or disable logging for categories */
|
|
|
|
QT_LOGGING_RULES = '*.warning=true'
|
|
|
|
|
|
|
|
/* Set to a non-zero value to make Qt print out diagnostic information about the each (C++) plugin it tries to load. */
|
|
|
|
QT_DEBUG_PLUGINS = 0
|
2023-10-19 16:49:52 +00:00
|
|
|
}
|
|
|
|
|
2023-09-28 12:44:13 +00:00
|
|
|
stages {
|
2023-10-24 12:45:32 +00:00
|
|
|
stage('Prep') {
|
2023-10-19 18:12:14 +00:00
|
|
|
steps { script {
|
2023-10-26 11:18:33 +00:00
|
|
|
setNewBuildName()
|
2023-10-24 12:45:32 +00:00
|
|
|
updateGitHubStatus()
|
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Deps') {
|
2024-06-03 07:58:13 +00:00
|
|
|
steps { script { dir('test/e2e') {
|
2024-04-15 12:02:00 +00:00
|
|
|
sh "python3 -m venv ${VIRTUAL_ENV}"
|
|
|
|
sh 'pip3 install -r requirements.txt'
|
2024-06-03 07:58:13 +00:00
|
|
|
} } }
|
2023-10-19 18:12:14 +00:00
|
|
|
}
|
|
|
|
|
2023-10-13 14:37:06 +00:00
|
|
|
stage('Download') {
|
2023-10-19 18:12:14 +00:00
|
|
|
when { expression { params.BUILD_SOURCE.startsWith('http') } }
|
2024-06-03 07:58:13 +00:00
|
|
|
steps { timeout(5) { script { dir('test/e2e') {
|
2023-11-30 11:05:59 +00:00
|
|
|
sh 'mkdir -p ./pkg/'
|
2023-11-08 10:55:08 +00:00
|
|
|
setBuildDescFromFile(params.BUILD_SOURCE)
|
2023-10-19 18:12:14 +00:00
|
|
|
fileOperations([
|
|
|
|
fileDownloadOperation(
|
|
|
|
url: params.BUILD_SOURCE,
|
|
|
|
targetFileName: 'StatusIm-Desktop.tar.gz',
|
2023-11-30 11:05:59 +00:00
|
|
|
targetLocation: './pkg/',
|
2023-10-19 18:12:14 +00:00
|
|
|
userName: '',
|
|
|
|
password: '',
|
|
|
|
)
|
|
|
|
])
|
2024-06-03 07:58:13 +00:00
|
|
|
} } } }
|
2023-09-28 12:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 18:12:14 +00:00
|
|
|
stage('Copy') {
|
|
|
|
when { expression { ! params.BUILD_SOURCE.startsWith('http') } }
|
2024-06-03 07:58:13 +00:00
|
|
|
steps { timeout(5) { script { dir('test/e2e') {
|
2023-10-19 18:12:14 +00:00
|
|
|
copyArtifacts(
|
|
|
|
projectName: params.BUILD_SOURCE,
|
|
|
|
filter: 'pkg/*-x86_64.tar.gz',
|
|
|
|
selector: lastWithArtifacts(),
|
2023-11-30 11:05:59 +00:00
|
|
|
target: './'
|
2023-10-19 18:12:14 +00:00
|
|
|
)
|
2023-11-30 11:05:59 +00:00
|
|
|
setBuildDescFromFile(utils.findFile('pkg/*tar.gz'))
|
2024-06-03 07:58:13 +00:00
|
|
|
} } } }
|
2023-10-19 18:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Unpack') {
|
2024-06-03 07:58:13 +00:00
|
|
|
steps { timeout(5) { script { dir('test/e2e') {
|
2023-11-30 11:05:59 +00:00
|
|
|
sh 'mkdir aut'
|
|
|
|
sh "tar -zxvf '${utils.findFile('pkg/*tar.gz')}' -C './aut'"
|
|
|
|
env.AUT_PATH = utils.findFile('aut/*.AppImage')
|
2024-06-03 07:58:13 +00:00
|
|
|
} } } }
|
2023-09-28 12:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Test') {
|
2024-06-07 12:13:58 +00:00
|
|
|
steps { timeout(getTestStageTimeout()) { script { dir('test/e2e') {
|
2023-10-19 16:49:52 +00:00
|
|
|
def flags = []
|
2023-12-01 13:57:36 +00:00
|
|
|
if (params.TEST_NAME) { flags.add("-k=${params.TEST_NAME}") }
|
2023-12-22 16:17:34 +00:00
|
|
|
if (params.TEST_SCOPE_FLAG) { flags.add(params.TEST_SCOPE_FLAG) }
|
2023-12-01 13:57:36 +00:00
|
|
|
if (params.LOG_LEVEL) { flags.addAll(["--log-level=${params.LOG_LEVEL}", "--log-cli-level=${params.LOG_LEVEL}"]) }
|
2023-10-19 16:49:52 +00:00
|
|
|
dir ('configs') { sh 'ln -s _local.ci.py _local.py' }
|
2023-10-13 14:37:06 +00:00
|
|
|
wrap([
|
|
|
|
$class: 'Xvfb',
|
|
|
|
autoDisplayName: true,
|
|
|
|
parallelBuild: true,
|
2024-08-06 14:43:37 +00:00
|
|
|
screen: '2560x1440x24',
|
2023-10-13 14:37:06 +00:00
|
|
|
additionalOptions: '-dpi 1'
|
2023-10-19 18:12:14 +00:00
|
|
|
]) {
|
2023-10-19 16:49:52 +00:00
|
|
|
sh 'fluxbox &'
|
|
|
|
withCredentials([
|
|
|
|
usernamePassword(
|
|
|
|
credentialsId: 'test-rail-api-devops',
|
|
|
|
usernameVariable: 'TESTRAIL_USR',
|
|
|
|
passwordVariable: 'TESTRAIL_PSW'
|
|
|
|
)
|
|
|
|
]) {
|
2024-02-29 16:24:57 +00:00
|
|
|
/* Keep the --reruns flag first, or it won't work */
|
2023-10-19 16:49:52 +00:00
|
|
|
sh """
|
2024-06-21 06:18:16 +00:00
|
|
|
python3 -m pytest --reruns=1 --timeout=180 ${flags.join(" ")} \
|
2023-10-19 16:49:52 +00:00
|
|
|
--disable-warnings \
|
2024-06-21 06:18:16 +00:00
|
|
|
--alluredir=./allure-results \
|
|
|
|
-o timeout_func_only=true
|
2023-10-19 16:49:52 +00:00
|
|
|
"""
|
2023-10-13 11:22:50 +00:00
|
|
|
}
|
2023-09-28 12:44:13 +00:00
|
|
|
}
|
2024-06-03 07:58:13 +00:00
|
|
|
} } } }
|
2023-09-28 12:44:13 +00:00
|
|
|
}
|
|
|
|
}
|
2024-02-09 06:29:26 +00:00
|
|
|
|
2023-09-28 12:44:13 +00:00
|
|
|
post {
|
2024-06-03 07:58:13 +00:00
|
|
|
always { script { dir('test/e2e') {
|
2023-11-30 11:06:18 +00:00
|
|
|
archiveArtifacts('aut/*.log')
|
2024-02-09 06:29:26 +00:00
|
|
|
|
|
|
|
/* Needed to categorize types of errors and add environment section in allure report. */
|
|
|
|
sh 'cp ext/allure_files/categories.json allure-results'
|
|
|
|
sh 'cp ext/allure_files/environment.properties allure-results'
|
|
|
|
|
2023-09-28 12:44:13 +00:00
|
|
|
allure([
|
|
|
|
results: [[path: 'allure-results']],
|
|
|
|
reportBuildPolicy: 'ALWAYS',
|
2023-10-19 18:12:14 +00:00
|
|
|
properties: [],
|
|
|
|
jdk: '',
|
2023-09-28 12:44:13 +00:00
|
|
|
])
|
2023-10-24 12:45:32 +00:00
|
|
|
updateGitHubStatus()
|
2024-06-03 07:58:13 +00:00
|
|
|
} } }
|
2024-02-13 11:17:42 +00:00
|
|
|
failure { script {
|
|
|
|
discord.send(
|
|
|
|
header: '**Desktop E2E test failure!**',
|
|
|
|
cred: 'discord-status-desktop-e2e-webhook',
|
|
|
|
)
|
|
|
|
} }
|
2023-09-28 12:44:13 +00:00
|
|
|
cleanup { cleanWs() }
|
|
|
|
}
|
|
|
|
}
|
2023-10-20 12:26:52 +00:00
|
|
|
|
2023-10-26 11:18:33 +00:00
|
|
|
def setNewBuildName() {
|
2023-11-08 10:55:08 +00:00
|
|
|
if (currentBuild.upstreamBuilds) {
|
|
|
|
def parent = utils.parentOrCurrentBuild()
|
|
|
|
currentBuild.displayName = parent.getFullDisplayName().minus('status-desktop » ')
|
2023-11-06 15:45:43 +00:00
|
|
|
}
|
2023-11-08 10:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def setBuildDescFromFile(fileNameOrPath) {
|
|
|
|
def tokens = utils.parseFilename(utils.baseName(fileNameOrPath))
|
2023-11-10 13:00:52 +00:00
|
|
|
if (tokens == null) { /* Fallback for regex fail. */
|
|
|
|
currentBuild.description = utils.baseName(fileNameOrPath)
|
|
|
|
return
|
|
|
|
}
|
2023-11-10 13:57:46 +00:00
|
|
|
if (tokens.build && tokens.build.startsWith('pr')) {
|
2023-10-26 22:51:27 +00:00
|
|
|
currentBuild.displayName = tokens.build.replace(/^pr/, 'PR-')
|
2023-10-20 12:26:52 +00:00
|
|
|
}
|
2023-11-08 10:55:08 +00:00
|
|
|
currentBuild.description = formatMap([
|
|
|
|
Node: NODE_NAME,
|
|
|
|
Build: tokens.build,
|
|
|
|
Commit: tokens.commit,
|
|
|
|
Version: (tokens.tstamp ?: tokens.version),
|
|
|
|
])
|
2023-10-20 12:26:52 +00:00
|
|
|
}
|
2023-10-24 12:45:32 +00:00
|
|
|
|
|
|
|
def updateGitHubStatus() {
|
|
|
|
/* For PR builds update check status. */
|
|
|
|
if (params.BUILD_SOURCE ==~ /.*\/PR-[0-9]+\/?$/) {
|
|
|
|
github.statusUpdate(
|
|
|
|
context: 'jenkins/prs/tests/e2e-new',
|
|
|
|
commit: jenkins.getJobCommitByPath(params.BUILD_SOURCE),
|
|
|
|
repo_url: 'https://github.com/status-im/status-desktop'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2023-10-26 11:18:33 +00:00
|
|
|
|
|
|
|
def formatMap(Map data=[:]) {
|
|
|
|
def text = ''
|
|
|
|
data.each { key, val -> text += "<b>${key}</b>: ${val}</a><br>\n" }
|
|
|
|
return text
|
|
|
|
}
|
2023-11-06 15:45:43 +00:00
|
|
|
|
|
|
|
def getDefaultBuildSource() {
|
|
|
|
if (JOB_NAME ==~ 'status-desktop/qa-automation/prs/.*') {
|
|
|
|
return 'status-desktop/nightly'
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
2023-12-22 16:17:34 +00:00
|
|
|
|
|
|
|
def getDefaultTestScopeFlag() {
|
2024-06-03 07:58:13 +00:00
|
|
|
if (JOB_NAME == "status-desktop/systems/linux/x86_64/tests-e2e") {
|
2023-12-22 16:17:34 +00:00
|
|
|
return ''
|
|
|
|
} else {
|
|
|
|
return '-m=critical'
|
|
|
|
}
|
|
|
|
}
|
2024-06-07 12:13:58 +00:00
|
|
|
|
|
|
|
def getTestStageTimeout() { TEST_SCOPE_FLAG == '-m=critical' ? 30 : 120 }
|