From defaf7f5e5cb9de95e14f05da313bd9a632a3b7b Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 8 Jan 2017 13:45:28 -0500 Subject: [PATCH] docker run helper script (#6270) --- .travis.yml | 6 ++---- Makefile | 28 ++++++++++++---------------- Tools/docker_run.sh | 15 +++++++++++++++ circle.yml | 7 ++----- 4 files changed, 31 insertions(+), 25 deletions(-) create mode 100755 Tools/docker_run.sh diff --git a/.travis.yml b/.travis.yml index 07119ae51c..a2cb7e9d83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: include: - os: linux sudo: required - env: GCC_VER=5.4 DOCKER_REPO="px4io/px4-dev-nuttx:2017-01-01" + env: GCC_VER=5.4 services: - docker - os: osx @@ -30,7 +30,6 @@ before_install: - if [[ "${TRAVIS_OS_NAME}" = "linux" && "${TRAVIS_BRANCH}" != "coverity" ]]; then cd ${TRAVIS_BUILD_DIR} && git fetch --unshallow && git fetch --all --tags - && docker pull ${DOCKER_REPO} ; elif [[ "${TRAVIS_OS_NAME}" = "linux" && "${TRAVIS_BRANCH}" == "coverity" ]]; then sudo apt-get install genromfs @@ -66,12 +65,11 @@ env: # AWS SECRET: $PX4_AWS_SECRET - secure: "h6oajlW68dWIr+wZhO58Dv6e68dZHrBLVA6lPXZmheFQBW6Xam1HuLGA0LOW6cL9TnrAsOZ8g4goB58eMQnMEijFZKi3mhRwZhd/Xjq/ZGJOWBUrLoQHZUw2dQk5ja5vmUlKEoQnFZjDuMjx8KfX5ZMNy8A3yssWZtJYHD8c+bk=" - PX4_AWS_BUCKET=px4-travis - - GIT_SUBMODULES_ARE_EVIL=1 script: - ccache -M 1GB; ccache -z - if [[ "${TRAVIS_OS_NAME}" = "linux" && "${TRAVIS_BRANCH}" != "coverity" ]]; then - PX4_DOCKER=1 make check_qgc_firmware; + ./Tools/docker_run.sh 'GIT_SUBMODULES_ARE_EVIL=1 make qgc_firmware'; elif [ "${TRAVIS_OS_NAME}" = "osx" ]; then make tests; fi diff --git a/Makefile b/Makefile index 228e48ced0..2bbadd6577 100644 --- a/Makefile +++ b/Makefile @@ -122,9 +122,9 @@ endif define cmake-build +@$(eval BUILD_DIR = $(SRC_DIR)/build_$@$(BUILD_DIR_SUFFIX)) +@if [ $(PX4_CMAKE_GENERATOR) = "Ninja" ] && [ -e $(BUILD_DIR)/Makefile ]; then rm -rf $(BUILD_DIR); fi -+@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && $(call PX4_RUN, cd $(BUILD_DIR); cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=$(1) $(CMAKE_ARGS)) || (rm -rf $(BUILD_DIR)); fi ++@if [ ! -e $(BUILD_DIR)/CMakeCache.txt ]; then mkdir -p $(BUILD_DIR) && cd $(BUILD_DIR) && cmake $(2) -G"$(PX4_CMAKE_GENERATOR)" -DCONFIG=$(1) $(CMAKE_ARGS) || (rm -rf $(BUILD_DIR)); fi +@echo "PX4 CONFIG: $(BUILD_DIR)" -+@$(call PX4_RUN,$(PX4_MAKE) -C "$(BUILD_DIR)" $(PX4_MAKE_ARGS) $(ARGS)) ++@$(PX4_MAKE) -C "$(BUILD_DIR)" $(PX4_MAKE_ARGS) $(ARGS) endef define colorecho @@ -279,23 +279,19 @@ unittest: posix_sitl_default @(cd build_unittest && ctest -j2 --output-on-failure) run_tests_posix: - @$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_default test_results) + $(MAKE) --no-print-directory posix_sitl_default test_results -tests: run_tests_posix - @$(call PX4_RUN,$(MAKE) --no-print-directory unittest) +tests: unittest run_tests_posix tests_coverage: - @$(call PX4_RUN,lcov --zerocounters --directory $(SRC_DIR) --quiet) - @$(call PX4_RUN,lcov --capture --initial --directory $(SRC_DIR) --quiet --output-file coverage.info) - @$(call PX4_RUN,$(MAKE) --no-print-directory unittest PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1 HEADLESS=1) - @$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_default test_results PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1 HEADLESS=1) - @$(call PX4_RUN,lcov --no-checksum --directory $(SRC_DIR) --capture --quiet --output-file coverage.info) - @$(call PX4_RUN,lcov --remove coverage.info '/usr/*' 'unittests/googletest/*' --quiet --output-file coverage.info) - @$(call PX4_RUN,genhtml --legend --show-details --function-coverage --quiet --output-directory coverage-html coverage.info) - @$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_default test_results_junit) - -test_startup_shutdown: - @$(call PX4_RUN,$(MAKE) --no-print-directory posix_sitl_test gazebo_standard_vtol HEADLESS=1 MEMORY_DEBUG=1) + @lcov --zerocounters --directory $(SRC_DIR) --quiet + @lcov --capture --initial --directory $(SRC_DIR) --quiet --output-file coverage.info + @$(MAKE) --no-print-directory unittest PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1 + @$(MAKE) --no-print-directory posix_sitl_default test_results PX4_CODE_COVERAGE=1 CCACHE_DISABLE=1 + @lcov --no-checksum --directory $(SRC_DIR) --capture --quiet --output-file coverage.info + @lcov --remove coverage.info '/usr/*' 'unittests/googletest/*' --quiet --output-file coverage.info + @genhtml --legend --show-details --function-coverage --quiet --output-directory coverage-html coverage.info + @$(MAKE) --no-print-directory posix_sitl_default test_results_junit scan-build: @export CCACHE_DISABLE=1 diff --git a/Tools/docker_run.sh b/Tools/docker_run.sh new file mode 100755 index 0000000000..29d48eb6ac --- /dev/null +++ b/Tools/docker_run.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +PWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +SRC_DIR=$PWD/../ + +CCACHE_DIR=${HOME}/.ccache +mkdir -p ${CCACHE_DIR} + +docker run -it --rm -w ${SRC_DIR} \ + -v ${SRC_DIR}:${SRC_DIR}:rw \ + -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ + -v ${CCACHE_DIR}:${CCACHE_DIR}:rw \ + -e CCACHE_DIR=${CCACHE_DIR} \ + -e LOCAL_USER_ID=`id -u` \ + px4io/px4-dev-nuttx:2017-01-07 /bin/bash -c "$@" diff --git a/circle.yml b/circle.yml index 9a02149534..6f99d060ec 100644 --- a/circle.yml +++ b/circle.yml @@ -14,15 +14,12 @@ dependencies: pre: - sudo pip install cpp-coveralls - sudo apt-get install -y lcov - - gem install coveralls-lcov test: override: - - mkdir -p ~/.ccache - - make distclean - - PX4_DOCKER=1 make tests + - ./Tools/docker_run.sh 'make tests' # copy test results for circleci #- mkdir -p $CIRCLE_TEST_REPORTS/junit/ && cp ./build_posix_sitl_default/JUnitTestResults.xml build_unittest/test_detail.xml $CIRCLE_TEST_REPORTS/junit/ #- mkdir -p $CIRCLE_ARTIFACTS && cp -R coverage-html $CIRCLE_ARTIFACTS # only post to coveralls if not a fork PR - #- if [ -z ${CIRCLE_PR_USERNAME}]; then cpp-coveralls -l coverage.info; fi + #- if [ -z ${CIRCLE_PR_USERNAME}]; then ./Tools/docker_run.sh 'cpp-coveralls -l coverage.info'; fi