Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into user/dfriend01/add-mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-5546 committed Oct 10, 2023
2 parents 971f09b + c2087b9 commit 2e68e86
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 79 deletions.
8 changes: 7 additions & 1 deletion .devcontainer/base-dev/base-dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/ubcsailbot/sailbot_workspace/pre-base:ros_humble-ompl_4c86b2f as base
FROM ghcr.io/ubcsailbot/sailbot_workspace/pre-base:ros_humble-ompl_4c86b2f-mongo_367-v2 as base

# install base apt dependencies
ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -22,6 +22,12 @@ RUN apt-get update \
&& rosdep init || echo "rosdep already initialized"
ENV DEBIAN_FRONTEND=

# install base pip dependencies
RUN pip3 install \
plotly \
pyproj \
shapely

# root bash configuration
ENV ROS_WORKSPACE=/workspaces/sailbot_workspace
COPY update-bashrc.sh /sbin/update-bashrc
Expand Down
28 changes: 25 additions & 3 deletions .devcontainer/config/sailbot_workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
{
"path": "../../src/boat_simulator"
},
{
"path": "../../src/controller"
},
{
"path": "../../src/custom_interfaces"
},
Expand All @@ -18,6 +21,9 @@
{
"path": "../../src/network_systems"
},
{
"path": "../../src/notebooks"
},
{
"path": "../../src/raye-local-pathfinding"
},
Expand All @@ -41,6 +47,7 @@
"cSpell.words": [
"athackst",
"autopep",
"bsoncxx",
"buildx",
"cmake",
"cppcheck",
Expand All @@ -54,6 +61,7 @@
"isort",
"kmph",
"mkdocs",
"mongocxx",
"mypy",
"noqa",
"OMPL",
Expand Down Expand Up @@ -124,6 +132,8 @@
"editor.formatOnSave": true,
"editor.rulers": [99],
},
"notebook.formatOnCellExecution": true,
"notebook.formatOnSave.enabled": true,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.extraPaths": [
"/workspaces/sailbot_workspace/install/lib/python3.10/site-packages",
Expand Down Expand Up @@ -178,6 +188,17 @@
"editor.rulers": [120],
},

"testMate.cpp.discovery.loadOnStartup": true,
// The following setting just changes the default prelaunch task from "build" to "debug"
"testMate.cpp.test.advancedExecutables": [
{
"pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
"runTask": {
"before": [ "debug" ]
}
}
],

// markdown
// copied from docs: https://github.com/UBCSailbot/docs/blob/main/.vscode/settings.json
"[markdown]": {
Expand Down Expand Up @@ -230,7 +251,8 @@
"request": "launch",
"program": "${workspaceFolder:sailbot_workspace}/install/lib/${input:node}",
"args": [],
"preLaunchTask": "Build All",
// Have testMate extension build before starting debug session to avoid building twice
// "preLaunchTask": "debug",
"stopAtEntry": false,
"cwd": "${workspaceFolder:sailbot_workspace}",
"externalConsole": false,
Expand Down Expand Up @@ -420,9 +442,9 @@
// Workspace editing tasks
{
"label": "clone source repositories",
"detail": "Clone the repositories specified in src/new_project.repos to src/",
"detail": "Clone the repositories specified in src/polaris.repos to src/",
"type": "shell",
"command": "vcs import < src/new_project.repos src --skip-existing",
"command": "vcs import < src/polaris.repos src --skip-existing",
"problemMatcher": []
},
{
Expand Down
19 changes: 18 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Sailbot Workspace",
"dockerComposeFile": [
// Uncomment the files containing the programs you need
// "docker-compose.db.yml", // mongodb
"docker-compose.db.yml", // mongodb
// "docker-compose.docs.yml", // docs
// "docker-compose.website.yml", // grafana, website

Expand All @@ -22,6 +22,20 @@
},
// Set *default* container specific settings.json values on container create.
"customizations": {
"codespaces": {
"repositories": {
"UBCSailbot/boat_simulator": {"permissions": "write-all"},
"UBCSailbot/controller": {"permissions": "write-all"},
"UBCSailbot/custom_interfaces": {"permissions": "write-all"},
"UBCSailbot/docs": {"permissions": "write-all"},
"UBCSailbot/local_pathfinding": {"permissions": "write-all"},
"UBCSailbot/network_systems": {"permissions": "write-all"},
"UBCSailbot/notebooks": {"permissions": "write-all"},
"UBCSailbot/raye-local-pathfinding": {"permissions": "write-all"},
"UBCSailbot/website": {"permissions": "write-all"},
"UBCSailbot/virtual_iridium": {"permissions": "write-all"}
}
},
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
Expand Down Expand Up @@ -60,14 +74,17 @@
"jeff-hykin.better-cpp-syntax",
"KevinRose.vsc-python-indent",
"llvm-vs-code-extensions.vscode-clangd",
"matepek.vscode-catch2-test-adapter",
"mongodb.mongodb-vscode",
"ms-iot.vscode-ros",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-vsliveshare.vsliveshare",
"ms-python.mypy-type-checker",
"njpwerner.autodocstring",
"stevejpurves.cucumber",
"streetsidesoftware.code-spell-checker",
"vscode-icons-team.vscode-icons",
"zxh404.vscode-proto3"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/pre-base/build-pre-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

docker buildx build . \
--file pre-base.Dockerfile \
--tag ghcr.io/ubcsailbot/sailbot_workspace/pre-base:ros_humble-ompl_4c86b2f \
--tag ghcr.io/ubcsailbot/sailbot_workspace/pre-base:ros_humble-ompl_4c86b2f-mongo_367-v2 \
--platform linux/arm64,linux/amd64 \
--push
43 changes: 40 additions & 3 deletions .devcontainer/pre-base/pre-base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
FROM ubuntu:22.04 AS ompl-source
FROM ubuntu:22.04 AS fix-certificates

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
ENV DEBIAN_FRONTEND=

FROM fix-certificates AS ompl-source

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
Expand All @@ -11,7 +22,7 @@ WORKDIR /ompl
RUN git reset --hard 4c86b2f

# From https://github.com/athackst/dockerfiles/blob/32a872348af0ad25ec4a6e6184cb803357acb6ab/ros2/humble.Dockerfile
FROM ubuntu:22.04 AS ros-pre-base
FROM fix-certificates AS ros-pre-base

ENV DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -55,7 +66,7 @@ ENV ROS_VERSION=2
ENV DEBIAN_FRONTEND=

# Based on https://github.com/ompl/ompl/blob/4c86b2fecf7084ae9073bf6a837176d0be169721/scripts/docker/ompl.Dockerfile
FROM ros-pre-base AS ompl-builder
FROM fix-certificates AS ompl-builder
# avoid interactive configuration dialog from tzdata, which gets pulled in
# as a dependency
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -99,6 +110,30 @@ RUN cmake \
&& ninja -j `nproc` \
&& ninja install

FROM fix-certificates AS mongo-cxx-driver-builder

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libmongoc-dev \
wget \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*

# setup MongoDB C++ Packages
# mongo-cxx-driver version must match libmongoc-dev version - see https://mongocxx.org/mongocxx-v3/installation/linux/
RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz \
&& tar -xzf mongo-cxx-driver-r3.6.7.tar.gz \
&& cd mongo-cxx-driver-r3.6.7/build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local \
&& cmake --build . \
&& cmake --build . --target install
ENV DEBIAN_FRONTEND=

FROM ros-pre-base as pre-base
LABEL org.opencontainers.image.source = "https://github.com/UBCSailbot/sailbot_workspace"

Expand All @@ -115,6 +150,7 @@ RUN apt-get update \
libboost-system-dev \
libeigen3-dev \
libflann-dev \
libmongoc-dev \
libode-dev \
libtriangle-dev \
ninja-build \
Expand All @@ -129,3 +165,4 @@ RUN apt-get update \
ENV DEBIAN_FRONTEND=

COPY --from=ompl-builder /usr /usr
COPY --from=mongo-cxx-driver-builder /usr/local /usr/local
5 changes: 1 addition & 4 deletions .devcontainer/website/website.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
# RUN su node -c "npm install -g <your-package-list-here>"

# Adapted from https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker
RUN mkdir -p /website/node_modules
WORKDIR /website
COPY src/website/package*.json ./
RUN npm install
EXPOSE 3005
CMD [ "npm", "run", "dev" ]
CMD npm install --legacy-peer-deps && npm run dev
25 changes: 22 additions & 3 deletions .github/actions/ament-lint/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
name: 'Ament Lint'
description: 'Ament Lint using devcontainer'

inputs:
linter:
description: 'The linter to run'
required: true
disable_vcs:
description: 'Whether to disable VCS cloning all repositories'
required: true

runs:
using: 'docker'
image: '../../../.devcontainer/Dockerfile'
entrypoint: ".github/actions/ament-lint/run.sh"
using: "composite"
steps:
- name: Build Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml build

- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export LINTER=${{ inputs.linter}} && export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/ament-lint/run.sh"
2 changes: 1 addition & 1 deletion .github/actions/ament-lint/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ source /opt/ros/${ROS_DISTRO}/setup.bash
cd src

# Exclude repos and files we don't want to lint
VALID_SRC_DIRS=$(ls | grep -v -e virtual_iridium -e docs -e raye-local-pathfinding -e new_project.repos)
VALID_SRC_DIRS=$(ls | grep -v -e virtual_iridium -e docs -e raye-local-pathfinding -e polaris.repos)
lint ${VALID_SRC_DIRS}
24 changes: 24 additions & 0 deletions .github/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Checkout Repositories'
description: 'Checkout the repositories depending on the inputs'

inputs:
repository:
description: 'The repository name: github.event.repository.name'
required: true

runs:
using: "composite"
steps:
- name: Checkout ROS package
if: ${{ inputs.repository != 'sailbot_workspace' }}
uses: actions/checkout@v4
with:
repository: UBCSailbot/${{ inputs.repository }}
path: src/${{ inputs.repository }}

- name: Checkout custom_interfaces ROS package
if: ${{ inputs.repository != 'sailbot_workspace' && inputs.repository != 'custom_interfaces' }}
uses: actions/checkout@v4
with:
repository: UBCSailbot/custom_interfaces
path: src/custom_interfaces
22 changes: 19 additions & 3 deletions .github/actions/clang-tidy/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
name: 'Clang-Tidy'
description: 'Clang-Tidy using devcontainer'

inputs:
disable_vcs:
description: 'Whether to disable VCS cloning all repositories'
required: true

runs:
using: 'docker'
image: '../../../.devcontainer/Dockerfile'
entrypoint: ".github/actions/clang-tidy/run.sh"
using: "composite"
steps:
- name: Build Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml build

- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/clang-tidy/run.sh"
22 changes: 19 additions & 3 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
name: 'Test'
description: 'Test using devcontainer'

inputs:
disable_vcs:
description: 'Whether to disable VCS cloning all repositories'
required: true

runs:
using: 'docker'
image: '../../../.devcontainer/Dockerfile'
entrypoint: ".github/actions/test/run.sh"
using: "composite"
steps:
- name: Build Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml build

- name: Run Containers
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml up -d

- name: Run Tests
shell: bash
run: docker-compose -f .devcontainer/docker-compose.yml -f .devcontainer/docker-compose.db.yml exec -T sailbot-workspace /bin/bash -c "export DISABLE_VCS=${{ inputs.disable_vcs }} && cd /workspaces/sailbot_workspace && .github/actions/test/run.sh"
Loading

0 comments on commit 2e68e86

Please sign in to comment.