Skip to content

Commit 5a6fda9

Browse files
ruffslSteveMacenski
authored andcommitted
Use Codespaces prebuilds (#3470)
* 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
1 parent 27c2d1e commit 5a6fda9

File tree

4 files changed

+83
-21
lines changed

4 files changed

+83
-21
lines changed

.devcontainer/devcontainer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
22
"name": "Nav2",
3-
"image": "ghcr.io/ros-planning/navigation2:main-dev",
3+
"image": "ghcr.io/ros-planning/navigation2:main",
44
"runArgs": [
55
"--privileged",
66
"--network=host"
77
],
88
"workspaceMount": "source=${localWorkspaceFolder},target=/opt/overlay_ws/src/navigation2,type=bind",
99
"workspaceFolder": "/opt/overlay_ws/src",
10+
"onCreateCommand": "navigation2/.devcontainer/on-create-command.sh",
11+
"updateContentCommand": "navigation2/.devcontainer/update-content-command.sh",
12+
"remoteEnv": {
13+
"OVERLAY_MIXINS": "release ccache lld",
14+
"CCACHE_DIR": "${containerEnv:OVERLAY_WS}/.ccache"
15+
},
1016
"features": {
1117
// "ghcr.io/devcontainers/features/desktop-lite:1": {},
1218
"ghcr.io/devcontainers/features/github-cli:1": {}

.devcontainer/on-create-command.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
env
6+
7+
cd $OVERLAY_WS
8+
. $UNDERLAY_WS/install/setup.sh
9+
10+
git config --global --add safe.directory "*"
11+
colcon cache lock
12+
13+
colcon build \
14+
--symlink-install \
15+
--mixin $OVERLAY_MIXINS
16+
17+
sed --in-place \
18+
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
19+
/ros_entrypoint.sh
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
env
6+
7+
cd $OVERLAY_WS
8+
9+
colcon cache lock
10+
11+
BUILD_UNFINISHED=$(
12+
colcon list \
13+
--names-only \
14+
--packages-skip-build-finished \
15+
| xargs)
16+
echo BUILD_UNFINISHED: $BUILD_UNFINISHED
17+
18+
BUILD_FAILED=$(
19+
colcon list \
20+
--names-only \
21+
--packages-select-build-failed \
22+
| xargs)
23+
echo BUILD_FAILED: $BUILD_FAILED
24+
25+
BUILD_INVALID=$(
26+
colcon list \
27+
--names-only \
28+
--packages-select-cache-invalid \
29+
--packages-select-cache-key build \
30+
| xargs)
31+
echo BUILD_INVALID: $BUILD_INVALID
32+
33+
BUILD_PACKAGES=""
34+
if [ -n "$BUILD_UNFINISHED" ] || \
35+
[ -n "$BUILD_FAILED" ] || \
36+
[ -n "$BUILD_INVALID" ]
37+
then
38+
BUILD_PACKAGES=$(
39+
colcon list \
40+
--names-only \
41+
--packages-above \
42+
$BUILD_UNFINISHED \
43+
$BUILD_FAILED \
44+
$BUILD_INVALID \
45+
| xargs)
46+
fi
47+
echo BUILD_PACKAGES: $BUILD_PACKAGES
48+
49+
colcon clean packages --yes \
50+
--packages-select ${BUILD_PACKAGES} \
51+
--base-select install
52+
53+
. $UNDERLAY_WS/install/setup.sh
54+
colcon build \
55+
--symlink-install \
56+
--mixin $OVERLAY_MIXINS \
57+
--packages-select ${BUILD_PACKAGES}

.github/workflows/update_ci_image.yaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,3 @@ jobs:
109109
- name: Image digest
110110
if: steps.config.outputs.trigger == 'true'
111111
run: echo ${{ steps.docker_build.outputs.digest }}
112-
- name: Build and push ${{ github.ref_name }}-dev
113-
if: steps.config.outputs.trigger == 'true'
114-
id: docker_build_dev
115-
uses: docker/build-push-action@v4
116-
with:
117-
pull: true
118-
push: true
119-
cache-from: |
120-
type=registry,ref=ghcr.io/ros-planning/navigation2:${{ github.ref_name }}
121-
type=registry,ref=ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev
122-
cache-to: type=inline
123-
build-args: |
124-
RUN_TESTS=True
125-
target: tester
126-
tags: |
127-
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev
128-
ghcr.io/ros-planning/navigation2:${{ github.ref_name }}-dev-${{ steps.config.outputs.timestamp }}
129-
- name: Image digest
130-
if: steps.config.outputs.trigger == 'true'
131-
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)