From 3efd6270c6d8239f906690bf4c1aad45e3fa3bb0 Mon Sep 17 00:00:00 2001 From: Agustin Alba Chicar Date: Tue, 17 Nov 2020 08:36:17 -0300 Subject: [PATCH 1/3] - Adds clang sanitizer jobs. - Moves to ros-tools v0.26 - Removes tsan --- .github/clang_suite_installation.sh | 63 ++++++++++++++ .github/workflows/build.yml | 4 +- .github/workflows/sanitizers.yml | 123 ++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+), 3 deletions(-) create mode 100755 .github/clang_suite_installation.sh create mode 100644 .github/workflows/sanitizers.yml diff --git a/.github/clang_suite_installation.sh b/.github/clang_suite_installation.sh new file mode 100755 index 000000000..ca51cd00d --- /dev/null +++ b/.github/clang_suite_installation.sh @@ -0,0 +1,63 @@ +#! /bin/bash + +####################################### +# Installs clang suite packages. +# Arguments: +# Version of the clang suite package. +# Returns: +# 0 if no error was detected, non-zero otherwise. +####################################### +function install_clang_suite() { + local version=$1 + + apt install -y \ + clang-${version} \ + lldb-${version} \ + lld-${version} \ + clang-format-${version} \ + clang-tidy-${version} \ + libc++-${version}-dev \ + libc++abi-${version}-dev +} + +####################################### +# Setups alternatives for clang suite. +# Arguments: +# Version of the clang suite package. +# Returns: +# 0 if no error was detected, 2 otherwise. +####################################### +function update_clang_suite_alternatives() { + local version=$1 + local priority=$2 + + update-alternatives \ + --install /usr/bin/clang clang /usr/bin/clang-${version} ${priority}\ + --slave /usr/bin/clang++ clang++ /usr/bin/clang++-${version} \ + --slave /usr/bin/asan_symbolize asan_symbolize /usr/bin/asan_symbolize-${version} \ + --slave /usr/bin/c-index-test c-index-test /usr/bin/c-index-test-${version} \ + --slave /usr/bin/clang-check clang-check /usr/bin/clang-check-${version} \ + --slave /usr/bin/clang-cl clang-cl /usr/bin/clang-cl-${version} \ + --slave /usr/bin/clang-cpp clang-cpp /usr/bin/clang-cpp-${version} \ + --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-${version} \ + --slave /usr/bin/clang-format-diff clang-format-diff /usr/bin/clang-format-diff-${version} \ + --slave /usr/bin/clang-import-test clang-import-test /usr/bin/clang-import-test-${version} \ + --slave /usr/bin/clang-include-fixer clang-include-fixer /usr/bin/clang-include-fixer-${version} \ + --slave /usr/bin/clang-offload-bundler clang-offload-bundler /usr/bin/clang-offload-bundler-${version} \ + --slave /usr/bin/clang-query clang-query /usr/bin/clang-query-${version} \ + --slave /usr/bin/clang-rename clang-rename /usr/bin/clang-rename-${version} \ + --slave /usr/bin/clang-reorder-fields clang-reorder-fields /usr/bin/clang-reorder-fields-${version} \ + --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${version} \ + --slave /usr/bin/lldb lldb /usr/bin/lldb-${version} \ + --slave /usr/bin/lldb-server lldb-server /usr/bin/lldb-server-${version} +} + + +####################################### +# Modify clang suite version and priority as required. +####################################### +CLANG_SUITE_VERSION=8 +CLANG_SUITE_ALTERNATIVE_PRIORITY=10 + +install_clang_suite ${CLANG_SUITE_VERSION} +update_clang_suite_alternatives ${CLANG_SUITE_VERSION} ${CLANG_SUITE_ALTERNATIVE_PRIORITY} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c99c81e1..f002c1b94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,9 +49,7 @@ jobs: path: dsim-repos-index token: ${{ secrets.MALIPUT_TOKEN }} # use setup-ros action to get vcs, rosdep, and colcon - - uses: ros-tooling/setup-ros@0.0.25 - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true + - uses: ros-tooling/setup-ros@0.0.26 # install drake_vendor prereqs using dsim-repos-index/tools/prereqs.lib - name: install drake_vendor prereqs shell: bash diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml new file mode 100644 index 000000000..072d1eb99 --- /dev/null +++ b/.github/workflows/sanitizers.yml @@ -0,0 +1,123 @@ +name: clang + +on: + push: + branches: + - master + pull_request: + +env: + PACKAGE_NAME: delphyne + ROS_DISTRO: dashing + ROS_WS: maliput_ws + +jobs: + compile_and_test: + name: Compile and test with sanitizer + runs-on: ubuntu-18.04 + container: + image: ubuntu:18.04 + strategy: + matrix: + sanitizer: [none, asan, ubsan] + include: + - sanitizer: none + COMPILER_FLAG: '' + - sanitizer: asan + COMPILER_FLAG: ' -DADDRESS_SANITIZER=On' + - sanitizer: ubsan + COMPILER_FLAG: ' -DUNDEFINED_SANITIZER=On' + env: + CC: clang + CXX: clang++ + LINKER_PATH: /usr/bin/llvm-ld + steps: + # clone private dependencies + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/maliput + path: ${{ env.ROS_WS }}/src/maliput + token: ${{ secrets.MALIPUT_TOKEN }} + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/maliput-dragway + path: ${{ env.ROS_WS }}/src/maliput_dragway + token: ${{ secrets.MALIPUT_TOKEN }} + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/maliput-multilane + path: ${{ env.ROS_WS }}/src/maliput_multilane + token: ${{ secrets.MALIPUT_TOKEN }} + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/malidrive + path: ${{ env.ROS_WS }}/src/malidrive + token: ${{ secrets.MALIPUT_TOKEN }} + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/drake-vendor + path: ${{ env.ROS_WS }}/src/drake_vendor + token: ${{ secrets.MALIPUT_TOKEN }} + - uses: actions/checkout@v2 + with: + repository: ToyotaResearchInstitute/dsim-repos-index + path: dsim-repos-index + token: ${{ secrets.MALIPUT_TOKEN }} + # use setup-ros action to get vcs, rosdep, and colcon + - uses: ros-tooling/setup-ros@0.0.26 + # install drake_vendor prereqs using dsim-repos-index/tools/prereqs.lib + - name: install drake_vendor prereqs + shell: bash + working-directory: ${{ env.ROS_WS }}/src/drake_vendor + run: ${GITHUB_WORKSPACE}/dsim-repos-index/tools/prereqs-install -t drake . + # install delphyne prereqs using dsim-repos-index/tools/prereqs.lib + - name: install delphyne prereqs + shell: bash + working-directory: ${{ env.ROS_WS }}/src/delphyne + run: ${GITHUB_WORKSPACE}/dsim-repos-index/tools/prereqs-install -t ignition . + - name: clang 8 install + shell: bash + run: ${{ env.ROS_WS }}/src/${REPOSITORY_NAME}/.github/clang_suite_installation.sh + # clone public dependencies + - name: vcs import + shell: bash + working-directory: ${{ env.ROS_WS }} + run: vcs import src < src/${REPOSITORY_NAME}/.github/dependencies.repos + - run: colcon graph + shell: bash + working-directory: ${{ env.ROS_WS }} + - name: rosdep install + shell: bash + working-directory: ${{ env.ROS_WS }} + run: | + rosdep update; + rosdep install -i -y --rosdistro ${ROS_DISTRO} \ + --skip-keys "ignition-transport5 ignition-msgs2 ignition-math6 ignition-common3 pybind11" \ + --from-paths src + - name: colcon build libraries + shell: bash + working-directory: ${{ env.ROS_WS }} + run: | + . /opt/ros/${ROS_DISTRO}/setup.bash; + colcon build --packages-up-to ${PACKAGE_NAME} \ + --cmake-args -DCMAKE_LINKER=${LINKER_PATH} \ + --event-handlers=console_direct+ \ + ${COMPILER_FLAG} \ + --cmake-args -DBUILD_TESTING=OFF + - name: colcon build tests + shell: bash + working-directory: ${{ env.ROS_WS }} + run: | + . /opt/ros/${ROS_DISTRO}/setup.bash; + colcon build --packages-select ${PACKAGE_NAME} \ + --cmake-args -DCMAKE_LINKER=${LINKER_PATH} \ + --event-handlers=console_direct+ \ + ${COMPILER_FLAG} \ + --cmake-args -DBUILD_TESTING=ON; + - name: colcon test + shell: bash + working-directory: ${{ env.ROS_WS }} + run: | + . /opt/ros/${ROS_DISTRO}/setup.bash; + colcon test --packages-select ${PACKAGE_NAME} --event-handlers=console_direct+; + colcon test-result --verbose; From f075d042c25f4a6b8071ca869b48cfa391cef3aa Mon Sep 17 00:00:00 2001 From: Agustin Alba Chicar Date: Wed, 25 Nov 2020 13:51:41 -0300 Subject: [PATCH 2/3] Adds delphyne repository. --- .github/workflows/sanitizers.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 072d1eb99..64bf00e1f 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -32,6 +32,9 @@ jobs: CXX: clang++ LINKER_PATH: /usr/bin/llvm-ld steps: + - uses: actions/checkout@v2 + with: + path: ${{ env.ROS_WS }}/src/${{ env.PACKAGE_NAME }} # clone private dependencies - uses: actions/checkout@v2 with: From 16b87228f08c8d810598193b6f5c097c07c825ef Mon Sep 17 00:00:00 2001 From: Agustin Alba Chicar Date: Wed, 25 Nov 2020 14:00:48 -0300 Subject: [PATCH 3/3] Replaces REPOSITORY by PACKAGE name --- .github/workflows/sanitizers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 64bf00e1f..a54227dce 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -80,12 +80,12 @@ jobs: run: ${GITHUB_WORKSPACE}/dsim-repos-index/tools/prereqs-install -t ignition . - name: clang 8 install shell: bash - run: ${{ env.ROS_WS }}/src/${REPOSITORY_NAME}/.github/clang_suite_installation.sh + run: ${{ env.ROS_WS }}/src/${PACKAGE_NAME}/.github/clang_suite_installation.sh # clone public dependencies - name: vcs import shell: bash working-directory: ${{ env.ROS_WS }} - run: vcs import src < src/${REPOSITORY_NAME}/.github/dependencies.repos + run: vcs import src < src/${PACKAGE_NAME}/.github/dependencies.repos - run: colcon graph shell: bash working-directory: ${{ env.ROS_WS }}