Skip to content

Instantly share code, notes, and snippets.

@ruffsl
Last active October 19, 2021 05:16
Show Gist options
  • Save ruffsl/b2b567995810c69866221f659d52e71e to your computer and use it in GitHub Desktop.
Save ruffsl/b2b567995810c69866221f659d52e71e to your computer and use it in GitHub Desktop.
Colcon cache & clean demo

Recorded demo:
https://asciinema.org/a/XGRsVTuQ6QAXe5nM4bpDxsRNh

Setup an example colcon workspace:

mkdir -p ~/ws/src && cd ~/ws
wget https://raw.githubusercontent.com/colcon/colcon.readthedocs.org/main/colcon.repos
vcs import src < colcon.repos

First, lock, build and then test the workspace:

colcon cache lock
colcon build
colcon test

Next, modify any workspace packages, updating cache lock files afterwards:

echo "#foo" >> src/colcon-cmake/setup.py
echo "#bar" >> src/colcon-package-information/setup.py
colcon cache lock

Then, clean workpsace install base paths for invalidated package builds:

colcon clean packages \
    --packages-select-cache-invalid \
    --packages-select-cache-key build \
    --base-select install

Finally, rebuild and retest, while skipping packages with valid caches:

colcon build --packages-skip-cache-valid
colcon test  --packages-skip-cache-valid
FROM ros:rolling
RUN apt-get update && \
apt-get install -y \
fish \
python3-pip \
wget \
&& pip3 install \
asciinema \
scspell3k \
git+https://github.com/ruffsl/colcon-cache.git \
git+https://github.com/ruffsl/colcon-clean.git \
&& rm -rf /var/lib/apt/lists/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment