ci: harden unit test step and junit post
This commit is contained in:
parent
8930161926
commit
a228e063f1
50
Jenkinsfile
vendored
50
Jenkinsfile
vendored
@ -95,26 +95,26 @@ spec:
|
|||||||
stage('Unit tests') {
|
stage('Unit tests') {
|
||||||
steps {
|
steps {
|
||||||
container('tester') {
|
container('tester') {
|
||||||
sh '''
|
sh(script: '''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
python -m ruff check ariadne --select C90,PLR
|
python -m ruff check ariadne --select C90,PLR
|
||||||
python -m slipcover \
|
python -m slipcover \
|
||||||
--json \
|
--json \
|
||||||
--out "${COVERAGE_JSON}" \
|
--out "${COVERAGE_JSON}" \
|
||||||
--source ariadne \
|
--source ariadne \
|
||||||
--fail-under "${COVERAGE_MIN}" \
|
--fail-under "${COVERAGE_MIN}" \
|
||||||
-m pytest -ra -vv --durations=20 --junitxml "${JUNIT_XML}"
|
-m pytest -ra -vv --durations=20 --junitxml "${JUNIT_XML}"
|
||||||
python - <<'PY'
|
python - <<'PY'
|
||||||
import json
|
import json
|
||||||
with open("build/coverage.json", "r", encoding="utf-8") as handle:
|
with open("build/coverage.json", "r", encoding="utf-8") as handle:
|
||||||
payload = json.load(handle)
|
payload = json.load(handle)
|
||||||
summary = payload.get("summary") or {}
|
summary = payload.get("summary") or {}
|
||||||
percent = summary.get("percent_covered")
|
percent = summary.get("percent_covered")
|
||||||
print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable")
|
print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable")
|
||||||
PY
|
PY
|
||||||
'''
|
'''.stripIndent())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +204,15 @@ spec:
|
|||||||
|
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
junit allowEmptyResults: true, testResults: 'build/junit.xml'
|
script {
|
||||||
|
if (fileExists('build/junit.xml')) {
|
||||||
|
try {
|
||||||
|
junit allowEmptyResults: true, testResults: 'build/junit.xml'
|
||||||
|
} catch (Throwable err) {
|
||||||
|
echo "junit step unavailable: ${err.class.simpleName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
archiveArtifacts artifacts: 'build/junit.xml,build/coverage.json', allowEmptyArchive: true, fingerprint: true
|
archiveArtifacts artifacts: 'build/junit.xml,build/coverage.json', allowEmptyArchive: true, fingerprint: true
|
||||||
script {
|
script {
|
||||||
def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:]
|
def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user