From 61ff62cb290d72b39d9718933dd6ad5f4afaa652 Mon Sep 17 00:00:00 2001 From: gusto Date: Fri, 27 Oct 2023 19:54:56 +0200 Subject: [PATCH] CI: Integration tests report (#484) * Add missing dep to ci Dockerfile * Add a map to store minimal tests report * Use env vars for report messages * Do not mutate variables outside the scipt block * Write report to file --- ci/Dockerfile | 3 ++- ci/Jenkinsfile.nightly.integration | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index e6cd77eb..6621650e 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -10,7 +10,8 @@ RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' \ # Dependecies for publishing documentation. RUN apt-get update && apt-get install -yq \ - libssl-dev openssh-client git python3-pip clang + libssl-dev openssh-client git python3-pip clang \ + pkg-config RUN pip install ghp-import RUN rustup component add rustfmt clippy diff --git a/ci/Jenkinsfile.nightly.integration b/ci/Jenkinsfile.nightly.integration index 33f7dcd5..214a4ebb 100644 --- a/ci/Jenkinsfile.nightly.integration +++ b/ci/Jenkinsfile.nightly.integration @@ -54,7 +54,8 @@ pipeline { tests.add('mixnet') } - runBuildAndTestsForFeature(FEATURE, tests) + def report = runBuildAndTestsForFeature(FEATURE, tests) + writeFile(file: "${WORKSPACE}/report.txt", text: report) } } } @@ -68,14 +69,16 @@ pipeline { post { failure { script { + def report = readFile("${WORKSPACE}/report.txt").trim() def discord = load "${WORKSPACE}/ci/discord.groovy" - discord.sendMessage(header: 'Nightly Integration Tests Failed') + discord.sendMessage(header: "Nightly Integration Tests Failed: ${report}") } } success { script { + def report = readFile('report.txt').trim() def discord = load "${WORKSPACE}/ci/discord.groovy" - discord.sendMessage(header: 'Nightly Integration Tests Passed') + discord.sendMessage(header: "Nightly Integration Tests Passed: ${report}") } } cleanup { cleanWs() } @@ -87,12 +90,11 @@ def runBuildAndTestsForFeature(feature, tests) { def build_node = "cargo build --all --no-default-features --features ${feature}" if (sh(script: build_node, returnStatus: true) != 0) { - error("Build '${feature}' node failed") - return + return reportError("Build '${feature}' node failed") } int iterations = params.ITERATIONS.toInteger() - runTestCases(tests, iterations) + return runTestCases(tests, iterations) } def runTestCases(test_cases, iterations) { @@ -102,10 +104,15 @@ def runTestCases(test_cases, iterations) { for (test_case in test_cases) { def test_cmd = "cargo test -p tests --all --no-default-features --features ${feature} ${test_case}" if (sh(script: test_cmd, returnStatus: true) != 0) { - error("Test '${test_case}' failed on iteration ${i + 1}") - return + return reportError("Test '${test_case}' failed on iteration ${i + 1}") } } } + + return "${iterations}/${iterations} iterations succeeded" } +def reportError(e) { + error(e) + return e +}