From 9a15342925a0c8661bf21ead49d9c75b304c997f Mon Sep 17 00:00:00 2001 From: AlejandroSuero Date: Thu, 12 Sep 2024 12:03:25 +0200 Subject: [PATCH] feat(tests): add rerun test when failures --- .config/python/dev/requirements.txt | 1 + .cspell.json | 1 + entrypoint.sh | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.config/python/dev/requirements.txt b/.config/python/dev/requirements.txt index e39c0ff5bdb..ed27fb49b8b 100644 --- a/.config/python/dev/requirements.txt +++ b/.config/python/dev/requirements.txt @@ -24,6 +24,7 @@ pytablewriter pytest-cov pytest-timeout pytest-xdist +pytest-rerunfailures python-gitlab python-gitlab python-multipart diff --git a/.cspell.json b/.cspell.json index 3b064e96160..6234a15baa3 100644 --- a/.cspell.json +++ b/.cspell.json @@ -148,6 +148,7 @@ "readdir-scoped-modules", "rechoir", "repositoryformatversion", + "rerunfailures", "reusify", "rimraf", "rulesetsoverridetype", diff --git a/entrypoint.sh b/entrypoint.sh index c9e4ed1a09b..708f748f232 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,11 +29,11 @@ git config --global --add safe.directory /tmp/lint # Called by Auto-update CI job if [ "${UPGRADE_LINTERS_VERSION}" == "true" ]; then echo "[MegaLinter init] UPGRADING LINTER VERSION" - pip install pytest-cov pytest-timeout + pip install pytest-cov pytest-timeout pytest-rerunfailures # Run only get_linter_version test methods - pytest -v --durations=0 -k _get_linter_version megalinter/ + pytest --reruns 3 --reruns-delay 1 -v --durations=0 -k _get_linter_version megalinter/ # Run only get_linter_help test methods - pytest -v --durations=0 -k _get_linter_help megalinter/ + pytest --reruns 3 --reruns-delay 1 -v --durations=0 -k _get_linter_help megalinter/ # Reinstall mkdocs-material because of broken dependency pip3 install --upgrade markdown mike mkdocs-material pymdown-extensions "mkdocs-glightbox==0.3.2" mdx_truly_sane_lists jsonschema json-schema-for-humans giturlparse webpreview github-dependents-info cd /tmp/lint || exit 1 @@ -45,11 +45,11 @@ fi # Run test cases with pytest if [ "${TEST_CASE_RUN}" == "true" ]; then echo "[MegaLinter init] RUNNING TEST CASES" - pip install pytest-cov pytest-timeout pytest-xdist + pip install pytest-cov pytest-timeout pytest-xdist pytest-rerunfailures if [ -z "${TEST_KEYWORDS}" ]; then - pytest -v --timeout=300 --durations=0 --cov=megalinter --cov-report=xml --numprocesses auto --dist loadscope megalinter/ + pytest --reruns 3 --reruns-delay 1 -v --timeout=300 --durations=0 --cov=megalinter --cov-report=xml --numprocesses auto --dist loadscope megalinter/ else - pytest -v --timeout=300 --durations=0 --numprocesses auto --dist loadscope -k "${TEST_KEYWORDS}" megalinter/ + pytest --reruns 3 --reruns-delay 1 -v --timeout=300 --durations=0 --numprocesses auto --dist loadscope -k "${TEST_KEYWORDS}" megalinter/ fi PYTEST_STATUS=$? echo Pytest exited $PYTEST_STATUS