From 7da05f1d1eaa22e60bc72e7dc663696df93e2aa9 Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sat, 4 May 2024 20:49:23 -0500 Subject: [PATCH 1/6] Add Dev Container for local development - https://github.com/colcon/colcon-clean/pull/39 --- .devcontainer/devcontainer.json | 16 ++++++++++++++++ .devcontainer/on-create-command.sh | 20 ++++++++++++++++++++ .devcontainer/post-create-command.sh | 11 +++++++++++ .dockerignore | 6 ------ .vscode/settings.json | 15 +++++++++++++-- Dockerfile | 16 ---------------- 6 files changed, 60 insertions(+), 24 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/on-create-command.sh create mode 100755 .devcontainer/post-create-command.sh delete mode 100644 .dockerignore delete mode 100644 Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..9f09003 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "colcon-clean", + "image": "python:3", + "workspaceFolder": "/workspace/colcon-clean", + "workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind", + "onCreateCommand": ".devcontainer/on-create-command.sh", + "postCreateCommand": ".devcontainer/post-create-command.sh", + "customizations": { + "vscode": { + "settings": {}, + "extensions": [ + "ms-python.python" + ] + } + } +} diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh new file mode 100755 index 0000000..aec466e --- /dev/null +++ b/.devcontainer/on-create-command.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Immediately catch all errors +set -eo pipefail + +# Uncomment for debugging +# set -x +# env + +git config --global --add safe.directory "*" + +CONSTRAINTS_URL=https://raw.githubusercontent.com/colcon/ci/main/constraints.txt +CONSTRAINTS_FILE=/tmp/constraints.txt + +# Download constraints +curl -sSLo $CONSTRAINTS_FILE $CONSTRAINTS_URL +# Remove this package from constraints +sed -i "/^$(python setup.py --name)@/d" $CONSTRAINTS_FILE +# Install dependencies, including any 'test' extras, as well as pytest-cov +pip install -U -e .[test] pytest-cov -c $CONSTRAINTS_FILE diff --git a/.devcontainer/post-create-command.sh b/.devcontainer/post-create-command.sh new file mode 100755 index 0000000..486724e --- /dev/null +++ b/.devcontainer/post-create-command.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Immediately catch all errors +set -eo pipefail + +# Uncomment for debugging +# set -x +# env + +# Enable autocomplete for user +cp /etc/skel/.bashrc ~/ diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 9e2d116..0000000 --- a/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -.dockerignore -.git/ -.github/ -.gitignore -.vscode/ -Dockerfile diff --git a/.vscode/settings.json b/.vscode/settings.json index 9cd2784..96ad239 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,16 @@ "sched", "subverb", "subverbs" - ] -} \ No newline at end of file + ], + "python.languageServer": "Default", + "python.testing.pytestArgs": [ + "--cov", + "--cov-branch", + "--cov-report", + "xml:coverage.xml", + "--cov-config", + "setup.cfg" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 477dede..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3 - -WORKDIR /usr/src/app - -COPY setup.cfg setup.py ./ -COPY colcon_cache/__init__.py ./colcon_cache/__init__.py -RUN pip install -e .[test] - -COPY . . -RUN pip install -e .[test] - -RUN colcon build \ - --symlink-install - -RUN colcon test && \ - colcon test-result --verbose From f876efe74c9e195a44c1d64fc56ee76caf81db44 Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sun, 5 May 2024 02:14:24 +0000 Subject: [PATCH 2/6] Update scipt to match colcon CI --- .devcontainer/on-create-command.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index aec466e..d2eed4b 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -9,12 +9,13 @@ set -eo pipefail git config --global --add safe.directory "*" -CONSTRAINTS_URL=https://raw.githubusercontent.com/colcon/ci/main/constraints.txt -CONSTRAINTS_FILE=/tmp/constraints.txt +COLCON_CI_URL=https://github.com/colcon/ci/archive/refs/heads/main.zip +curl -sSL $COLCON_CI_URL > /tmp/main.zip +unzip /tmp/main.zip -d /tmp/ +GITHUB_ACTION_PATH=/tmp/ci-main -# Download constraints -curl -sSLo $CONSTRAINTS_FILE $CONSTRAINTS_URL -# Remove this package from constraints -sed -i "/^$(python setup.py --name)@/d" $CONSTRAINTS_FILE -# Install dependencies, including any 'test' extras, as well as pytest-cov -pip install -U -e .[test] pytest-cov -c $CONSTRAINTS_FILE +PKG_NAME=$(pip list -l -e --format json | jq '.[0].name' -r | tr _ -) +cp -a ${GITHUB_ACTION_PATH}/constraints{,-heads,-pins}.txt ./ +sed -i.orig "s/^${PKG_NAME}@.*//g" constraints-heads.txt +# Install dependencies, including 'test' extras, as well as pytest-cov +python -m pip install -U -e .[test] pytest-cov -c constraints.txt From 5d0f47fef509ba5fa179263195c3eb26c4bb4fbd Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sun, 5 May 2024 02:14:45 +0000 Subject: [PATCH 3/6] Install missing jq CLI --- .devcontainer/on-create-command.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index d2eed4b..3291326 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -9,6 +9,8 @@ set -eo pipefail git config --global --add safe.directory "*" +apt update && apt install -y jq + COLCON_CI_URL=https://github.com/colcon/ci/archive/refs/heads/main.zip curl -sSL $COLCON_CI_URL > /tmp/main.zip unzip /tmp/main.zip -d /tmp/ From 66085e43aa9b1a3855c8dd4e0e025e553cee0a9f Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sun, 5 May 2024 02:18:22 +0000 Subject: [PATCH 4/6] Update devcontainer name and path --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9f09003..de85a5e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { - "name": "colcon-clean", + "name": "colcon-cache", "image": "python:3", - "workspaceFolder": "/workspace/colcon-clean", + "workspaceFolder": "/workspace/colcon-cache", "workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind", "onCreateCommand": ".devcontainer/on-create-command.sh", "postCreateCommand": ".devcontainer/post-create-command.sh", From 783830d7a1a6032df4d976af1db9b3554610aa3d Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sun, 5 May 2024 02:48:01 +0000 Subject: [PATCH 5/6] Install jq via apt-get feature --- .devcontainer/devcontainer.json | 7 +++++++ .devcontainer/on-create-command.sh | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index de85a5e..4a73a36 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,6 +5,13 @@ "workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind", "onCreateCommand": ".devcontainer/on-create-command.sh", "postCreateCommand": ".devcontainer/post-create-command.sh", + "features": { + "ghcr.io/devcontainers-contrib/features/apt-get-packages:1": { + "packages": [ + "jq", + ] + }, + }, "customizations": { "vscode": { "settings": {}, diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index 3291326..d2eed4b 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -9,8 +9,6 @@ set -eo pipefail git config --global --add safe.directory "*" -apt update && apt install -y jq - COLCON_CI_URL=https://github.com/colcon/ci/archive/refs/heads/main.zip curl -sSL $COLCON_CI_URL > /tmp/main.zip unzip /tmp/main.zip -d /tmp/ From f9a75818ae0f935228785ec6456eb1de6a78a0ef Mon Sep 17 00:00:00 2001 From: ruffsl Date: Sat, 15 Jun 2024 20:45:05 -0500 Subject: [PATCH 6/6] cleanup temp files --- .devcontainer/on-create-command.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index d2eed4b..d28d605 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -19,3 +19,6 @@ cp -a ${GITHUB_ACTION_PATH}/constraints{,-heads,-pins}.txt ./ sed -i.orig "s/^${PKG_NAME}@.*//g" constraints-heads.txt # Install dependencies, including 'test' extras, as well as pytest-cov python -m pip install -U -e .[test] pytest-cov -c constraints.txt + +# cleanup temp files +rm constraints*.txt*