Skip to content

Commit

Permalink
Use Codespaces prebuilds (#3470)
Browse files Browse the repository at this point in the history
* Add commands to devcontainer

* Set builtin bash to be safe
https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425
https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/

* Setup workspace on create

* Revert use of set -u for bash
don't raise error due to variables
otherwise colcon setup.sh chokes from using an unbounded path variable

* Add safe.directory for git config
otherwise colcon cache errors out because of issues with git
due to complex user mapping magic that vscode does with devcontainers

https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor

also used by Moveit2:
moveit/moveit2#1994

https://github.blog/2022-04-12-git-security-vulnerability-announced/

* Set env using remoteEnv
instead of inlining them in scripts

* Revert to using the main tag
now that the tester stage has been replicated
with the new devcontainer script commands instead

* formating

* Scrap `-dev` image tag
and use codspaces prebuilds instead

* Build incrementally from update content command
by copying the build workspace steps from circleci config

* Adapt the build workspace steps for bash
  • Loading branch information
ruffsl authored and SteveMacenski committed Jun 9, 2023
1 parent 27c2d1e commit 5a6fda9
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 21 deletions.
8 changes: 7 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"name": "Nav2",
"image": "ghcr.io/ros-planning/navigation2:main-dev",
"image": "ghcr.io/ros-planning/navigation2:main",
"runArgs": [
"--privileged",
"--network=host"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/opt/overlay_ws/src/navigation2,type=bind",
"workspaceFolder": "/opt/overlay_ws/src",
"onCreateCommand": "navigation2/.devcontainer/on-create-command.sh",
"updateContentCommand": "navigation2/.devcontainer/update-content-command.sh",
"remoteEnv": {
"OVERLAY_MIXINS": "release ccache lld",
"CCACHE_DIR": "${containerEnv:OVERLAY_WS}/.ccache"
},
"features": {
// "ghcr.io/devcontainers/features/desktop-lite:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
Expand Down
19 changes: 19 additions & 0 deletions .devcontainer/on-create-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -exo pipefail

env

cd $OVERLAY_WS
. $UNDERLAY_WS/install/setup.sh

git config --global --add safe.directory "*"
colcon cache lock

colcon build \
--symlink-install \
--mixin $OVERLAY_MIXINS

sed --in-place \
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
/ros_entrypoint.sh
57 changes: 57 additions & 0 deletions .devcontainer/update-content-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

set -exo pipefail

env

cd $OVERLAY_WS

colcon cache lock

BUILD_UNFINISHED=$(
colcon list \
--names-only \
--packages-skip-build-finished \
| xargs)
echo BUILD_UNFINISHED: $BUILD_UNFINISHED

BUILD_FAILED=$(
colcon list \
--names-only \
--packages-select-build-failed \
| xargs)
echo BUILD_FAILED: $BUILD_FAILED

BUILD_INVALID=$(
colcon list \
--names-only \
--packages-select-cache-invalid \
--packages-select-cache-key build \
| xargs)
echo BUILD_INVALID: $BUILD_INVALID

BUILD_PACKAGES=""
if [ -n "$BUILD_UNFINISHED" ] || \
[ -n "$BUILD_FAILED" ] || \
[ -n "$BUILD_INVALID" ]
then
BUILD_PACKAGES=$(
colcon list \
--names-only \
--packages-above \
$BUILD_UNFINISHED \
$BUILD_FAILED \
$BUILD_INVALID \
| xargs)
fi
echo BUILD_PACKAGES: $BUILD_PACKAGES

colcon clean packages --yes \
--packages-select ${BUILD_PACKAGES} \
--base-select install

. $UNDERLAY_WS/install/setup.sh
colcon build \
--symlink-install \
--mixin $OVERLAY_MIXINS \
--packages-select ${BUILD_PACKAGES}
20 changes: 0 additions & 20 deletions .github/workflows/update_ci_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,3 @@ jobs:
- name: Image digest
if: steps.config.outputs.trigger == 'true'
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Build and push ${{ github.ref_name }}-dev
if: steps.config.outputs.trigger == 'true'
id: docker_build_dev
uses: docker/build-push-action@v4
with:
pull: true
push: true
cache-from: |
type=registry,ref=ghcr.io/ros-planning/navigation2:${{ github.ref_name }}
type=registry,ref=ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev
cache-to: type=inline
build-args: |
RUN_TESTS=True
target: tester
tags: |
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev-${{ steps.config.outputs.timestamp }}
- name: Image digest
if: steps.config.outputs.trigger == 'true'
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 5a6fda9

Please sign in to comment.