From 56e675bd333f8af069b2d7ba67ade1f39fcd01c4 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Mon, 22 Apr 2024 11:40:23 +0200 Subject: [PATCH] fix: configure ruff with a temp cache (#5548) - Configure Ruff to store its cache in a temporary directory inside the container by default. Users can still override this by providing a configuration file for Ruff. - Add tests to ensure that super-linter deletes temporary files and directories. Close #5543 --- TEMPLATES/.ruff.toml | 3 +++ test/run-super-linter-tests.sh | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/TEMPLATES/.ruff.toml b/TEMPLATES/.ruff.toml index b22a41fa..a970189c 100644 --- a/TEMPLATES/.ruff.toml +++ b/TEMPLATES/.ruff.toml @@ -1,3 +1,6 @@ +# Store the cache in a temporary location +cache-dir = "/tmp/.ruff_cache" + # Same as .flake8 line-length = 120 diff --git a/test/run-super-linter-tests.sh b/test/run-super-linter-tests.sh index f13180d8..cdf5feb9 100755 --- a/test/run-super-linter-tests.sh +++ b/test/run-super-linter-tests.sh @@ -127,3 +127,21 @@ if [ ${SUPER_LINTER_EXIT_CODE} -ne ${EXPECTED_EXIT_CODE} ]; then else echo "Super-linter exited with the expected code: ${SUPER_LINTER_EXIT_CODE}" fi + +# Check if super-linter leaves leftovers behind +declare -a TEMP_ITEMS_TO_CLEAN +TEMP_ITEMS_TO_CLEAN=() +TEMP_ITEMS_TO_CLEAN+=("$(pwd)/.lintr") +TEMP_ITEMS_TO_CLEAN+=("$(pwd)/.mypy_cache") +TEMP_ITEMS_TO_CLEAN+=("$(pwd)/.ruff_cache") +TEMP_ITEMS_TO_CLEAN+=("$(pwd)/logback.log") + +for item in "${TEMP_ITEMS_TO_CLEAN[@]}"; do + echo "Check if ${item} exists" + if [[ -e "${item}" ]]; then + echo "Error: ${item} exists and it should have been deleted" + exit 1 + else + echo "${item} does not exist as expected" + fi +done