From eea3ef77b70f7b9963e3b9d610500215f13363d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire?= <gregoire.kubler@proton.me> Date: Thu, 31 Oct 2024 12:07:12 +0100 Subject: [PATCH] fix : missing deps + better prints of format jobs --- .gitlab/ci/code_quality/cpp.gitlab-ci.yml | 6 ++++-- .gitlab/ci/code_quality/python.gitlab-ci.yml | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitlab/ci/code_quality/cpp.gitlab-ci.yml b/.gitlab/ci/code_quality/cpp.gitlab-ci.yml index 24c1d8b..8e3c912 100644 --- a/.gitlab/ci/code_quality/cpp.gitlab-ci.yml +++ b/.gitlab/ci/code_quality/cpp.gitlab-ci.yml @@ -9,7 +9,7 @@ code_quality:static_analysis:cpp: - static_analysis before_script : - !reference [.retrieve_deps:apt, script] - - apt-get install -y cppcheck python-is-python3 + - apt-get install -y cppcheck python-is-python3 python3-pip - python -m pip install Pygments - python -m pip install -U cppcheck_codequality @@ -70,9 +70,11 @@ code_quality:code_format:cpp: - ./llvm.sh $CLANG_VERSION - apt-get install -y -qq clang-format-$CLANG_VERSION script: - - echo "Ensuring that all cpp files modified in previous commit are correctly formatted. If not, this job will fail." + - echo "Retrieving all cpp/hpp files that differ from dev branch." + - echo "Ensuring that all these files are correctly formatted. If not, this job will fail." - modified_files=$(git diff --name-only HEAD origin/dev) # change "dev" to $CI_DEFAULT_BRANCH when whole codebase is formatted - modified_CXX_files=$(echo "$modified_files" | grep -Ei '\.(h|c|hpp|cpp|cu)$' || true) + - echo "modified CXX files :\ $modified_CXX_files" - > if [[ -n "$modified_CXX_files" ]]; then CLANG_OUTPUT=$(clang-format-$CLANG_VERSION --style=file:.clang-format --dry-run $modified_CXX_files || true ) diff --git a/.gitlab/ci/code_quality/python.gitlab-ci.yml b/.gitlab/ci/code_quality/python.gitlab-ci.yml index 684332e..a1b1bfb 100644 --- a/.gitlab/ci/code_quality/python.gitlab-ci.yml +++ b/.gitlab/ci/code_quality/python.gitlab-ci.yml @@ -67,16 +67,19 @@ code_quality:code_format:python: - pip install ruff script: - - echo "Ensuring that all python files modified in previous commit are correctly formatted. If not, this job will fail." + - echo "Retrieving all python files that differ from dev branch." + - echo "Ensuring that all these files are correctly formatted. If not, this job will fail." - modified_files=$(git diff --name-only HEAD origin/dev) # change "dev" to $CI_DEFAULT_BRANCH when whole codebase is formatted - modified_python_files=$(echo $modified_files | grep ".py$\|.ipynb$" || true ) + - echo "Modified python files $modified_python_files." - > - if [[ -n $modified_python_files ]]; then + if [[ -n "$modified_python_files" ]]; then python_files_to_format=$(ruff format --check $modified_python_files) - python_files_to_format=$(( $python_files_to_format != "" ? $python_files_to_format : "")) + python_files_to_format=$(( "$python_files_to_format" != "" ? $python_files_to_format : "")) echo "PYTHON FILES TO FORMAT :" echo "$python_files_to_format" fi + after_script: - > if [[ "$python_files_to_format" != "" ]]; then echo "You pushed unformatted files, setup a code formatter before pushing your code." -- GitLab