Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Integrate GH actions CI/CD pipelines #21

Merged
merged 32 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
807c0f4
started docker then got distracted
evan-palmer Mar 3, 2023
cb036ae
split dev image from production images
evan-palmer Mar 3, 2023
3b5c36d
take 1
evan-palmer Mar 3, 2023
7f09b59
take 2
evan-palmer Mar 3, 2023
9f76b50
moving ci integration here to make docker updates easier
evan-palmer Mar 3, 2023
133d8b5
testing precommit pipeline
evan-palmer Mar 3, 2023
0e889df
take one on ci
evan-palmer Mar 3, 2023
240bd21
ran with wrong branch
evan-palmer Mar 3, 2023
347d6b4
attempt to use clang style config files
evan-palmer Mar 3, 2023
123aabb
another attempt at clang format
evan-palmer Mar 3, 2023
991f3a3
testing different version of clang tidy
evan-palmer Mar 3, 2023
4535e7f
testing to see if ici catches bug in test
evan-palmer Mar 3, 2023
9e764f3
attempt to disable clang format checks
evan-palmer Mar 3, 2023
6e35ad9
remove clang format from build tests in favor of pre-commit
evan-palmer Mar 3, 2023
eb705fd
weird things happening with tidy
evan-palmer Mar 3, 2023
8621608
weird things happening with tidy
evan-palmer Mar 3, 2023
daf7631
im tired and want to go to bed
evan-palmer Mar 3, 2023
3dcd892
im just guessing at this point
evan-palmer Mar 3, 2023
d0224b6
another random test
evan-palmer Mar 3, 2023
e28ab99
disable ici clang tidy in favor of other workflow
evan-palmer Mar 3, 2023
899916c
why
evan-palmer Mar 3, 2023
e0b6c0d
why
evan-palmer Mar 3, 2023
91c723c
why
evan-palmer Mar 3, 2023
6c2ed7e
pain
evan-palmer Mar 3, 2023
7177042
sad
evan-palmer Mar 3, 2023
7f3da27
this is as good as it's going to get
evan-palmer Mar 3, 2023
eae4a3e
put env variable in wrong spot
evan-palmer Mar 3, 2023
dd9857b
fixed readme. time for bed
evan-palmer Mar 3, 2023
eb145c6
fixed readme. time for bed
evan-palmer Mar 3, 2023
48cbb32
fixed readme. time for bed
evan-palmer Mar 3, 2023
d284e1a
removed test branch from ci pipeline. actually going to bed now
evan-palmer Mar 3, 2023
639d33a
Resolved PR comments
evan-palmer Mar 3, 2023
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
94 changes: 94 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
ARG ROS_DISTRO=rolling

FROM ros:$ROS_DISTRO as core

LABEL maintainer="Evan Palmer"
LABEL maintainer-email="[email protected]"

ENV DEBIAN_FRONTEND=noninteractive

# Install core apt dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils \
software-properties-common \
git \
wget \
gnupg2 \
lsb-release \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install core ROS dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-$ROS_DISTRO-robot-state-publisher \
ros-$ROS_DISTRO-xacro \
ros-$ROS_DISTRO-ros2-control \
ros-$ROS_DISTRO-ros2-controllers \
ros-$ROS_DISTRO-controller-manager \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

FROM core as ci

# Install CI apt dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
clang-format \
python3-dev \
python3-pip \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install debugging/linting Python packages
RUN pip3 install \
black \
flake8 \
isort \
pydocstyle \
pre-commit \
mypy

FROM ci as base

RUN apt-get update && apt-get install -y --no-install-recommends \
ros-$ROS_DISTRO-rviz2 \
ros-dev-tools \
ros-$ROS_DISTRO-moveit \
ros-$ROS_DISTRO-gazebo-ros-pkgs \
ros-$ROS_DISTRO-gazebo-ros2-control \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

FROM base as develop

RUN apt-get update && apt-get install -y --no-install-recommends \
iputils-ping \
net-tools \
lsb-release \
gdb \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Configure a new non-root user
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

ARG WORKSPACE
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc
RUN echo "export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${WORKSPACE}/" >> /home/$USERNAME/.bashrc
RUN echo "source /usr/share/gazebo/setup.sh" >> /home/$USERNAME/.bashrc
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"dockerFile": "../.docker/Dockerfile",
"dockerFile": "Dockerfile",
"build": {
"args": {
"WORKSPACE": "${containerWorkspaceFolder}"
"WORKSPACE": "${containerWorkspaceFolder}",
"ROS_DISTRO": "humble"
}
},
"remoteUser": "dev",
Expand Down
91 changes: 35 additions & 56 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,77 +1,56 @@
FROM ros:humble as base
ARG ROS_DISTRO=rolling
FROM ros:$ROS_DISTRO-ros-base as ci

LABEL maintainer="Evan Palmer"
LABEL maintainer-email="[email protected]"
LABEL license="MIT"

ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /root/ws_alpha

# Install general apt dependencies
COPY . src/alpha

# Install the core apt packages
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils \
software-properties-common \
git \
wget \
gnupg2 \
lsb-release \
curl \
sudo \
clang \
clang-format-14 \
clang-tidy \
clang-tools \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install required ROS dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-humble-rviz2 \
ros-dev-tools \
ros-humble-moveit \
ros-humble-robot-state-publisher \
ros-humble-xacro \
ros-humble-ros2-control \
ros-humble-ros2-controllers \
ros-humble-controller-manager \
ros-humble-gazebo-ros-pkgs \
ros-humble-gazebo-ros2-control \
# Install the alpha driver dependencies
RUN apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive \
rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& rm -rf src \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

FROM base as develop
FROM ci as source

RUN apt-get update && apt-get install -y --no-install-recommends \
iputils-ping \
net-tools \
lsb-release \
gdb \
clang-format \
python3-dev \
python3-pip \
ENV ROS_UNDERLAY /root/ws_alpha/install
WORKDIR $ROS_UNDERLAY/..

COPY . src/alpha

RUN apt-get update \
&& rosdep update \
&& DEBIAN_FRONTEND=noninteractive \
rosdep install -y --from-paths src --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install debugging/linting Python packages
RUN pip3 install \
black \
flake8 \
isort \
pydocstyle \
mypy

# Configure a new non-root user
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc

ARG WORKSPACE
RUN echo "if [ -f ${WORKSPACE}/install/setup.bash ]; then source ${WORKSPACE}/install/setup.bash; fi" >> /home/$USERNAME/.bashrc
RUN echo "export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${WORKSPACE}/" >> /home/$USERNAME/.bashrc
RUN echo "source /usr/share/gazebo/setup.sh" >> /home/$USERNAME/.bashrc
RUN . "/opt/ros/${ROS_DISTRO}/setup.sh" \
&& colcon build \
--cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
--ament-cmake-args -DCMAKE_BUILD_TYPE=Release \
--event-handlers desktop_notification- status- \
# Update /ros_entrypoint.sh to source the new workspace
&& sed -i "s#/opt/ros/\$ROS_DISTRO/setup.bash#$ROS_UNDERLAY/setup.sh#g" /ros_entrypoint.sh
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ignore everything
*

# except the following
!alpha_bringup
!alpha_description
!alpha_driver
!alpha_hardware
45 changes: 45 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Continuous Integration

on:
push:
branches:
- main
workflow_dispatch:

env:
CLANG_TIDY: true

jobs:
test:
name: Test Implementation
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
env:
- IMAGE: rolling-ci
ROS_DISTRO: rolling
- IMAGE: humble-ci
ROS_DISTRO: humble
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Log into registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run ROS Industrial CI
uses: ros-industrial/industrial_ci@master
env:
DOCKER_IMAGE: ghcr.io/evan-palmer/alpha:${{ matrix.env.IMAGE }}
CXXFLAGS: >-
-Wall -Wextra -Wpedantic -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls
CC: ${{ env.CLANG_TIDY && 'clang' }}
CXX: ${{ env.CLANG_TIDY && 'clang++' }}
99 changes: 99 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Docker

on:
schedule:
- cron: "0 17 * * 6"
push:
branches:
- main
pull_request:
paths:
- .docker/**
- .github/workflows/docker.yaml
workflow_dispatch:

env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'evan-palmer/alpha') }}

jobs:
ci:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble, rolling]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}

source:
strategy:
fail-fast: false
matrix:
ROS_DISTRO: [humble, rolling]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log into registry
if: env.PUSH == 'true'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
if: env.PUSH == 'true'
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ matrix.ROS_DISTRO }}-${{ github.job }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: .docker/Dockerfile
build-args: ROS_DISTRO=${{ matrix.ROS_DISTRO }}
target: ${{ github.job }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ env.PUSH }}
Loading