diff --git a/.travis.yml b/.travis.yml index fe2a4dc2f..0bec5da85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,8 +37,9 @@ env: - ROS_DISTRO=indigo PRERELEASE=true USE_MOCKUP='industrial_ci/mockups/failing_test' EXPECT_EXIT_CODE=1 - ROS_DISTRO=kinetic PRERELEASE=true PRERELEASE_REPONAME=industrial_ci - ROS_DISTRO=indigo APTKEY_STORE_SKS=hkp://ha.pool.sks-keyservers.vet # Passing wrong SKS URL as a break test. Should still pass. - - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=debian - - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file # Using default file name for ROSINSTALL_FILENAME + - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=debian AFTER_SCRIPT='ccache 2> /dev/null && exit 1; [ "$?" = "127" ]' + # Using default file name for ROSINSTALL_FILENAME, test CCACHE, verify cache was filled + - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file CCACHE_DIR=$HOME/.ccache AFTER_SCRIPT='num=($(ccache -s | grep "files in cache")) && (( num[-1] > 0 ))' - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=file USE_DEB=true # Expected to fail. See https://github.com/ros-industrial/industrial_ci/pull/74 - ROS_DISTRO=indigo UPSTREAM_WORKSPACE=https://raw.githubusercontent.com/ros-industrial/industrial_ci/master/.travis.rosinstall - ROS_DISTRO=indigo USE_DEB=true # Checking backup compatibility with UPSTREAM_WORKSPACE diff --git a/doc/index.rst b/doc/index.rst index 666a82fec..ba8d29101 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -157,6 +157,7 @@ Note that some of these currently tied only to a single option, but we still lea * `CATKIN_CONFIG` (default: not set): `catkin config --install` is used by default and with this variable you can 1) pass additional config options, or 2) overwrite `--install` by `--no-install`. See more in `this section `_. * `CATKIN_PARALLEL_JOBS` (default: -p4): Maximum number of packages to be built in parallel that is passed to underlining build tool. As of Jan 2016, this is only enabled with `catkin_tools`. See for more detail about `number of build jobs `_ and `documentation of catkin_tools `_ that this env variable is passed to internally in `catkin-tools`. * `CATKIN_PARALLEL_TEST_JOBS` (default: -p4): Maximum number of packages which could be examined in parallel during the test run. If not set it's filled by `ROS_PARALLEL_JOBS`. +* `CCACHE_DIR` (default: not set): If set, `ccache `_ gets enabled for your build to speed up the subsequent builds in the same job if anything. See `detail. `_ * `CI_PARENT_DIR` (default: .ci_config): (NOT recommended to specify) This is the folder name that is used in downstream repositories in order to point to this repo. * `DOCKER_IMAGE` (default: not set): Selects a Docker images different from default one. Please note, this disables the handling of `ROS_REPOSITORY_PATH` and `ROS_DISTRO` as ROS needs already to be installed in the image. * `DOCKER_FILE` (default: not set): Instead of pulling an images from the Docker hub, build it from the given path or URL. Please note, this disables the handling of `ROS_REPOSITORY_PATH` and `ROS_DISTRO`, they have to be set in the build file instead. @@ -249,6 +250,37 @@ Reference: * `Discussion about install space `_ * `Detail for catkin config `_ for more info about `catkin-tools`. +Cache build artifacts to speed up the subsequent builds (if any) +---------------------------------------------------------------- + +If `CCACHE_DIR` is set (not set by default), `ccache `_ gets enabled for your build to speed up the subsequent builds in the same job if anything. +Recommended value is `$HOME/.ccache`, but any non-used directory works. + +https://docs.travis-ci.com/user/caching/#Arbitrary-directories + + * Enable cache. How to do so depends on the CI system of your choice. + + On Travis CI, add as follows (`refrence `_):: + + cache: + directories: + - $HOME/.ccache # can be any valid cache location + + + * Define `CCACHE_DIR` variable. You can apply to all of your jobs by something like below:: + + env: + global: + - CCACHE_DIR=$HOME/.ccache + matrix: + : + +Or define `CCACHE_DIR` per job. + +NOTE: + * Beware, if you use `run_ci `_, the files will be owned by root! + * Caching may not work for packages with "smaller" number of files (see also `this discussion `_). + Add repository-specific CI config in addition ---------------------------------------------------------------- diff --git a/industrial_ci/src/docker.sh b/industrial_ci/src/docker.sh index 486a587fd..b64b0f8ce 100644 --- a/industrial_ci/src/docker.sh +++ b/industrial_ci/src/docker.sh @@ -60,20 +60,23 @@ function ici_require_run_in_docker() { # (None) ####################################### function ici_run_cmd_in_docker() { + local run_opts=($DOCKER_RUN_OPTS) + #forward ssh agent into docker container local ssh_docker_opts=() if [ "$SSH_AUTH_SOCK" ]; then local auth_dir auth_dir=$(dirname "$SSH_AUTH_SOCK") - ssh_docker_opts=(-v "$auth_dir:$auth_dir" -e "SSH_AUTH_SOCK=$SSH_AUTH_SOCK") + run_opts+=(-v "$auth_dir:$auth_dir" -e "SSH_AUTH_SOCK=$SSH_AUTH_SOCK") fi - local run_opts=($DOCKER_RUN_OPTS) + if [ "$CCACHE_DIR" ]; then + run_opts+=(-v "$CCACHE_DIR:/root/.ccache" -e CCACHE_DIR=/root/.ccache) + fi local cid cid=$(docker create \ --env-file "${ICI_SRC_PATH}"/docker.env \ - "${ssh_docker_opts[@]}" \ "${run_opts[@]}" \ "$@") if [ -d ~/.ssh ]; then diff --git a/industrial_ci/src/tests/source_tests.sh b/industrial_ci/src/tests/source_tests.sh index 1112c34dc..7c0b45118 100644 --- a/industrial_ci/src/tests/source_tests.sh +++ b/industrial_ci/src/tests/source_tests.sh @@ -40,17 +40,24 @@ function catkin { /usr/bin/catkin "$cmd" -w "$CATKIN_WORKSPACE" "$@" } -ici_time_start setup_ros +ici_time_start setup_apt sudo apt-get update -qq # If more DEBs needed during preparation, define ADDITIONAL_DEBS variable where you list the name of DEB(S, delimitted by whitespace) if [ "$ADDITIONAL_DEBS" ]; then - sudo apt-get install -q -qq -y $ADDITIONAL_DEBS || error "One or more additional deb installation is failed. Exiting." + sudo apt-get install -qq -y $ADDITIONAL_DEBS || error "One or more additional deb installation is failed. Exiting." fi source /opt/ros/$ROS_DISTRO/setup.bash -ici_time_end # setup_ros +ici_time_end # setup_apt + +if [ "$CCACHE_DIR" ]; then + ici_time_start setup_ccache + sudo apt-get install -qq -y ccache || error "Could not install ccache. Exiting." + export PATH="/usr/lib/ccache:$PATH" + ici_time_end # setup_ccache +fi ici_time_start setup_rosdep