Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/devel_docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit tests run in CI

on:
push:
branches:
- main
- jazzy
- jazzy-dev

pull_request:
branches:
- main
- jazzy
- jazzy-dev

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

env:
ROS_DOMAIN_ID: 88
jobs:
unit-tests:
runs-on: ubuntu-24.04

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Pre-build docker image
run: |
./docker/run.sh --build -- echo "We have a working image!"

- name: Build code and run tests
run: |
./docker/run.sh --build -- bash -c ' \
rm -rf build/* install/* log/* && \
colcon build --symlink-install && \
. install/setup.bash && \
colcon test && \
echo "CI test runner completed." '
4 changes: 4 additions & 0 deletions .github/workflows/ros2-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
pull_request:
branches:
- ros2
- jazzy
- jazzy-dev
push:
branches:
- ros2
- jazzy
- jazzy-dev

jobs:

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.swp
.vscode/
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Run against all the files: pre-commit run -a
# Install the git hook scripts: pre-commit install

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-yaml
args: [--unsafe]
- id: check-xml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
exclude: ^\.clang-format$

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.3
hooks:
- id: clang-format

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--skip-string-normalization]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-lint
128 changes: 128 additions & 0 deletions docker/Dockerfile.jazzy
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
FROM ubuntu:noble AS package_xml_files_cacher

WORKDIR /ws/src

COPY . project/

RUN mkdir -p /tmp/ws/src \
&& find ./ -name "package.xml" | xargs cp --parents -t /tmp/ws/src \
&& find ./ -name "COLCON_IGNORE" | xargs cp --parents -t /tmp/ws/src \
|| true

FROM ubuntu:noble AS vesc_service_image_base

ARG USER=developer
ARG GROUP=developer

ENV ROS_DISTRO=jazzy

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /root

RUN apt update \
&& apt install --no-install-recommends -y \
adduser \
bash-completion \
ccache \
curl \
git \
htop \
locate \
mc \
nano \
psmisc \
python-is-python3 \
python3-pip \
python3-venv \
screen \
sudo \
tmux \
vim \
wget \
xterm \
&& rm -rf /var/lib/apt/lists/*

RUN apt update \
&& apt install -y \
tzdata \
&& ln -fs /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*

FROM vesc_service_image_base AS vesc_service_image_devel

RUN apt update && sudo apt install curl -y \
&& export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}') \
&& curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo ${UBUNTU_CODENAME:-${VERSION_CODENAME}})_all.deb" \
&& sudo dpkg -i /tmp/ros2-apt-source.deb \
&& rm -rf /var/lib/apt/lists/*

RUN apt update \
&& apt install --no-install-recommends -y \
ros-$ROS_DISTRO-ros-base \
ros-dev-tools \
&& rm -rf /var/lib/apt/lists/*

RUN userdel ubuntu \
&& addgroup --gid 1000 $GROUP \
&& adduser --uid 1000 --ingroup $GROUP --home /home/$USER --shell /bin/bash --disabled-password --gecos "" $USER \
&& adduser $USER sudo \
&& adduser $USER dialout \
&& echo "$USER ALL=NOPASSWD: ALL" >> /etc/sudoers.d/$USER

USER $USER:$GROUP

ENV USER_WS /home/$USER/ws
RUN mkdir -p $USER_WS/src

WORKDIR $USER_WS

ENV PIP_BREAK_SYSTEM_PACKAGES=1

RUN colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml \
&& colcon mixin update default

COPY --chown=$USER:$GROUP docker/files/colcon_defaults.yaml /home/$USER/.colcon/defaults.yaml

#
# Install the project's dependencies

RUN sudo rosdep init && rosdep update

COPY --from=package_xml_files_cacher --chown=$USER:$GROUP /tmp/ws/ $USER_WS/
RUN /bin/bash -c '\
sudo apt update \
&& rosdep install -i -y --from-path src \
&& sudo rm -rf /var/lib/apt/lists/*'

#
# Fixuid setup

COPY --chown=root:root docker/files/fixuid_config.yml /etc/fixuid/config.yml
RUN /bin/bash -c '\
ARCH=`uname -m` && if [ "$ARCH" == "aarch64" ]; then FIXUID_ARCH="arm64"; else FIXUID_ARCH="amd64"; fi \
&& curl -SsL https://github.com/boxboat/fixuid/releases/download/v0.6.0/fixuid-0.6.0-linux-$FIXUID_ARCH.tar.gz | sudo tar -C /usr/local/bin -xzf - \
&& sudo chmod 4755 /usr/local/bin/fixuid \
&& cd /etc/fixuid \
&& sudo sed -i "s/_USER_/$USER/" config.yml \
&& sudo sed -i "s/_GROUP_/$GROUP/" config.yml \
&& echo Done installing fixuid for $FIXUID_ARCH'

#
# Final setup of the workspace


RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /home/$USER/.bashrc

RUN mkdir -p $USER_WS/persistence && chmod 777 $USER_WS/persistence

RUN sudo updatedb && sudo apt update

ENV WITHIN_DEV=1

COPY --chown=root:root docker/files/fixuid_wrapper.sh /fixuid_wrapper.sh
COPY --chown=root:root docker/files/entrypoint.sh /ros_entrypoint.sh

CMD ["/bin/bash"]
ENTRYPOINT ["/fixuid_wrapper.sh", "fixuid", "-q", "/ros_entrypoint.sh"]
27 changes: 27 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
vesc_devel_base:
build:
context: ..
dockerfile: docker/Dockerfile.${ROS_DISTRO}
target: vesc_service_image_devel
environment:
- DISPLAY
- QT_X11_NO_MITSHM=1
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0}
- XAUTHORITY=/tmp/.docker.xauth
stdin_open: true
tty: true
user: ${USERID:-1000}:${GROUPID:-1000}
volumes:
- ..:/home/developer/ws/src/project
- /dev:/dev
- /tmp:/tmp:rw
- vesc_persistence:/home/developer/ws/persistence

vesc_devel:
extends:
service: vesc_devel_base
network_mode: host

volumes:
vesc_persistence:
5 changes: 5 additions & 0 deletions docker/files/colcon_defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build": {
"mixin": [ "ccache" ]
}
}
48 changes: 48 additions & 0 deletions docker/files/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo "Missing command line argument"
echo "Usage: $(basename $0) <command>"
exit 1
fi

mkdir -p $USER_WS/persistence/$(id -u)/cache
mkdir -p $USER_WS/persistence/$(id -u)/ccache
mkdir -p $USER_WS/persistence/$(id -u)/install
mkdir -p $USER_WS/persistence/$(id -u)/build

rm -rf $HOME/.cache
rm -rf $HOME/.ccache

ln -s $USER_WS/persistence/$(id -u)/cache $HOME/.cache
ln -s $USER_WS/persistence/$(id -u)/ccache $HOME/.ccache
ln -s $USER_WS/persistence/$(id -u)/install $USER_WS/install
ln -s $USER_WS/persistence/$(id -u)/build $USER_WS/build


# if bash_history is not a symlink or if it does not exist, remove it and create a new symlink
if [ ! -h "$HOME/.bash_history" ]; then
if [ -f "$HOME/.bash_history" ]; then
rm $HOME/.bash_history
fi
touch $USER_WS/persistence/$(id -u)/.bash_history
ln -s $USER_WS/persistence/$(id -u)/.bash_history $HOME/.bash_history
fi

if [ ! -f "$USER_WS/persistence/$(id -u)/COLCON_IGNORE" ]; then
touch $USER_WS/persistence/$(id -u)/COLCON_IGNORE
fi

. /opt/ros/$ROS_DISTRO/setup.bash

ros2 daemon start

echo
echo "ROS_DISTRO : $ROS_DISTRO"
echo "ROS_DOMAIN_ID : $ROS_DOMAIN_ID"
echo

# set the flag indicating that fixuid is done
touch fixuid_complete

exec "$@"
4 changes: 4 additions & 0 deletions docker/files/fixuid_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
user: _USER_
group: _GROUP_
paths:
- /home
13 changes: 13 additions & 0 deletions docker/files/fixuid_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo "Missing command line argument"
echo "Usage: $(basename "$0") <command>"
exit 1
fi

echo
echo "Starting docker container..."
echo

exec "$@"
Loading
Loading