#!/usr/bin/env groovy library 'status-jenkins-lib@v1.8.0' pipeline { agent { label "${params.AGENT} && x86_64 && qt-5.15.2" } parameters { gitParameter( name: 'GIT_REF', description: 'Git branch to checkout.', branchFilter: 'origin/(.*)', branch: '', defaultValue: 'master', quickFilterEnabled: false, selectedValue: 'DEFAULT', sortMode: 'ASCENDING_SMART', tagFilter: '*', type: 'PT_BRANCH' ) string( name: 'BUILD_SOURCE', description: 'URL to tar.gz file OR path to Jenkins build.', defaultValue: '' ) string( name: 'TEST_NAME', description: 'Paste test name/part of test name to run specific test.', defaultValue: '' ) string( name: 'TEST_SCOPE', description: 'Paste tag to run specific scope of tests.', defaultValue: '' ) string( name: 'TESTRAIL_RUN_ID', description: 'Test run ID in Test Rail.', defaultValue: '' ) /* 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'] ) } options { timestamps() /* Prevent Jenkins jobs from running forever */ timeout(time: 120, unit: 'MINUTES') /* manage how many builds we keep */ buildDiscarder(logRotator( numToKeepStr: '10', daysToKeepStr: '30', artifactNumToKeepStr: '3', )) } environment { QT_QPA_PLATFORMTHEME = 'qt5ct' QT_LOGGING_DEBUG = 1 QT_DEBUG_PLUGINS = 1 SQUISH_DIR = '/opt/squish-runner-7.1-20230222-1555' PYTHONPATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/lib/python:${PYTHONPATH}" LD_LIBRARY_PATH = "${SQUISH_DIR}/lib:${SQUISH_DIR}/python3/lib:${LD_LIBRARY_PATH}" TESTRAIL_URL = 'https://ethstatus.testrail.net' } stages { stage('Setup') { steps { script { currentBuild.displayName = getNewBuildName() sh 'pip3 install --user -r requirements.txt' } } } stage('Download') { when { expression { params.BUILD_SOURCE.startsWith('http') } } steps { script { sh 'mkdir -p ./tmp/pkg/' fileOperations([ fileDownloadOperation( url: params.BUILD_SOURCE, targetFileName: 'StatusIm-Desktop.tar.gz', targetLocation: './tmp/pkg/', userName: '', password: '', ) ]) } } } stage('Copy') { when { expression { ! params.BUILD_SOURCE.startsWith('http') } } steps { script { copyArtifacts( projectName: params.BUILD_SOURCE, filter: 'pkg/*-x86_64.tar.gz', selector: lastWithArtifacts(), target: './tmp' ) } } } stage('Unpack') { steps { script { sh "tar -zxvf '${utils.findFile('tmp/pkg/*tar.gz')}' -C './tmp'" env.APP_DIR = utils.findFile('tmp/*.AppImage') } } } stage('Test') { steps { script { def flags = [] if (params.TEST_NAME) { flags.add("-k=${params.TEST_NAME}") } if (params.TEST_SCOPE) { flags.add("-m=${params.TEST_SCOPE}") } dir ('configs') { sh 'ln -s _local.ci.py _local.py' } wrap([ $class: 'Xvfb', autoDisplayName: true, parallelBuild: true, screen: '1920x1080x24', additionalOptions: '-dpi 1' ]) { sh 'fluxbox &' withCredentials([ usernamePassword( credentialsId: 'test-rail-api-devops', usernameVariable: 'TESTRAIL_USR', passwordVariable: 'TESTRAIL_PSW' ) ]) { sh """ python3 -m pytest ${flags.join(" ")} \ --disable-warnings \ --alluredir=./allure-results """ } } } } } } post { always { script { allure([ results: [[path: 'allure-results']], reportBuildPolicy: 'ALWAYS', properties: [], jdk: '', ]) /* 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' ) } } } cleanup { cleanWs() } } } def getNewBuildName() { /* For URLs we need to parse the filename to get attributes. */ if (params.BUILD_SOURCE.startsWith('http')) { def tokens = utils.parseFilename(utils.baseName(params.BUILD_SOURCE)) return [ (tokens.tstamp ?: tokens.version), tokens.commit, tokens.build ].grep().join('-') } else { return utils.baseName(params.BUILD_SOURCE) } }