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
4 changes: 3 additions & 1 deletion .devcontainer/append_to_bashrc.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Custom Alias
alias src='source /opt/ros/jazzy/setup.bash && source /home/ws/install/setup.bash'
alias build='/home/ws/docker/build.sh'
alias test='build && sudo /home/act -j test-locally'

# Integrate entrypoint.sh
source /home/ws/.devcontainer/entrypoint.sh
source /home/ws/docker/entrypoint.sh
99 changes: 51 additions & 48 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
{
"name": "ROS 2 Development Container HelMoRo",
"privileged": true,
"remoteUser": "htkz",
"build": {
"dockerfile": "../docker/Dockerfile",
"context": "..",
"target": "dev",
"args": {
"USERNAME": "htkz"
}
},
"workspaceFolder": "/home/ws",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ws,type=bind",
"customizations": {
"vscode": {
"extensions":[
"ms-vscode.cpptools",
"ms-vscode.cpptools-themes",
"donjayamanne.python-extension-pack",
"eamodio.gitlens",
"ms-iot.vscode-ros",
"ms-azuretools.vscode-docker",
"ms-vscode.cmake-tools",
"github.vscode-github-actions"
]
}
},
"containerEnv": {
"DISPLAY": "unix:0",
"ROS_AUTOMATIC_DISCOVERY_RANGE": "LOCALHOST",
"ROS_DOMAIN_ID": "42",
"NVIDIA_DRIVER_CAPABILITIES": "all"
},
"runArgs": [
"--net=host",
"--pid=host",
"--ipc=host",
"-e", "DISPLAY=${env:DISPLAY}",
"--gpus=all",
"--runtime=nvidia"
],
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
"source=/dev/dri,target=/dev/dri,type=bind,consistency=cached",
"source=/dev/input,target=/dev/input,type=bind,consistency=delegated",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"postCreateCommand": "sudo chown -R $(whoami) /home/ws/ && python3 /home/ws/.devcontainer/append_to_bashrc.py"
"name": "ROS 2 Development Container HelMoRo",
"privileged": true,
"remoteUser": "htkz",
"build": {
"dockerfile": "../docker/Dockerfile",
"context": "..",
"target": "dev",
"args": {
"USERNAME": "htkz"
},
"options": [
"--tag", "helmoro_dev"
]
},
"workspaceFolder": "/home/ws",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ws,type=bind",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-themes",
"donjayamanne.python-extension-pack",
"eamodio.gitlens",
"ms-iot.vscode-ros",
"ms-azuretools.vscode-docker",
"ms-vscode.cmake-tools",
"github.vscode-github-actions"
]
}
},
"containerEnv": {
"DISPLAY": "unix:0",
"ROS_AUTOMATIC_DISCOVERY_RANGE": "LOCALHOST",
"ROS_DOMAIN_ID": "42",
"NVIDIA_DRIVER_CAPABILITIES": "all"
},
"runArgs": [
"--net=host",
"--pid=host",
"--ipc=host",
"-e", "DISPLAY=${env:DISPLAY}",
"--gpus=all",
"--runtime=nvidia"
],
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
"source=/dev/dri,target=/dev/dri,type=bind,consistency=cached",
"source=/dev/input,target=/dev/input,type=bind,consistency=delegated",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"postCreateCommand": "sudo chown -R $(whoami) /home/ws/ && sudo chown -R $(whoami) /var/run/docker.sock && python3 /home/ws/.devcontainer/append_to_bashrc.py"
}
50 changes: 50 additions & 0 deletions .github/workflows/ci-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Image and Run Tests with act

on:
push:
branches:
- '!**' # Exclude all branches from triggering this workflow

jobs:
test-locally:
runs-on: ubuntu-latest
env:
IMAGE_NAME: test-image
CONTAINER_NAME: test-container

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

- name: Install Xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb

- name: Build Docker image and use local cache
run: docker build --file docker/Dockerfile --tag ${{ env.IMAGE_NAME }} --target prod .

- name: Start container
run: docker run --name ${{ env.CONTAINER_NAME }} --net host -v /tmp/.X11-unix:/tmp/.X11-unix -v /var/run/docker.sock:/var/run/docker.sock --detach ${{ env.IMAGE_NAME }} tail -f /dev/null

- name: Run test
shell: bash
run: |
set -e
echo "Starting virtual display (Xvfb)..."
Xvfb :99 -screen 0 1024x768x24 &
export DISPLAY=:99
export ROS_DOMAIN_ID=42

echo "Start testing..."
docker exec -e DISPLAY=$DISPLAY -e ROS_DOMAIN_ID=$ROS_DOMAIN_ID ${{ env.CONTAINER_NAME }} bash -c "
source ./entrypoint.sh &&
colcon test --executor sequential &&
colcon test-result --verbose
"

- name: Export logs to runner
shell: bash
run: docker cp ${{ env.CONTAINER_NAME }}:/home/ws/log ./log
if: always() # export logs even if tests fail
- name: Stop and remove container
run: docker stop -t 0 ${{ env.CONTAINER_NAME }} && docker rm ${{ env.CONTAINER_NAME }}
if: always()
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ RUN apt-get update && apt-get install -y \
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV RMW_CYCLONEDDS_URI=file:///home/ws/config/cyclonedds.xml

# Install act for local github actions execution
RUN mkdir -p /home/ws \
&& wget https://github.com/nektos/act/releases/download/v0.2.78/act_Linux_x86_64.tar.gz \
&& tar -xzf act_Linux_x86_64.tar.gz -C /home act \
&& rm act_Linux_x86_64.tar.gz

# ********************************************************
# * Set up the user *
# ********************************************************
Expand Down