From 8ea9184570ea9512c01b3500ebb7ead4713f4d82 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sat, 28 May 2022 01:19:19 +0200 Subject: [PATCH] Tests: Switch module tests to podman --- tests/modules/Jenkinsfile | 46 ++++++--------------------------------- tests/modules/testall.sh | 19 ++++++++++++++++ 2 files changed, 26 insertions(+), 39 deletions(-) create mode 100755 tests/modules/testall.sh diff --git a/tests/modules/Jenkinsfile b/tests/modules/Jenkinsfile index c32521ddd..0b8c2474a 100644 --- a/tests/modules/Jenkinsfile +++ b/tests/modules/Jenkinsfile @@ -1,37 +1,19 @@ #!groovy -def prepareDocker () { - def img - stage('Prepare environment') { - dir('.imagebuild') { - 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') - } +node { + stage('Checkout') { + deleteDir() + checkout scm } - return img -} -def runTests() { - stage ('Install lib') { - sh "pip install --user -e .[css,dev]" - } stage ('Run tests') { timeout(time: 12, unit: 'HOURS') { withCredentials([string(credentialsId: 'proxymap', variable: 'PROXYMAP')]) { - 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 - ''' + sh 'podman run --rm -v $PWD:/work --userns=keep-id docker.io/python:3.10-bullseye tests/modules/testall.sh' } } } + stage('Report') { junit 'junit.xml' publishCoverage calculateDiffForChangeRequests: true, @@ -40,19 +22,6 @@ def runTests() { coberturaAdapter('coverage.xml') ] } -} - -// MAIN // -node { - def img = prepareDocker() - - stage('Checkout') { - checkout scm - } - - img.inside { - runTests() - } stage('Allure Report') { copyArtifacts filter: 'allure-history.zip', optional: true, @@ -61,9 +30,8 @@ node { unzip dir: 'allure-data', quiet: true, zipFile: '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' publishHTML reportDir: 'allure-report', reportFiles: 'index.html', reportName: 'Allure Report' } } - diff --git a/tests/modules/testall.sh b/tests/modules/testall.sh new file mode 100755 index 000000000..d4483bc83 --- /dev/null +++ b/tests/modules/testall.sh @@ -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 +