Skip to content

Commit 0f08104

Browse files
authored
Initialize rolling
0 parents  commit 0f08104

22 files changed

Lines changed: 1075 additions & 0 deletions

.devcontainer/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM althack/ros2:rolling-dev
2+
3+
# Set up dev packages
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
RUN apt-get update \
6+
&& apt-get -y install --no-install-recommends \
7+
bash-completion \
8+
git-core \
9+
openssh-client \
10+
python3-argcomplete \
11+
python3-colcon-common-extensions \
12+
python3-vcs2l \
13+
sudo \
14+
&& rm -rf /var/lib/apt/lists/*
15+
ENV DEBIAN_FRONTEND=dialog
16+
17+
# Set up auto-source of workspace for ros user
18+
ARG WORKSPACE
19+
ARG USERNAME=ros
20+
ARG USER_UID=1000
21+
ARG USER_GID=$USER_UID
22+
23+
# Find and replace any user with matching UID
24+
RUN set -eux; \
25+
existing_user=$(getent passwd "$USER_UID" | cut -d: -f1 || true); \
26+
if [ -n "$existing_user" ]; then \
27+
usermod -l $USERNAME -d /home/$USERNAME -m $existing_user && \
28+
groupmod -n $USERNAME $existing_user && \
29+
echo "Renamed $existing_user to $USERNAME"; \
30+
else \
31+
groupadd --gid $USER_GID $USERNAME && \
32+
useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME && \
33+
echo "Created new user $USERNAME"; \
34+
fi
35+
# Ensure necessary directories and permissions
36+
RUN mkdir -p /home/$USERNAME /run/user/$USER_UID && \
37+
chown -R $USER_UID:$USER_GID /home/$USERNAME /run/user/$USER_UID
38+
39+
# Add sudo support for the non-root user
40+
RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
41+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
42+
&& touch /home/$USERNAME/.sudo_as_admin_successful
43+
44+
# Set up autocompletion for user
45+
RUN echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc \
46+
&& echo "if [ -f /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash ]; then source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash; fi" >> /home/$USERNAME/.bashrc \
47+
&& echo "if [ -f /usr/share/vcs2l-completion/vcs.bash ]; then source /usr/share/vcs2l-completion/vcs.bash; fi" >> /home/$USERNAME/.bashrc \
48+
# Set up auto-source of workspace for ros user
49+
&& echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc

.devcontainer/devcontainer.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3+
{
4+
"dockerFile": "Dockerfile",
5+
"build": {
6+
"args": {
7+
"WORKSPACE": "${containerWorkspaceFolder}"
8+
},
9+
"options": ["--pull"]
10+
},
11+
"runArgs": [
12+
"--network=host",
13+
"--cap-add=SYS_PTRACE",
14+
"--security-opt=seccomp:unconfined",
15+
"--security-opt=apparmor:unconfined",
16+
"--volume=/tmp/.X11-unix:/tmp/.X11-unix",
17+
"--volume=/mnt/wslg:/mnt/wslg",
18+
"--ipc=host"
19+
// uncomment to use intel iGPU
20+
// "--device=/dev/dri"
21+
],
22+
"containerEnv": {
23+
"DISPLAY": "${localEnv:DISPLAY}", // Needed for GUI try ":0" for windows
24+
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}",
25+
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}",
26+
"PULSE_SERVER": "${localEnv:PULSE_SERVER}",
27+
"LIBGL_ALWAYS_SOFTWARE": "1" // Needed for software rendering of opengl
28+
},
29+
// Set *default* container specific settings.json values on container create.
30+
"customizations": {
31+
"vscode": {
32+
"extensions": [
33+
"althack.ament-task-provider",
34+
"betwo.b2-catkin-tools",
35+
"DotJoshJohnson.xml",
36+
"ms-azuretools.vscode-docker",
37+
"ms-python.autopep8",
38+
"ms-python.python",
39+
"ms-vscode.cpptools",
40+
"Ranch-Hand-Robotics.rde-pack",
41+
"redhat.vscode-yaml",
42+
"streetsidesoftware.code-spell-checker",
43+
"twxs.cmake",
44+
"yzhang.markdown-all-in-one",
45+
"zachflower.uncrustify"
46+
]
47+
}
48+
}
49+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import glob
2+
import os
3+
import subprocess
4+
import yaml
5+
6+
prefix="src"
7+
8+
def add_git_submodule(repo_name, repo_url, repo_version):
9+
subprocess.call(['git', 'submodule', 'add', '-b', repo_version, repo_url, repo_name])
10+
11+
def is_submodule(repo_name):
12+
try:
13+
subprocess.check_output(['git', 'submodule', 'status', repo_name], stderr=subprocess.DEVNULL)
14+
return True
15+
except subprocess.CalledProcessError:
16+
return False
17+
18+
def parse_repos_file(file_path):
19+
with open(file_path, 'r') as file:
20+
repos_data = yaml.safe_load(file)
21+
repositories = repos_data['repositories']
22+
23+
for repo_name, repo_info in repositories.items():
24+
if 'type' in repo_info and repo_info['type'] == 'git':
25+
repo_url = repo_info['url']
26+
repo_version = repo_info['version']
27+
submodule_name = os.path.join(prefix, repo_name)
28+
29+
if not is_submodule(submodule_name):
30+
add_git_submodule(submodule_name, repo_url, repo_version)
31+
print(f"Added {repo_name} as a submodule.")
32+
33+
# Find .repos files within the src directory
34+
repos_files = glob.glob('src/**/*.repos', recursive=True)
35+
36+
# Process each .repos file
37+
for repos_file in repos_files:
38+
parse_repos_file(repos_file)

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PYTHONPATH=src:install/lib/python3.12/site-packages

.github/actions/lint/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: 'Lint'
2+
description: 'Lint using devcontainer'
3+
runs:
4+
using: 'docker'
5+
image: '../../../.devcontainer/Dockerfile'
6+
entrypoint: ".github/actions/lint/run.sh"

.github/actions/lint/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
./setup.sh
5+
ament_${LINTER} src/

.github/actions/test/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: 'Test'
2+
description: 'Test using devcontainer'
3+
runs:
4+
using: 'docker'
5+
image: '../../../.devcontainer/Dockerfile'
6+
entrypoint: ".github/actions/test/run.sh"

.github/actions/test/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
./setup.sh
5+
./build.sh
6+
./test.sh

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10

.github/workflows/docs.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: docs
2+
3+
on:
4+
release:
5+
push:
6+
tags:
7+
- 'v*'
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Build and push docs
17+
uses: athackst/mkdocs-simple-plugin@v3.2.0

0 commit comments

Comments
 (0)