From 62a49be9e9b2d36eb3e37f1628423fcff3d9d219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Moreau?= <cem.moreau@gmail.com> Date: Mon, 13 Nov 2023 12:30:42 +0100 Subject: [PATCH] Resolve "E2E tests fail but the CI succeeds" (nodes/rust/duniter-v2s!189) * fix(#132): fix: always run `tests` job by default * fix(#132): fix: change `tests` job * fix(#132): E2E tests must fail if some hooks have failed --- .gitlab-ci.yml | 18 ++++++++++++------ end2end-tests/tests/cucumber_tests.rs | 10 +++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e4b04ffb..b2cc65c9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -127,20 +127,26 @@ build_release_tag: IMAGE_TAG: "$CI_COMMIT_TAG" PODMAN_BUILD_OPTIONS: "--platform linux/amd64" -test_debug: +tests: stage: tests - extends: .docker_build + image: rust:1-bullseye rules: - if: $CI_COMMIT_REF_NAME =~ /^wip*$/ when: manual - if: $CI_COMMIT_TAG when: never - if: '$CI_MERGE_REQUEST_ID || $CI_COMMIT_BRANCH == "master"' - - when: manual + when: manual + - when: always variables: - IMAGE_NAME: "duniter/duniter-v2s-test" - IMAGE_TAG: "debug-sha-$CI_COMMIT_SHORT_SHA" - PODMAN_BUILD_OPTIONS: "--target build --build-arg debug=1 --build-arg cucumber=1" + DEBIAN_FRONTEND: noninteractive + script: + - apt-get update + - apt-get install -y clang cmake protobuf-compiler + # cargo build is required for cucumber tests anyway + - cargo build + - cargo tu + - cargo cucumber test_release: stage: tests diff --git a/end2end-tests/tests/cucumber_tests.rs b/end2end-tests/tests/cucumber_tests.rs index 80a1772ac..06b8acba6 100644 --- a/end2end-tests/tests/cucumber_tests.rs +++ b/end2end-tests/tests/cucumber_tests.rs @@ -18,7 +18,7 @@ mod common; use async_trait::async_trait; use common::*; -use cucumber::{given, then, when, World, WorldInit}; +use cucumber::{given, then, when, FailureWriter, World, WorldInit}; use sp_keyring::AccountKeyring; use std::convert::Infallible; use std::path::PathBuf; @@ -636,7 +636,7 @@ async fn main() { }) .expect("Error setting Ctrl-C handler"); - DuniterWorld::cucumber() + let summarize = DuniterWorld::cucumber() //.fail_on_skipped() .max_concurrent_scenarios(4) .before(|feature, _rule, scenario, world| { @@ -660,8 +660,12 @@ async fn main() { Box::pin(std::future::ready(())) }) .with_cli(opts) - .run_and_exit(features_path) + .run(features_path) .await; + + if summarize.hook_errors() > 0 { + panic!("Could not run tests correctly (hook errors)"); + } } fn genesis_conf_name(feature_tags: &[String], scenario_tags: &[String]) -> String { -- GitLab