Tests: Switch module tests to podman
This commit is contained in:
parent
420fde12b0
commit
8ea9184570
2 changed files with 26 additions and 39 deletions
46
tests/modules/Jenkinsfile
vendored
46
tests/modules/Jenkinsfile
vendored
|
@ -1,37 +1,19 @@
|
||||||
#!groovy
|
#!groovy
|
||||||
|
|
||||||
def prepareDocker () {
|
node {
|
||||||
def img
|
stage('Checkout') {
|
||||||
stage('Prepare environment') {
|
deleteDir()
|
||||||
dir('.imagebuild') {
|
checkout scm
|
||||||
def uid = sh returnStdout: true, script: 'id -u'
|
|
||||||
writeFile file: 'Dockerfile', text: """
|
|
||||||
FROM python:3.8-buster
|
|
||||||
RUN pip install pytest-cov PySocks && \\
|
|
||||||
useradd -m -u ${uid.trim()} jenkins
|
|
||||||
"""
|
|
||||||
img = docker.build('local:test-all-comics')
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return img
|
|
||||||
}
|
|
||||||
|
|
||||||
def runTests() {
|
|
||||||
stage ('Install lib') {
|
|
||||||
sh "pip install --user -e .[css,dev]"
|
|
||||||
}
|
|
||||||
stage ('Run tests') {
|
stage ('Run tests') {
|
||||||
timeout(time: 12, unit: 'HOURS') {
|
timeout(time: 12, unit: 'HOURS') {
|
||||||
withCredentials([string(credentialsId: 'proxymap', variable: 'PROXYMAP')]) {
|
withCredentials([string(credentialsId: 'proxymap', variable: 'PROXYMAP')]) {
|
||||||
sh '''
|
sh 'podman run --rm -v $PWD:/work --userns=keep-id docker.io/python:3.10-bullseye tests/modules/testall.sh'
|
||||||
TESTALL=1 py.test -v --cov=dosagelib --cov-report xml \
|
|
||||||
--alluredir=allure-data \
|
|
||||||
--tb=short -n10 --junitxml=junit.xml \
|
|
||||||
tests/modules/check_comics.py || true
|
|
||||||
'''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Report') {
|
stage('Report') {
|
||||||
junit 'junit.xml'
|
junit 'junit.xml'
|
||||||
publishCoverage calculateDiffForChangeRequests: true,
|
publishCoverage calculateDiffForChangeRequests: true,
|
||||||
|
@ -40,19 +22,6 @@ def runTests() {
|
||||||
coberturaAdapter('coverage.xml')
|
coberturaAdapter('coverage.xml')
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// MAIN //
|
|
||||||
node {
|
|
||||||
def img = prepareDocker()
|
|
||||||
|
|
||||||
stage('Checkout') {
|
|
||||||
checkout scm
|
|
||||||
}
|
|
||||||
|
|
||||||
img.inside {
|
|
||||||
runTests()
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Allure Report') {
|
stage('Allure Report') {
|
||||||
copyArtifacts filter: 'allure-history.zip', optional: true,
|
copyArtifacts filter: 'allure-history.zip', optional: true,
|
||||||
|
@ -61,9 +30,8 @@ node {
|
||||||
unzip dir: 'allure-data', quiet: true, zipFile: 'allure-history.zip'
|
unzip dir: 'allure-data', quiet: true, zipFile: 'allure-history.zip'
|
||||||
sh 'rm -f allure-history.zip'
|
sh 'rm -f allure-history.zip'
|
||||||
}
|
}
|
||||||
sh 'docker run --rm -v $PWD:/work -u $(id -u) tobix/allure-cli generate allure-data'
|
sh 'podman run --rm -v $PWD:/work --userns=keep-id docker.io/tobix/allure-cli generate allure-data'
|
||||||
zip archive: true, dir: 'allure-report', glob: 'history/**', zipFile: 'allure-history.zip'
|
zip archive: true, dir: 'allure-report', glob: 'history/**', zipFile: 'allure-history.zip'
|
||||||
publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report'
|
publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
tests/modules/testall.sh
Executable file
19
tests/modules/testall.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
if ! [ "$container" ]
|
||||||
|
then
|
||||||
|
echo 'ERROR: Not running inside a container!'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
HOME="/tmp/home"
|
||||||
|
mkdir -p "$HOME"
|
||||||
|
cd /work
|
||||||
|
pip install --no-warn-script-location --user pytest-cov PySocks
|
||||||
|
pip install --no-warn-script-location --user -e '.[css,dev]'
|
||||||
|
|
||||||
|
TESTALL=1 python3 -m py.test -v --cov=. --cov-report xml \
|
||||||
|
--alluredir=allure-data \
|
||||||
|
--tb=short -n10 --junitxml=junit.xml \
|
||||||
|
tests/modules/check_comics.py
|
||||||
|
|
Loading…
Reference in a new issue