forked from allenh1/rplidar_ros
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request allenh1#7 from tiiuae/new_build_scripts
New build scripts
- Loading branch information
Showing
13 changed files
with
562 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: tii-rplidar | ||
|
||
on: | ||
push: | ||
branches: new_ros2 | ||
tags: | ||
- 'v*' | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
- v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+ | ||
pull_request: | ||
branches: [ new_ros2 ] | ||
|
||
jobs: | ||
tii-rplidar: | ||
runs-on: ubuntu-latest | ||
services: | ||
registry: | ||
image: registry:2 | ||
ports: | ||
- 5000:5000 | ||
steps: | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
driver-opts: network=host | ||
|
||
- name: Build the builder container image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile.build_env | ||
push: true | ||
tags: localhost:5000/tiiuae/rplidar:build_env | ||
build-args: | | ||
PACKAGE_NAME=rplidar | ||
ROS_DISTRO=foxy | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ghcr.io/tiiuae/tii-rplidar | ||
tags: | | ||
type=ref,event=branch | ||
type=semver,pattern={{version}} | ||
type=sha | ||
type=raw,value=latest | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
if: github.event_name == 'push' | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.GCR_PACKAGES_USER }} | ||
password: ${{ secrets.GCR_PACKAGES_TOKEN }} | ||
|
||
- name: Build tii-rplidar image and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
build-args: | | ||
PACKAGE_NAME=rplidar | ||
ROS_DISTRO=foxy | ||
FROM_IMAGE=localhost:5000/tiiuae/rplidar:build_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# fog-sw BUILDER | ||
ARG FROM_IMAGE | ||
FROM $FROM_IMAGE as fog-sw-builder | ||
ARG ROS_DISTRO="galactic" | ||
ARG UID=1000 | ||
ARG GID=1000 | ||
ARG PACKAGE_NAME | ||
|
||
WORKDIR /$PACKAGE_NAME/main_ws | ||
USER root | ||
ADD . /$PACKAGE_NAME/main_ws/src | ||
RUN chown -R builder:builder /$PACKAGE_NAME/main_ws | ||
|
||
USER builder | ||
|
||
RUN if [ -e /$PACKAGE_NAME/deps_ws ]; then \ | ||
. /$PACKAGE_NAME/deps_ws/install/setup.sh && \ | ||
colcon build; \ | ||
elif [ -e /opt/ros/${ROS_DISTRO}/setup.sh ]; then \ | ||
. /opt/ros/${ROS_DISTRO}/setup.sh && \ | ||
colcon build; \ | ||
fi | ||
|
||
RUN sed --in-place \ | ||
's|^source .*|source "/'$PACKAGE_NAME'/main_ws/install/setup.bash"|' \ | ||
/$PACKAGE_NAME/entrypoint.sh && \ | ||
chmod +x /$PACKAGE_NAME/entrypoint.sh | ||
|
||
ENV PACKAGE_NAME $PACKAGE_NAME | ||
WORKDIR /$PACKAGE_NAME | ||
ENTRYPOINT "/"$PACKAGE_NAME"/entrypoint.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# fog-sw BUILDER | ||
ARG ROS_DISTRO="galactic" | ||
FROM ros:${ROS_DISTRO}-ros-base as fog-sw-builder | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
ARG BUILD_NUMBER | ||
ARG COMMIT_ID | ||
ARG GIT_VER | ||
ARG PACKAGE_NAME | ||
# Install build dependencies | ||
RUN apt-get update -y && apt-get install -y --no-install-recommends \ | ||
curl \ | ||
python3-bloom \ | ||
fakeroot \ | ||
dh-make \ | ||
libboost-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN groupadd -g $GID builder && \ | ||
useradd -m -u $UID -g $GID -g builder builder && \ | ||
usermod -aG sudo builder && \ | ||
echo 'builder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | ||
|
||
RUN echo "deb [trusted=yes] https://ssrc.jfrog.io/artifactory/ssrc-debian-public-remote focal fog-sw" >> /etc/apt/sources.list | ||
|
||
RUN mkdir -p /$PACKAGE_NAME/packaging | ||
|
||
COPY packaging/rosdep.yaml* packaging/rosdep.sh packaging/build_deps.sh /$PACKAGE_NAME/packaging/ | ||
COPY underlay.repos package.xml /$PACKAGE_NAME/packaging/ | ||
COPY entrypoint.sh* /$PACKAGE_NAME/ | ||
|
||
RUN /$PACKAGE_NAME/packaging/rosdep.sh /$PACKAGE_NAME | ||
|
||
RUN chown -R builder:builder /$PACKAGE_NAME | ||
|
||
USER builder | ||
|
||
RUN rosdep update | ||
|
||
RUN /$PACKAGE_NAME/packaging/build_deps.sh /$PACKAGE_NAME | ||
|
||
VOLUME /$PACKAGE_NAME/sources | ||
WORKDIR /$PACKAGE_NAME/sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -euxo pipefail | ||
|
||
output_dir=$1 | ||
|
||
git_commit_hash=${2:-$(git rev-parse HEAD)} | ||
|
||
git_version_string=${3:-$(git log --date=format:%Y%m%d --pretty=~git%cd.%h -n 1)} | ||
|
||
build_number=${GITHUB_RUN_NUMBER:=0} | ||
|
||
ros_distro=${ROS_DISTRO:=foxy} | ||
|
||
iname=${PACKAGE_NAME:=rplidar_ros2} | ||
|
||
iversion=${PACKAGE_VERSION:=latest} | ||
|
||
docker build \ | ||
--build-arg UID=$(id -u) \ | ||
--build-arg GID=$(id -g) \ | ||
--build-arg ROS_DISTRO=${ros_distro} \ | ||
--build-arg PACKAGE_NAME=${iname} \ | ||
--pull \ | ||
-f Dockerfile.build_env -t "${iname}_build:${iversion}" . | ||
|
||
docker run \ | ||
--rm \ | ||
-v $(pwd):/${iname}/sources \ | ||
${iname}_build:${iversion} \ | ||
./packaging/package.sh \ | ||
-b ${build_number} \ | ||
-g ${git_commit_hash} \ | ||
-v ${git_version_string} | ||
|
||
mkdir -p ${output_dir} | ||
cp *.deb *.ddeb ${output_dir} | ||
rm -Rf *.deb *.ddeb | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
source /opt/ros/foxy/setup.bash | ||
ros2 launch rplidar_ros2 sensors_launch.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
mod_dir=${1} | ||
|
||
# Extract not satisfied dependencies from output, check if they are exist in ../underlay.repos | ||
if rosdep check --from-paths ${mod_dir} 1> /dev/null 2>&1; then | ||
echo "[INFO] Dependencies are satisfied." | ||
else | ||
echo "[INFO] Building dependencies using underlay.repos." | ||
cd ${mod_dir} | ||
|
||
echo "[INFO] Get package dependencies." | ||
# Dependencies from fog-sw repo | ||
if [ -e ${mod_dir}/ros2_ws/src ]; then | ||
echo "[INFO] Use dependencies from fog_sw." | ||
pushd ${mod_dir}/ros2_ws > /dev/null | ||
source /opt/ros/${ROS_DISTRO}/setup.bash | ||
else | ||
echo "[INFO] Use dependencies from local repository." | ||
mkdir -p ${mod_dir}/deps_ws/src | ||
pushd ${mod_dir}/deps_ws > /dev/null | ||
vcs import src < ${mod_dir}/packaging/underlay.repos | ||
rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO} | ||
source /opt/ros/${ROS_DISTRO}/setup.bash | ||
fi | ||
|
||
rosdep_out=$(rosdep check -v --from-paths src 2>&1 | grep "resolving for resources" ) | ||
ALL_PKGS=$(echo $rosdep_out | sed 's/.*\[\(.*\)\].*/\1/' | tr ',' '\n' | tr -d ' ') | ||
echo "[INFO] All packages: $(echo $ALL_PKGS|tr '\n' ' ')" | ||
PKGS_TO_BUILD="" | ||
pushd src > /dev/null | ||
|
||
for pkg_name in ${ALL_PKGS}; do | ||
echo "[INFO] Check if package ${pkg_name} is in the list of packages to build." | ||
pkg_name=$(echo ${pkg_name} | sed 's/\/$//') | ||
if ! ros2 pkg list | grep ${pkg_name} 1> /dev/null 2>&1; then | ||
PKGS_TO_BUILD="${PKGS_TO_BUILD} ${pkg_name}" | ||
fi | ||
done | ||
|
||
echo "[INFO] Packages to build: $PKGS_TO_BUILD" | ||
popd > /dev/null | ||
|
||
echo "[INFO] Build package dependencies." | ||
colcon build --packages-select ${PKGS_TO_BUILD} | ||
popd > /dev/null | ||
fi | ||
|
||
|
Oops, something went wrong.