-
Notifications
You must be signed in to change notification settings - Fork 0
Add prompty-dumpty feature with installation scripts and tests #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # Feature tarballs for local testing | ||
| .devcontainer/*.tgz | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Plan: prompty-dumpty DevContainer Feature | ||
|
|
||
| Install prompty-dumpty (v0.6.2 current) Python package system-wide using pip3 with `--break-system-packages` flag. The CLI command `dumpty` will be available globally after installation. | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. **Create feature structure** at `src/prompty-dumpty/` with `devcontainer-feature.json` (id: "prompty-dumpty", version option only with default "latest", no `installsAfter` or installPath), `README.md` documenting the `dumpty` command, and `.gitignore` | ||
|
|
||
| 2. **Write install script** at `src/prompty-dumpty/install.sh` with `set -e` for fail-fast behavior, detect package manager (apt/apk/yum), install `python3-pip` if missing, run `pip3 install prompty-dumpty --break-system-packages` (latest) or `pip3 install prompty-dumpty==VERSION --break-system-packages` (specific version like 0.6.2) | ||
|
|
||
| 3. **Add verification and output** using `command -v dumpty` to verify installation, run `dumpty --version`, display colored success message with installation details following `src/microsoft-security-devops-cli/install.sh` colored output pattern | ||
|
|
||
| 4. **Create test suite** at `test/prompty-dumpty/` with `test.sh` (installs latest, verifies `dumpty` exists), `version.sh` (installs version 0.6.2 specifically), and `scenarios.json` testing both scenarios on debian/ubuntu base images | ||
|
|
||
| ## Further Considerations | ||
|
|
||
| None - ready to implement with fail-fast on errors and pip's default install paths. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
|
|
||
| # Prompty Dumpty (prompty-dumpty) | ||
|
|
||
| Installs prompty-dumpty CLI tool for managing prompty files | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```json | ||
| "features": { | ||
| "ghcr.io/rosstaco/devcontainer-features/prompty-dumpty:1": {} | ||
| } | ||
| ``` | ||
|
|
||
| ## Options | ||
|
|
||
| | Options Id | Description | Type | Default Value | | ||
| |-----|-----|-----|-----| | ||
| | version | Version of prompty-dumpty to install. Use 'latest' or a specific version like '0.6.2' | string | latest | | ||
|
|
||
| ## Usage | ||
|
|
||
| After installation, the `dumpty` command will be available: | ||
|
|
||
| ```bash | ||
| dumpty --help | ||
| dumpty --version | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| This feature installs prompty-dumpty system-wide using pip3 with the `--break-system-packages` flag, which is appropriate for containerized development environments. Python 3 is assumed to be present in the base image. | ||
|
|
||
| For more information about prompty-dumpty, visit: https://pypi.org/project/prompty-dumpty/ | ||
|
|
||
| --- | ||
|
|
||
| _Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/rosstaco/devcontainer-features/blob/main/src/prompty-dumpty/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "id": "prompty-dumpty", | ||
| "version": "1.0.0", | ||
| "name": "Prompty Dumpty", | ||
| "description": "Installs prompty-dumpty CLI tool for managing prompty files", | ||
| "documentationURL": "https://github.com/rosstaco/devcontainer-features/tree/main/src/prompty-dumpty", | ||
| "options": { | ||
| "version": { | ||
| "type": "string", | ||
| "default": "latest", | ||
| "description": "Version of prompty-dumpty to install. Use 'latest' or a specific version like '0.6.2'" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Prompty Dumpty installation script for devcontainer features | ||
| # https://pypi.org/project/prompty-dumpty/ | ||
|
|
||
| VERSION="${VERSION:-latest}" | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| echo -e "${GREEN}Installing prompty-dumpty...${NC}" | ||
|
|
||
| # Ensure pip is available | ||
| if ! command -v pip3 &> /dev/null; then | ||
| echo "Installing python3-pip..." | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| if command -v apt-get &> /dev/null; then | ||
| apt-get update && apt-get install -y --no-install-recommends python3-pip | ||
| elif command -v apk &> /dev/null; then | ||
| apk add --no-cache py3-pip | ||
| elif command -v yum &> /dev/null; then | ||
| yum install -y python3-pip | ||
| else | ||
| echo -e "${RED}Could not install python3-pip. Please install it manually.${NC}" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| # Build pip install command | ||
| if [ "$VERSION" = "latest" ]; then | ||
| echo "Installing latest version..." | ||
| PIP_PACKAGE="prompty-dumpty" | ||
| else | ||
| echo "Installing version: $VERSION" | ||
| PIP_PACKAGE="prompty-dumpty==$VERSION" | ||
| fi | ||
|
|
||
| # Check if pip supports --break-system-packages flag (pip >= 23.0) | ||
| if pip3 install --help 2>&1 | grep -q "break-system-packages"; then | ||
| PIP_SUPPORTS_BREAK_SYSTEM="yes" | ||
| else | ||
| PIP_SUPPORTS_BREAK_SYSTEM="no" | ||
| fi | ||
|
|
||
| # Install prompty-dumpty with appropriate flags | ||
| if [ "$PIP_SUPPORTS_BREAK_SYSTEM" = "yes" ]; then | ||
| echo "Running: pip3 install $PIP_PACKAGE --break-system-packages" | ||
| if ! pip3 install "$PIP_PACKAGE" --break-system-packages; then | ||
| echo -e "${RED}Failed to install prompty-dumpty${NC}" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Running: pip3 install $PIP_PACKAGE" | ||
| if ! pip3 install "$PIP_PACKAGE"; then | ||
| echo -e "${RED}Failed to install prompty-dumpty${NC}" | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| echo -e "${GREEN}prompty-dumpty installed successfully${NC}" | ||
|
|
||
| # Verify installation | ||
| if ! command -v dumpty &> /dev/null; then | ||
| echo -e "${YELLOW}Warning: dumpty command not found in PATH${NC}" | ||
| echo -e "${YELLOW}You may need to restart your shell or source your shell configuration${NC}" | ||
| else | ||
| echo -e "${GREEN}dumpty installation verified successfully${NC}" | ||
|
|
||
| # Try to get version info | ||
| if INSTALLED_VERSION=$(dumpty --version 2>&1); then | ||
| echo "Installed version: $INSTALLED_VERSION" | ||
| else | ||
| echo "Installed version: version check failed" | ||
| fi | ||
| fi | ||
|
|
||
| echo "" | ||
| echo -e "${GREEN}========================================${NC}" | ||
| echo -e "${GREEN}Installation complete!${NC}" | ||
| echo -e "${GREEN}========================================${NC}" | ||
| echo "" | ||
| echo "The 'dumpty' command is now available." | ||
| echo "" | ||
| echo "For more information: https://pypi.org/project/prompty-dumpty/" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This test verifies prompty-dumpty works on Alpine | ||
|
|
||
| set -e | ||
|
|
||
| source dev-container-features-test-lib | ||
|
|
||
| check "dumpty is executable" bash -c "command -v dumpty" | ||
|
|
||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | ||
|
|
||
| reportResults | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| # This test verifies prompty-dumpty works on Debian | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| source dev-container-features-test-lib | ||||||
|
|
||||||
| check "dumpty is executable" bash -c "command -v dumpty" | ||||||
|
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | ||||||
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | |
| check "dumpty version command works" bash -c "dumpty --version 2>&1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "version": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
| "features": { | ||
| "prompty-dumpty": { | ||
| "version": "0.6.2" | ||
| } | ||
| } | ||
| }, | ||
| "debian": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:debian", | ||
| "features": { | ||
| "prompty-dumpty": {} | ||
| } | ||
| }, | ||
| "alpine": { | ||
| "image": "mcr.microsoft.com/devcontainers/base:alpine", | ||
| "features": { | ||
| "prompty-dumpty": {} | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| # This test file will be executed against an auto-generated devcontainer.json that | ||||||
| # includes the 'prompty-dumpty' Feature with no options. | ||||||
| # | ||||||
| # Thus, the value of all options will fall back to the default value in the | ||||||
| # Feature's 'devcontainer-feature.json'. | ||||||
| # | ||||||
| # These scripts are run as 'root' by default. Although that can be changed | ||||||
| # with the '--remote-user' flag. | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| # Optional: Import test library bundled with the devcontainer CLI | ||||||
| source dev-container-features-test-lib | ||||||
|
|
||||||
| # Feature-specific tests | ||||||
| check "dumpty is executable" bash -c "command -v dumpty" | ||||||
|
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | ||||||
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | |
| check "dumpty version command works" bash -c "dumpty --version 2>&1" |
Copilot
AI
Nov 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test logic in lines 18-20 is duplicated across all four test files (test.sh, version.sh, alpine.sh, debian.sh). Consider extracting this common test logic into a shared function or separate file to reduce duplication and improve maintainability.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| # This test verifies that a specific version can be installed | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| source dev-container-features-test-lib | ||||||
|
|
||||||
| check "dumpty is executable" bash -c "command -v dumpty" | ||||||
|
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | ||||||
|
||||||
| check "dumpty version command works" bash -c "dumpty --version 2>&1 || true" | |
| check "dumpty version command works" bash -c "dumpty --version 2>&1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
|| trueat the end of the version check masks potential failures. Ifdumpty --versionfails, the test will still pass. Consider removing|| trueto ensure the command actually succeeds, or add explicit validation of the output.