From f826ee7d9ca630164d13dd69c7c8a0ac8e16dc35 Mon Sep 17 00:00:00 2001 From: jparisu Date: Wed, 9 Jun 2021 14:50:18 +0200 Subject: [PATCH 1/4] add uncrustify test action Signed-off-by: jparisu --- .github/workflows/ci.yml | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc7f2e37..eb2d5d0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,3 +98,71 @@ jobs: # . install/local_setup.sh # colcon test --packages-select is-fiware --event-handlers console_direct+ # colcon test-result + + uncrustify: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + path: src/integration-service + + - name: Fetch all branches and tags + run: | + cd src/integration-service + git fetch --prune --unshallow + + - name: Install uncrustify + run: | + git clone https://github.com/uncrustify/uncrustify.git \ + --branch uncrustify-0.71.0 \ + --single-branch uncrustify + mkdir -p uncrustify/build + cd uncrustify/build + cmake .. + sudo cmake --build . --target install + cd ../.. + sudo rm -rf uncrustify + + - name: Clone ament_lint + run: | + git clone https://github.com/ament/ament_lint.git src/ament_lint + + - name: Build ament_uncrustify + run: colcon build --packages-up-to ament_uncrustify + + - name: Fetch uncrustify config file + run: | + curl \ + -l https://raw.githubusercontent.com/eProsima/cpp-style/master/uncrustify.cfg \ + -o uncrustify.cfg + + - name: Get difference + run: | + cd src/integration-service + echo "MODIFIED_FILES=$(git diff --name-only origin/${GITHUB_BASE_REF} origin/${GITHUB_HEAD_REF} | grep -e '\.h' -e '\.hpp' -e '\.cpp' | tr '\n' ' ')" >> $GITHUB_ENV + + - name: Check difference + run: | + cd src/integration-service + if [[ -z "${MODIFIED_FILES}" ]] + then + touch empty.hpp + echo "MODIFIED_FILES=empty.hpp" >> $GITHUB_ENV + fi + + - name: Check style + run: | + source install/local_setup.bash + cd src/integration-service + ament_uncrustify \ + -c ../../uncrustify.cfg \ + --language CPP \ + --xunit-file ../../uncrustify_results.xml \ + ${MODIFIED_FILES} + + - name: Upload uncrustify results + uses: actions/upload-artifact@v1 + with: + name: uncrustify_results + path: uncrustify_results.xml From 375127d20e38c45f88375119221775763f91178a Mon Sep 17 00:00:00 2001 From: jparisu Date: Wed, 9 Jun 2021 14:51:41 +0200 Subject: [PATCH 2/4] Uncrustify error to test Signed-off-by: jparisu --- core/src/utils/Log.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/utils/Log.cpp b/core/src/utils/Log.cpp index 0b48421c..cdf05259 100644 --- a/core/src/utils/Log.cpp +++ b/core/src/utils/Log.cpp @@ -187,8 +187,7 @@ std::ostream& Logger::green( //============================================================================== std::ostream& Logger::yellow( - std::ostream& os) -{ + std::ostream& os){ return os << "\033[33m"; } From 3f63b25d3d01d96636e86dc36efa425ea741821d Mon Sep 17 00:00:00 2001 From: jparisu Date: Wed, 9 Jun 2021 14:56:15 +0200 Subject: [PATCH 3/4] add actions for uncrustify dependencies Signed-off-by: jparisu --- .../actions/install-apt-packages/action.yml | 23 +++++++++++++++++++ .../install-python-packages/action.yml | 20 ++++++++++++++++ .github/workflows/ci.yml | 3 +++ 3 files changed, 46 insertions(+) create mode 100644 .github/actions/install-apt-packages/action.yml create mode 100644 .github/actions/install-python-packages/action.yml diff --git a/.github/actions/install-apt-packages/action.yml b/.github/actions/install-apt-packages/action.yml new file mode 100644 index 00000000..9cbd5220 --- /dev/null +++ b/.github/actions/install-apt-packages/action.yml @@ -0,0 +1,23 @@ +name: 'install-apt-packages' +description: 'Install necessary apt packages' +runs: + using: "composite" + steps: + - id: install-apt-packages + run: | + sudo apt -y install \ + doxygen \ + graphviz \ + imagemagick \ + python3 \ + python3-pip \ + python3-sphinxcontrib.spelling \ + python3-venv \ + software-properties-common \ + wget \ + libasio-dev \ + libtinyxml2-dev \ + clang-tidy \ + curl \ + grep + shell: bash diff --git a/.github/actions/install-python-packages/action.yml b/.github/actions/install-python-packages/action.yml new file mode 100644 index 00000000..354d1255 --- /dev/null +++ b/.github/actions/install-python-packages/action.yml @@ -0,0 +1,20 @@ +name: 'install-python-packages' +description: 'Install necessary python packages' +runs: + using: "composite" + steps: + - id: install-python-packages + run: | + sudo pip3 install -U \ + sphinx==3.0.3 \ + doc8==0.8.0 \ + sphinx_rtd_theme==0.4.3 \ + sphinxcontrib.spelling==5.0.0 \ + sphinxcontrib-imagehelper==1.1.1 \ + colcon-common-extensions \ + colcon-mixin \ + vcstool \ + GitPython \ + setuptools \ + gcovr + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb2d5d0c..88fd3acb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,9 @@ jobs: cd src/integration-service git fetch --prune --unshallow + - uses: ./src/integration-service/.github/actions/install-apt-packages + - uses: ./src/integration-service/.github/actions/install-python-packages + - name: Install uncrustify run: | git clone https://github.com/uncrustify/uncrustify.git \ From 9093b64b74ec6cfd3541ed3e1dcca9c0f1d8654e Mon Sep 17 00:00:00 2001 From: jparisu Date: Wed, 9 Jun 2021 15:05:49 +0200 Subject: [PATCH 4/4] fix propose error for uncrustify Signed-off-by: jparisu --- core/src/utils/Log.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/utils/Log.cpp b/core/src/utils/Log.cpp index cdf05259..775d377e 100644 --- a/core/src/utils/Log.cpp +++ b/core/src/utils/Log.cpp @@ -130,9 +130,9 @@ Logger& Logger::operator <<( //============================================================================== Logger& Logger::operator <<( - std::basic_ostream >& + std::basic_ostream>& (*func)( - std::basic_ostream >&)) + std::basic_ostream>&)) { switch (_status) { @@ -187,7 +187,8 @@ std::ostream& Logger::green( //============================================================================== std::ostream& Logger::yellow( - std::ostream& os){ + std::ostream& os) +{ return os << "\033[33m"; }