Skip to content

Commit

Permalink
clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjw committed Mar 24, 2021
1 parent 3ffd736 commit 3a67d3b
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 12 deletions.
58 changes: 46 additions & 12 deletions .github/workflows/industrial_ci_action.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,67 @@
# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git).
# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst)

# ros2 run industrial_ci rerun_ci ~/code/moveit2/ws_moveit2/src/moveit_calibration \
# DOCKER_IMAGE='moveit/moveit:melodic-source' \
# UPSTREAM_WORKSPACE='upstream.rosinstall' \
# BEFORE_INSTALL_UPSTREAM_DEPENDENCIES_EMBED='set +u && source /root/ws_moveit/install/setup.bash && set -u' \
# UNDERLAY='/root/ws_moveit' \
# TARGET_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1" \
# CCACHE_DIR=".ccache" \
# CLANG_TIDY=true \
# CLANG_TIDY_BASE_REF=master

name: BuildAndTest

on: [push, pull_request]
on:
workflow_dispatch:
pull_request:
push:
branches:
- master

jobs:
industrial_ci:
env:
DOCKER_IMAGE: 'moveit/moveit:melodic-source'
UPSTREAM_WORKSPACE: 'upstream.rosinstall'
AFTER_RUN_TARGET_TEST: './.ci.prepare_codecov'
TARGET_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='--coverage' -DCMAKE_CXX_FLAGS='--coverage'"
TARGET_CMAKE_ARGS: "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='--coverage' -DCMAKE_CXX_FLAGS='--coverage' -DCMAKE_EXPORT_COMPILE_COMMANDS=1"
ADDITIONAL_DEBS: 'lcov'
CCACHE_DIR: "${{ github.workspace }}/.ccache"
BASEDIR: ${{ github.workspace }}/.work
UNDERLAY: /root/ws_moveit
CLANG_TIDY: true
CLANG_TIDY_BASE_REF: 'master'

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: cache ccache
uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ github.sha }}
restore-keys: |
ccache-
- name: cache upstream_ws
uses: pat-s/always-upload-cache@v2.1.3
with:
path: ${{ env.BASEDIR }}/upstream_ws
key: upstream_ws-${{ hashFiles('upstream.rosinstall') }}-${{ github.run_id }}
key: upstream_ws-${{ hashFiles('upstream.repos') }}-${{ github.run_id }}
restore-keys: |
upstream_ws-${{ hashFiles('upstream.repos') }}
- name: cache target_ws
if: ${{ ! env.CCOV }}
uses: pat-s/always-upload-cache@v2.1.3
with:
path: ${{ env.BASEDIR }}/target_ws
key: target_ws-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}-${{ github.run_id }}
restore-keys: |
target_ws-${{ hashFiles('**/CMakeLists.txt', '**/package.xml') }}
- name: cache ccache
uses: pat-s/always-upload-cache@v2.1.3
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ github.sha }}-${{ github.run_id }}
restore-keys: |
upstream_ws-${{ hashFiles('upstream.rosinstall') }}
ccache-${{ github.sha }}
ccache
- name: industrial_ci
uses: 'ros-industrial/industrial_ci@master'
uses: 'tylerjw/industrial_ci@clang-tidy-modified-filter'
- name: upload test artifacts (on failure)
uses: actions/upload-artifact@v2
if: failure()
Expand All @@ -44,5 +70,13 @@ jobs:
path: ${{ env.BASEDIR }}/target_ws/**/test_results/**/*.xml
- name: upload codecov report
uses: codecov/codecov-action@v1
if: ${{ env.CCOV }}
with:
files: ${{ env.BASEDIR }}/coverage.info
- name: prepare target_ws for cache
if: ${{ always() && ! env.CCOV }}
run: |
du -sh ${{ env.BASEDIR }}/target_ws
sudo find ${{ env.BASEDIR }}/target_ws -wholename '*/test_results/*' -delete
sudo rm -rf ${{ env.BASEDIR }}/target_ws/src
du -sh ${{ env.BASEDIR }}/target_ws
172 changes: 172 additions & 0 deletions colcon_list_packages_changed_since.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env python3

# Copyright 2021 PickNik LLC
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the PickNik LLC nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


import argparse
import os
import subprocess
import sys


def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser(
description="List packages that have changed files since point in git history.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"path", help="<path> is the root of a git repo containing ros packages"
)
parser.add_argument("point", help="<point> is a git branch, tag, or commit")

group = parser.add_mutually_exclusive_group()
group.add_argument(
"--names-only",
"-n",
action="store_true",
default=False,
help="Output only the name of each package but not the path",
)
group.add_argument(
"--paths-only",
"-p",
action="store_true",
default=False,
help="Output only the path of each package but not the name",
)
args = parser.parse_args(argv)

if not os.path.isdir(os.path.join(args.path, ".git")):
print("'%s' is not the base of a git repo" % args.path, file=sys.stderr)
return 1

packages = get_packages_changed_since(args.path, args.point)

lines = []
for package in packages:
if args.names_only:
lines.append(package["name"])
elif args.paths_only:
lines.append(package["path"])
else:
lines.append(
"%s\t%s\t%s" % (package["name"], package["path"], package["type"])
)

lines.sort()
for line in lines:
print(line)

return 0


def find_executable(file_names):
paths = os.getenv("PATH").split(os.path.pathsep)
for file_name in file_names:
for path in paths:
file_path = os.path.join(path, file_name)
if os.path.isfile(file_path) and os.access(file_path, os.X_OK):
return file_path
return None


def get_packages_in_repo(repo_path):
bin_names = [
"colcon",
]
colcon_bin = find_executable(bin_names)
if not colcon_bin:
print(
"Could not find %s executable"
% " / ".join(["'%s'" % n for n in bin_names]),
file=sys.stderr,
)
return 1

cmd = [colcon_bin, "list", "--base-paths", repo_path]
output = []
try:
output = subprocess.check_output(cmd).strip().decode().split()
except subprocess.CalledProcessError as e:
print(
'The invocation of "%s" failed with error code %d: %s'
% (os.path.basename(colcon_bin), e.returncode, e),
file=sys.stderr,
)

return [
{"name": output[x], "path": output[x + 1], "type": output[x + 2]}
for x in range(0, len(output), 3)
]


def get_packages_changed_since(repo_path, point):
packages = get_packages_in_repo(repo_path)

bin_names = [
"git",
]
git_bin = find_executable(bin_names)
if not git_bin:
print(
"Could not find %s executable"
% " / ".join(["'%s'" % n for n in bin_names]),
file=sys.stderr,
)
return 1

def modified_files_test(package):
cmd = [
"git",
"diff",
"--name-only",
"--diff-filter=MA",
point + "..HEAD",
os.path.relpath(package["path"], repo_path),
]
modified_files = []
try:
modified_files = (
subprocess.check_output(cmd, cwd=repo_path).strip().decode().split()
)
except subprocess.CalledProcessError as e:
print(
'The invocation of "%s" failed with error code %d: %s'
% (os.path.basename(git_bin), e.returncode, " ".join(cmd)),
file=sys.stderr,
)
return False
return len(modified_files) > 0

filtered_packages = list(filter(modified_files_test, packages))
return filtered_packages


if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
namespace moveit_handeye_calibration
{
const std::string LOGNAME = "handeye_solver_default";
const std::string EXTRA_WORDS = "handeye_solver_default";

void HandEyeSolverDefault::initialize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ bool HandEyeCharucoTarget::initialize()
std::string dictionary_id;
double board_size_meters;
double marker_size_meters;
double not_used;

target_params_ready_ =
getParameter("squares, X", squares_x) && getParameter("squares, Y", squares_y) &&
Expand Down

0 comments on commit 3a67d3b

Please sign in to comment.