diff --git a/.gitlab/ci/code_quality/cpp.gitlab-ci.yml b/.gitlab/ci/code_quality/cpp.gitlab-ci.yml index 24c1d8b9076ce60a703b499eb5322765324065a9..8e3c912a74d5bfb102559a37c1340c78153b3676 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 684332e147ccb11316c82b4df99595b2fe958e3e..a1b1bfbbd74f0c7ebd9208cff20fb310ee2d808a 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."