Skip to content

Commit b6d37a7

Browse files
authored
Merge pull request #40 from cloudengine-labs/copilot/add-unit-testing-automation-templates
Add CLI tests for scaffold unittest + update docs for v0.4.0
2 parents 563baa0 + ffbbc05 commit b6d37a7

12 files changed

Lines changed: 1548 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
---
99

10+
## [0.4.0] - 2026-03-15
11+
12+
### Added
13+
- **`scaffold unittest` subcommand** — new `devopsos scaffold unittest` command that generates
14+
unit testing configuration files and sample test stubs for multiple tech stacks:
15+
- **Python**`pytest.ini` (with pytest-cov options), `conftest.py` with shared fixtures,
16+
`tests/__init__.py`, and `tests/test_sample.py` with parametrized examples.
17+
- **JavaScript** → Jest (`jest.config.js`), Vitest (`vitest.config.js`), or Mocha (`.mocharc.js`)
18+
configuration plus a matching `tests/sample.test.js`.
19+
- **TypeScript** → same as JavaScript with TypeScript-specific Jest transform (`ts-jest`)
20+
and `tests/sample.test.ts`.
21+
- **Go** → table-driven `<name>_test.go` sample and `Makefile.test` with `test`, `test-race`,
22+
`test-cov`, and `lint` targets.
23+
- Coverage configuration is included by default and can be disabled with `--no-coverage`.
24+
- Supports comma-separated `--languages` to scaffold multiple stacks at once.
25+
- **`generate_unittest_config` MCP tool** — exposes the new unit-test scaffold as an MCP tool
26+
so AI assistants can generate test configurations via conversation.
27+
- **`cli/scaffold_unittest.py`** — the scaffold library backing the new command.
28+
- **`docs/CLI-COMMANDS-REFERENCE.md`** — new section documenting all `unittest` options,
29+
output files, and examples.
30+
31+
---
32+
1033
## [0.3.0] - 2026-03-10
1134

1235
### Fixed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[![CI](https://github.com/cloudengine-labs/devops_os/actions/workflows/ci.yml/badge.svg)](https://github.com/cloudengine-labs/devops_os/actions/workflows/ci.yml)
88
[![Sanity Tests](https://github.com/cloudengine-labs/devops_os/actions/workflows/sanity.yml/badge.svg)](https://github.com/cloudengine-labs/devops_os/actions/workflows/sanity.yml)
9-
[![Version](https://img.shields.io/badge/version-0.2.0-blue)](CHANGELOG.md)
9+
[![Version](https://img.shields.io/badge/version-0.4.0-blue)](CHANGELOG.md)
1010
[![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue?logo=python&logoColor=white)](https://www.python.org/)
1111
[![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
1212
[![Open Source](https://img.shields.io/badge/open%20source-%E2%9D%A4-red)](https://github.com/cloudengine-labs/devops_os)
@@ -29,6 +29,7 @@ DevOps-OS is an open-source DevOps automation platform that scaffolds production
2929
| 🚀 **CI/CD Generators** | One-command scaffolding for GitHub Actions, GitLab CI, and Jenkins pipelines |
3030
| ☸️ **GitOps Config Generator** | Kubernetes manifests, ArgoCD Applications, and Flux CD Kustomizations |
3131
| 📊 **SRE Config Generator** | Prometheus alert rules, Grafana dashboards, and SLO manifests |
32+
| 🧪 **Unit Test Scaffold** | Generate pytest, Jest, Vitest, Mocha, or Go test configs with one command |
3233
| 🤖 **MCP Server** | Plug DevOps-OS tools into Claude or ChatGPT as native AI skills |
3334
| 🛠️ **Dev Container** | Pre-configured multi-language environment (Python · Java · Go · JavaScript) |
3435
| 🔄 **Process-First** | Built-in education on the Process-First SDLC philosophy and how it maps to every DevOps-OS tool |
@@ -174,6 +175,13 @@ python -m cli.devopsos scaffold sre --name my-app --team platform --slo-target 9
174175
# Dev container configuration → .devcontainer/devcontainer.json + .devcontainer/devcontainer.env.json
175176
python -m cli.devopsos scaffold devcontainer --languages python,go --cicd-tools docker,terraform --kubernetes-tools k9s,flux
176177

178+
# Unit test configs + sample stubs (Python, JS, Go, TypeScript)
179+
python -m cli.devopsos scaffold unittest --name my-app --languages python
180+
python -m cli.devopsos scaffold unittest --name my-app --languages python,javascript,go
181+
182+
# Combined GitHub Actions + Jenkins in one step
183+
python -m cli.devopsos scaffold cicd --name my-app --type build --languages python --github --jenkins
184+
177185
# Kubernetes manifests
178186
python kubernetes/k8s-config-generator.py --name my-app --image ghcr.io/myorg/my-app:v1
179187
```
@@ -218,7 +226,7 @@ git clone https://github.com/cloudengine-labs/devops_os.git && cd devops_os
218226
pip install -r cli/requirements.txt
219227

220228
# ── Check version ──────────────────────────────────────────────────────────
221-
python -m cli.devopsos --version # → devopsos version 0.2.0
229+
python -m cli.devopsos --version # → devopsos version 0.4.0
222230

223231
# ── Interactive project wizard ─────────────────────────────────────────────
224232
python -m cli.devopsos init # guided setup for any project
@@ -247,6 +255,10 @@ python -m cli.devopsos scaffold devcontainer --languages python,go --cicd-tools
247255
# ── Combined CI/CD (GHA + Jenkins in one step) ────────────────────────────
248256
python -m cli.devopsos scaffold cicd --name my-app --type build --languages python --github --jenkins
249257

258+
# ── Unit Tests ─────────────────────────────────────────────────────────────
259+
python -m cli.devopsos scaffold unittest --name my-app --languages python
260+
python -m cli.devopsos scaffold unittest --name my-app --languages python,javascript,go
261+
250262
# ── Process-First philosophy ───────────────────────────────────────────────
251263
python -m cli.devopsos process-first # full overview
252264
python -m cli.devopsos process-first --section mapping # which tool for which goal
@@ -268,7 +280,7 @@ python -m cli.devopsos scaffold gha --help
268280
devops_os/
269281
├── .devcontainer/ # Dev container config (Dockerfile, devcontainer.json, setup scripts)
270282
├── .github/workflows/ # CI, Sanity Tests, and GitHub Pages workflows
271-
├── cli/ # CLI scaffold tools (scaffold_gha, gitlab, jenkins, argocd, sre, devopsos)
283+
├── cli/ # CLI scaffold tools (scaffold_gha, gitlab, jenkins, argocd, sre, unittest, devopsos)
272284
├── kubernetes/ # Kubernetes manifest generator
273285
├── mcp_server/ # MCP server for AI assistant integration (Claude, ChatGPT)
274286
├── skills/ # Claude & OpenAI tool/function definitions
@@ -291,7 +303,7 @@ pip install -r cli/requirements.txt -r mcp_server/requirements.txt pytest pytest
291303
python -m pytest cli/test_cli.py mcp_server/test_server.py tests/test_comprehensive.py -v
292304
```
293305

294-
**Latest results:**162 passed · ⚠️ 3 xfailed (known tracked bugs) · ❌ 0 failed
306+
**Latest results:**260 passed · ⚠️ 2 xfailed (known tracked bugs) · ❌ 0 failed
295307

296308
| Report | Description |
297309
|--------|-------------|
@@ -346,7 +358,7 @@ You can also customize `.devcontainer/devcontainer.env.json` directly to enable
346358
|-------|-------------|
347359
| [🚀 Getting Started](docs/GETTING-STARTED.md) | Easy step-by-step guide — **start here** |
348360
| [📖 CLI Commands Reference](docs/CLI-COMMANDS-REFERENCE.md) | **Complete reference** — every option, input file, and output location |
349-
| [🖥️ CLI Test Report](docs/CLI-TEST-REPORT.md) | v0.2.0 CLI revamp test results — 52 tests, all passing |
361+
| [🖥️ CLI Test Report](docs/CLI-TEST-REPORT.md) | v0.4.0 CLI test results — 62 tests, all passing |
350362
| [🔄 Process-First Philosophy](docs/PROCESS-FIRST.md) | What Process-First means, how it maps to DevOps-OS, and AI learning tips |
351363
| [📦 Dev Container Setup](docs/DEVOPS-OS-README.md) | Set up and customize the dev container |
352364
| [⚡ Quick Start Reference](docs/DEVOPS-OS-QUICKSTART.md) | Essential CLI commands for all features |
@@ -355,6 +367,7 @@ You can also customize `.devcontainer/devcontainer.env.json` directly to enable
355367
| [🔧 Jenkins Pipeline Generator](docs/JENKINS-PIPELINE-README.md) | Generate and customize Jenkins pipelines |
356368
| [🔄 ArgoCD / Flux GitOps](docs/ARGOCD-README.md) | Generate ArgoCD Applications and Flux Kustomizations |
357369
| [📊 SRE Configuration](docs/SRE-CONFIGURATION-README.md) | Prometheus rules, Grafana dashboards, SLO manifests |
370+
| [🧪 Unit Test Scaffold](docs/CLI-COMMANDS-REFERENCE.md#devopsos-scaffold-unittest--unit-test-scaffold-generator) | Generate pytest, Jest, Vitest, Mocha, or Go test configs |
358371
| [☸️ Kubernetes Deployments](docs/KUBERNETES-DEPLOYMENT-README.md) | Generate and manage Kubernetes deployment configs |
359372
| [🤖 MCP Server](mcp_server/README.md) | Connect DevOps-OS tools to Claude or ChatGPT |
360373
| [🧠 AI Skills](skills/README.md) | Use DevOps-OS with the Anthropic API or OpenAI function calling |

cli/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Single source of truth for the devopsos package version."""
22

3-
__version__ = "0.3.0"
3+
__version__ = "0.4.0"

cli/devopsos.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import cli.scaffold_argocd as scaffold_argocd
1616
import cli.scaffold_sre as scaffold_sre
1717
import cli.scaffold_devcontainer as scaffold_devcontainer
18+
import cli.scaffold_unittest as scaffold_unittest
1819
import cli.process_first as process_first
1920
from cli import __version__
2021

@@ -559,6 +560,74 @@ def scaffold_cicd_cmd(
559560
flags += ["--custom-values", custom_values]
560561
_run_scaffold(scaffold_cicd.main, flags)
561562

563+
564+
# ── scaffold unittest ────────────────────────────────────────────────────────
565+
566+
@scaffold_app.command("unittest")
567+
def scaffold_unittest_cmd(
568+
ctx: typer.Context,
569+
name: str = typer.Option("my-app", envvar="DEVOPS_OS_UNITTEST_NAME",
570+
help="Project / application name"),
571+
languages: str = typer.Option("python", envvar="DEVOPS_OS_UNITTEST_LANGUAGES",
572+
help=(
573+
"Comma-separated languages to generate tests for: "
574+
"python, javascript, typescript, go"
575+
)),
576+
framework: str = typer.Option("", envvar="DEVOPS_OS_UNITTEST_FRAMEWORK",
577+
help=(
578+
"Testing framework override (auto-selected by default). "
579+
"JS/TS: jest | mocha | vitest. Python: pytest. Go: go-test."
580+
)),
581+
coverage: bool = typer.Option(True, envvar="DEVOPS_OS_UNITTEST_COVERAGE",
582+
help="Include coverage configuration (default: true)"),
583+
output_dir: str = typer.Option("unittest", "--output-dir",
584+
envvar="DEVOPS_OS_UNITTEST_OUTPUT_DIR",
585+
help="Root output directory for generated files"),
586+
):
587+
"""Generate unit testing configuration and sample test files.
588+
589+
\b
590+
Supported languages and their default frameworks:
591+
python → pytest + pytest-cov
592+
javascript → Jest (override with --framework mocha | vitest)
593+
typescript → Jest (override with --framework mocha | vitest)
594+
go → go test
595+
596+
\b
597+
Output files (default: unittest/ directory):
598+
unittest/pytest.ini Python pytest configuration
599+
unittest/conftest.py Python shared fixtures
600+
unittest/tests/__init__.py Python test-package marker
601+
unittest/tests/test_sample.py Python sample unit tests
602+
unittest/jest.config.js JavaScript/TypeScript Jest config
603+
unittest/vitest.config.js JavaScript/TypeScript Vitest config
604+
unittest/.mocharc.js JavaScript/TypeScript Mocha config
605+
unittest/tests/sample.test.js JavaScript/TypeScript sample tests
606+
unittest/<name>_test.go Go sample unit test file
607+
unittest/Makefile.test Go Makefile test targets
608+
609+
\b
610+
Examples:
611+
devopsos scaffold unittest --name my-app --languages python
612+
devopsos scaffold unittest --name my-app --languages javascript --framework jest
613+
devopsos scaffold unittest --name my-app --languages typescript --framework vitest
614+
devopsos scaffold unittest --name my-api --languages go
615+
devopsos scaffold unittest --name my-app --languages python,javascript,go
616+
"""
617+
_show_help_if_no_opts(ctx)
618+
flags = [
619+
"--name", name,
620+
"--languages", languages,
621+
"--output-dir", output_dir,
622+
]
623+
if framework:
624+
flags += ["--framework", framework]
625+
if not coverage:
626+
# coverage defaults to True; only pass flag when False
627+
flags.append("--no-coverage")
628+
_run_scaffold(scaffold_unittest.main, flags)
629+
630+
562631
@app.command()
563632
def init(
564633
directory: str = typer.Option(".", "--dir", help="Target directory in which the .devcontainer folder will be created (defaults to the current directory)"),

0 commit comments

Comments
 (0)