diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ec44dd..8c06155 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ jobs: build: needs: build_dev_container uses: ./.github/workflows/ci_build.yml + build_release_image: + needs: build + uses: ./.github/workflows/ci_build_release_image.yml unit_test: needs: build_dev_container uses: ./.github/workflows/ci_unit_test.yml diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index cd53d5a..28965df 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -13,6 +13,15 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Cargo build uses: devcontainers/ci@v0.3 with: diff --git a/.github/workflows/ci_build_release_image.yml b/.github/workflows/ci_build_release_image.yml new file mode 100644 index 0000000..f87ff59 --- /dev/null +++ b/.github/workflows/ci_build_release_image.yml @@ -0,0 +1,34 @@ +name: CI Build Release Image +'on': + workflow_call: null +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Cargo build + uses: devcontainers/ci@v0.3 + with: + cacheFrom: ghcr.io/vorausrobotik/voraus-ros-bridge-dev + runCmd: cargo ament-build --install-base install/voraus-ros-bridge -- --release + push: never + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/vorausrobotik/voraus-ros-bridge + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci_format_code.yml b/.github/workflows/ci_format_code.yml index e7d1b22..2f4423b 100644 --- a/.github/workflows/ci_format_code.yml +++ b/.github/workflows/ci_format_code.yml @@ -7,5 +7,14 @@ jobs: steps: - name: Checkout (GitHub) uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Verify Code is formatted run: cargo fmt -- --check diff --git a/.github/workflows/ci_integration_test.yml b/.github/workflows/ci_integration_test.yml index 970c048..42de791 100644 --- a/.github/workflows/ci_integration_test.yml +++ b/.github/workflows/ci_integration_test.yml @@ -7,6 +7,15 @@ jobs: steps: - name: Checkout (GitHub) uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: diff --git a/.github/workflows/ci_lint.yml b/.github/workflows/ci_lint.yml index e8f5756..4b63d97 100644 --- a/.github/workflows/ci_lint.yml +++ b/.github/workflows/ci_lint.yml @@ -7,6 +7,15 @@ jobs: steps: - name: Checkout (GitHub) uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: diff --git a/.github/workflows/ci_unit_test.yml b/.github/workflows/ci_unit_test.yml index d989814..c61955b 100644 --- a/.github/workflows/ci_unit_test.yml +++ b/.github/workflows/ci_unit_test.yml @@ -7,6 +7,15 @@ jobs: steps: - name: Checkout (GitHub) uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2078812 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM ros:humble-ros-core@sha256:854e48183c14881767553657ca73602fe7bb5d7f265f744c5ea66ef88bb59955 +RUN mkdir /root/voraus-ros-bridge +COPY package.xml /root/voraus-ros-bridge/ +COPY ./install/voraus-ros-bridge/ /root/voraus-ros-bridge/install/ +COPY ./launch/* /root/voraus-ros-bridge/install/share/voraus-ros-bridge/ +COPY ./voraus_interfaces/install/voraus_interfaces/lib/* /opt/ros/humble/lib/ diff --git a/README.md b/README.md index 81ac091..0681789 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ Enables `voraus.core` integration within the ROS framework. +## Quick Start + +The easiest way to use the voraus ros bridge is to start it via the provided docker compose file. + +`docker compose up` + +Note that you have to run this command from within the directory where the `compose.yaml` is located. + ## Development This repository provides a dev container to streamline the development process. diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..5fe377b --- /dev/null +++ b/compose.yaml @@ -0,0 +1,7 @@ +services: + voraus_ros_bridge: + image: voraus-ros-bridge:0.1.0 + command: ros2 launch voraus-ros-bridge voraus-ros-bridge.launch.py + environment: + - AMENT_PREFIX_PATH=/root/voraus-ros-bridge/install:/opt/ros/humble + - ROS_NAMESPACE=robot1 diff --git a/launch/voraus-ros-bridge.launch.py b/launch/voraus-ros-bridge.launch.py new file mode 100644 index 0000000..9c119ee --- /dev/null +++ b/launch/voraus-ros-bridge.launch.py @@ -0,0 +1,16 @@ +import os +from launch import LaunchDescription +from launch_ros.actions import Node + + +def generate_launch_description(): + return LaunchDescription( + [ + Node( + package="voraus-ros-bridge", + namespace=os.environ.get("ROS_NAMESPACE", "robot1"), + executable="voraus-ros-bridge", + name="voraus_ros_bridge", + ) + ] + ) diff --git a/package.xml b/package.xml index b701118..8dc7a65 100644 --- a/package.xml +++ b/package.xml @@ -10,6 +10,8 @@ rosidl_runtime_rs voraus_interfaces + ros2launch + ament_cargo