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') {
|
||||
steps {
|
||||
container('tester') {
|
||||
sh '''
|
||||
set -euo pipefail
|
||||
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
||||
mkdir -p build
|
||||
python -m ruff check ariadne --select C90,PLR
|
||||
python -m slipcover \
|
||||
--json \
|
||||
--out "${COVERAGE_JSON}" \
|
||||
--source ariadne \
|
||||
--fail-under "${COVERAGE_MIN}" \
|
||||
-m pytest -ra -vv --durations=20 --junitxml "${JUNIT_XML}"
|
||||
python - <<'PY'
|
||||
import json
|
||||
with open("build/coverage.json", "r", encoding="utf-8") as handle:
|
||||
payload = json.load(handle)
|
||||
summary = payload.get("summary") or {}
|
||||
percent = summary.get("percent_covered")
|
||||
print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable")
|
||||
PY
|
||||
'''
|
||||
sh(script: '''
|
||||
set -euo pipefail
|
||||
python -m pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
|
||||
mkdir -p build
|
||||
python -m ruff check ariadne --select C90,PLR
|
||||
python -m slipcover \
|
||||
--json \
|
||||
--out "${COVERAGE_JSON}" \
|
||||
--source ariadne \
|
||||
--fail-under "${COVERAGE_MIN}" \
|
||||
-m pytest -ra -vv --durations=20 --junitxml "${JUNIT_XML}"
|
||||
python - <<'PY'
|
||||
import json
|
||||
with open("build/coverage.json", "r", encoding="utf-8") as handle:
|
||||
payload = json.load(handle)
|
||||
summary = payload.get("summary") or {}
|
||||
percent = summary.get("percent_covered")
|
||||
print(f"Coverage summary: {percent:.2f}%" if percent is not None else "Coverage summary unavailable")
|
||||
PY
|
||||
'''.stripIndent())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,7 +204,15 @@ spec:
|
||||
|
||||
post {
|
||||
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
|
||||
script {
|
||||
def props = fileExists('build.env') ? readProperties(file: 'build.env') : [:]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user