Skip to content

Commit

Permalink
WIP: ci: Add github action for basic CI
Browse files Browse the repository at this point in the history
tmp: Test

ci: Run entrypoint script

ci: Fix entrypoint execution on devcontainer entry

ci: Add GitHub container registry

ci: Split up GitHub Actions
  • Loading branch information
philipp-caspers committed Jun 13, 2024
1 parent db261c8 commit 1504fef
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ RUN echo "source /opt/ros/humble/setup.sh" >> /root/.bashrc
RUN . /opt/ros/humble/setup.sh && colcon build
RUN echo "source /ros_deps/install/setup.sh" >> /root/.bashrc

ENV CARGO_TERM_COLOR=always
ENV RUSTFLAGS="-Dwarnings"

RUN mkdir -p /workspace
WORKDIR /workspace

Expand All @@ -39,3 +42,4 @@ COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]
2 changes: 2 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"dockerfile": "Dockerfile"
},
"runArgs": ["-v", ".:/workspace"],
"overrideCommand": true,
"postStartCommand": ". /entrypoint.sh",
"customizations": {
"vscode": {
"extensions": [
Expand Down
5 changes: 4 additions & 1 deletion .devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

# Build the package mounted in the container
echo "Building workspace with colcon"
. /opt/ros/humble/setup.sh && . /ros_deps/install/setup.sh && colcon build
echo "source /workspace/install/setup.sh" >> /root/.bashrc
/bin/bash

# Run the CMD (either the default from the Dockerfile or the one provided as docker run argument)
exec "$@"
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on:
push:
pull_request:

jobs:
build_dev_container:
uses: ./.github/workflows/ci_build_dev_container.yml
build:
needs: build_dev_container
uses: ./.github/workflows/ci_build.yml
test:
needs: build_dev_container
uses: ./.github/workflows/ci_test.yml
lint:
needs: build_dev_container
uses: ./.github/workflows/ci_lint.yml

25 changes: 25 additions & 0 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI Build

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:

- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cargo build
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/vorausrobotik/voraus-ros-bridge-dev
runCmd: cargo build --verbose
25 changes: 25 additions & 0 deletions .github/workflows/ci_build_dev_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI build dev container

on:
workflow_call:

jobs:
build_dev_container:
runs-on: ubuntu-latest
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/vorausrobotik/voraus-ros-bridge-dev
cacheFrom: ghcr.io/vorausrobotik/voraus-ros-bridge-dev
push: always
25 changes: 25 additions & 0 deletions .github/workflows/ci_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI Lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:

- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cargo Clippy
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/vorausrobotik/voraus-ros-bridge-dev
runCmd: cargo clippy --all-targets --all-features
25 changes: 25 additions & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI Test

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
steps:

- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cargo test
uses: devcontainers/[email protected]
with:
imageName: ghcr.io/vorausrobotik/voraus-ros-bridge-dev
runCmd: cargo test --verbose
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![CI](https://github.com/vorausrobotik/voraus-ros-bridge/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/vorausrobotik/voraus-ros-bridge/actions/workflows/ci.yml)

# voraus-ros-bridge

Enables `voraus.core` integration within the ROS framework.
Expand Down

0 comments on commit 1504fef

Please sign in to comment.