Skip to content
Snippets Groups Projects
Commit eea3ef77 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

fix : missing deps + better prints of format jobs

parent c0795a8a
No related branches found
No related tags found
1 merge request!10Code formatting
...@@ -9,7 +9,7 @@ code_quality:static_analysis:cpp: ...@@ -9,7 +9,7 @@ code_quality:static_analysis:cpp:
- static_analysis - static_analysis
before_script : before_script :
- !reference [.retrieve_deps:apt, 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 Pygments
- python -m pip install -U cppcheck_codequality - python -m pip install -U cppcheck_codequality
...@@ -70,9 +70,11 @@ code_quality:code_format:cpp: ...@@ -70,9 +70,11 @@ code_quality:code_format:cpp:
- ./llvm.sh $CLANG_VERSION - ./llvm.sh $CLANG_VERSION
- apt-get install -y -qq clang-format-$CLANG_VERSION - apt-get install -y -qq clang-format-$CLANG_VERSION
script: 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_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) - 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 if [[ -n "$modified_CXX_files" ]]; then
CLANG_OUTPUT=$(clang-format-$CLANG_VERSION --style=file:.clang-format --dry-run $modified_CXX_files || true ) CLANG_OUTPUT=$(clang-format-$CLANG_VERSION --style=file:.clang-format --dry-run $modified_CXX_files || true )
......
...@@ -67,16 +67,19 @@ code_quality:code_format:python: ...@@ -67,16 +67,19 @@ code_quality:code_format:python:
- pip install ruff - pip install ruff
script: 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_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 ) - 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=$(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 :"
echo "$python_files_to_format" echo "$python_files_to_format"
fi fi
after_script:
- > - >
if [[ "$python_files_to_format" != "" ]]; then if [[ "$python_files_to_format" != "" ]]; then
echo "You pushed unformatted files, setup a code formatter before pushing your code." echo "You pushed unformatted files, setup a code formatter before pushing your code."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment