diff --git a/.github/workflows/build-orbslam3-ws.yaml b/.github/workflows/build-orbslam3-ws.yaml index 76b9c405..14d41b13 100644 --- a/.github/workflows/build-orbslam3-ws.yaml +++ b/.github/workflows/build-orbslam3-ws.yaml @@ -8,6 +8,7 @@ on: - .github/workflows/build-orbslam3-ws.yaml - orbslam3_ws/docker/Dockerfile - orbslam3_ws/docker/.dockerignore + - orbslam3_ws/docker/.bashrc jobs: docker: diff --git a/orbslam3_ws/docker/.bashrc b/orbslam3_ws/docker/.bashrc new file mode 100644 index 00000000..0fc8a65e --- /dev/null +++ b/orbslam3_ws/docker/.bashrc @@ -0,0 +1,31 @@ +# Source global ROS2 environment +source /opt/ros/$ROS_DISTRO/setup.bash +# Optionally perform apt update if it has not been executed yet +if [ -z "$( ls -A '/var/lib/apt/lists' )" ]; then + echo "apt-get update has not been executed yet. Running sudo apt-get update..." + sudo apt-get update +fi +# Optionally perform rosdep update if it has not been executed yet +if [ ! -d $HOME/.ros/rosdep/sources.cache ]; then + echo "rosdep update has not been executed yet. Running rosdep update..." + rosdep update +fi +# Optionally build the workspace if it has not been built yet +if [ ! -f $ROS2_WS/install/setup.bash ]; then + echo "Workspace has not been built yet. Building workspace..." + cd $ROS2_WS + # Ref: https://docs.ros.org/en/humble/Tutorials/Intermediate/Rosdep.html + rosdep install --from-paths src --ignore-src -y -r + # TODO: If command `arch` outputs `aarch64`, consider adding `--packages-ignore ` to ignore x86 packages + # Ref: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html + if [ $(arch) == "aarch64" ]; then + colcon build --symlink-install + else + colcon build --symlink-install + fi + echo "Workspace built." +fi +# TODO: Source other workspace environments as underlay +source ~/test_ws/install/local_setup.bash +# Source workspace environment +source $ROS2_WS/install/setup.bash diff --git a/orbslam3_ws/docker/.dockerignore b/orbslam3_ws/docker/.dockerignore index 72e8ffc0..4901728d 100644 --- a/orbslam3_ws/docker/.dockerignore +++ b/orbslam3_ws/docker/.dockerignore @@ -1 +1,2 @@ * +!.bashrc diff --git a/tests/lint_comp_template.py b/tests/lint_comp_template.py index 45e962f7..7afe1ac4 100644 --- a/tests/lint_comp_template.py +++ b/tests/lint_comp_template.py @@ -84,6 +84,6 @@ def error(msg, i): compare_file_with_template(".devcontainer/devcontainer.json", ignored_workspaces=["ros1_bridge_ws"]) compare_file_with_template(".gitignore") compare_file_with_template("docker/.bashrc") -compare_file_with_template("docker/.dockerignore", ignored_workspaces=["ros1_bridge_ws", "orbslam3_ws"]) +compare_file_with_template("docker/.dockerignore", ignored_workspaces=["ros1_bridge_ws"]) compare_file_with_template("docker/compose.yaml", ignored_workspaces=["ros1_bridge_ws"]) compare_file_with_template("docker/Dockerfile", ignored_workspaces=["ros1_bridge_ws"]) diff --git a/tests/lint_filenames.py b/tests/lint_filenames.py index d307fb29..a09b7f98 100644 --- a/tests/lint_filenames.py +++ b/tests/lint_filenames.py @@ -21,8 +21,7 @@ for workspace_path in glob.glob(f"{repo_dir}/*_ws"): if not os.path.isfile(f"{workspace_path}/{filename}"): # Skip certain cases intentionally - if filename in (".gitignore", "docker/.bashrc") and os.path.basename(workspace_path) == "ros1_bridge_ws" or \ - filename in ("docker/.bashrc") and os.path.basename(workspace_path) == "orbslam3_ws": + if filename in (".gitignore", "docker/.bashrc") and os.path.basename(workspace_path) == "ros1_bridge_ws": continue # Report error raise ValueError(f"'{filename}' does not exist in: '{workspace_path}'")