Skip to content

Commit ffef504

Browse files
committed
merge dev: react workflow audit + code cleanup
2 parents e1cffd6 + 9f79f68 commit ffef504

13 files changed

Lines changed: 1526 additions & 105 deletions

File tree

.windloop/specs/devcontainer-template/design.md

Lines changed: 416 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Requirements: Splunk Devcontainer Template
2+
3+
## Introduction
4+
5+
A reusable GitHub template repository for building Splunk applications. The template provides a uniform development environment across operating systems (macOS, Windows, Linux) by running developer tooling inside a VS Code devcontainer and Splunk as a separate Docker Compose service. This separation means contributors on any OS get identical tooling without manual setup, while Splunk runs in its own isolated container.
6+
7+
The devcontainer is the cross-platform equalizer: a Windows developer gets a Linux shell with the right Node/Python/Task versions; a macOS developer gets the same environment as a Linux CI runner. Splunk and optional sidecars run as compose services, independent of the devcontainer lifecycle.
8+
9+
## Glossary
10+
11+
- **Devcontainer**: VS Code dev container providing tools (Node, Python, Docker CLI, Go Task). Tools-only — no Splunk runtime inside.
12+
- **Splunk container**: The `splunk/splunk` Docker image running as a compose service, accessed from the devcontainer via Docker-outside-of-Docker.
13+
- **Skip-provision**: Restarting the Splunk container without re-running Ansible (~30s vs ~90s), enabled by a marker file in the `splunk-var` volume.
14+
- **Symlink mount**: A single bind mount of `splunk/config/apps/` into the container at `/opt/splunk/dev-apps/`, with per-app symlinks in `/opt/splunk/etc/apps/` — avoids container recreation when adding new apps.
15+
- **APP_NAME**: The primary app identifier. Used as the folder name, `[package] id` in `app.conf`, and React source directory name.
16+
- **Staging environment**: A second Splunk instance with apps baked into the image, running on different ports (18000/18089/18088), for pre-release validation.
17+
18+
## Requirements
19+
20+
### Requirement 1: Uniform Cross-Platform Development Environment
21+
22+
**User Story:** As a developer on any OS (macOS, Windows, Linux), I want to open this repo in VS Code and get a fully configured development environment immediately, so that I don't need to manually install tools or worry about version mismatches.
23+
24+
#### Acceptance Criteria
25+
26+
1. WHEN a developer opens the repo in VS Code, THEN the devcontainer SHALL provide Node 22, Python 3.12, Docker CLI, and Go Task ready to use.
27+
2. WHEN the devcontainer starts, THEN it SHALL contain no Splunk runtime — Splunk runs only in the compose stack.
28+
3. WHEN the devcontainer rebuilds, THEN Splunk state SHALL be unaffected (volumes persist independently).
29+
4. WHEN the devcontainer starts, THEN VS Code extensions SHALL be pre-configured (ruff, Splunk, Chrome debug, ESLint, Prettier, YAML).
30+
5. WHEN the devcontainer is created, THEN `post-create.sh` SHALL install splunk-appinspect, ruff, and pytest, then build the Splunk dev image so `task splunk:up` is instant.
31+
6. WHEN a developer uses the devcontainer on Windows or Linux, THEN the experience SHALL be identical to macOS — same tool versions, same shell, same task commands.
32+
33+
### Requirement 2: Fast Splunk Dev Loop (Skip-Provision)
34+
35+
**User Story:** As a developer, I want Splunk to restart quickly after Docker Desktop restarts or container recreation, so that I'm not blocked waiting 90 seconds for Ansible to re-run.
36+
37+
#### Acceptance Criteria
38+
39+
1. WHEN the Splunk container restarts and a `.provisioned` marker exists in `splunk-var`, THEN the entrypoint wrapper SHALL skip Ansible and start splunkd directly in ~30s.
40+
2. WHEN the Splunk container starts for the first time (no marker), THEN full Ansible provisioning SHALL run and write the marker on success.
41+
3. WHEN `task splunk:reprovision` is run, THEN the marker SHALL be removed and full Ansible provisioning SHALL run on next start.
42+
4. WHEN skip-provision mode runs, THEN the Docker healthcheck state file SHALL be written so `checkstate.sh` passes.
43+
44+
### Requirement 3: Splunk Compose Services
45+
46+
**User Story:** As a developer, I want Splunk and optional sidecars to run as independent compose services, so that I can start/stop them without affecting my editor or tooling.
47+
48+
#### Acceptance Criteria
49+
50+
1. WHEN `task splunk:up` is run, THEN Splunk SHALL start as a compose service independent of the devcontainer lifecycle.
51+
2. WHEN app source files in `splunk/config/apps/` are edited on the host, THEN changes SHALL be visible inside the Splunk container without packaging or container recreation.
52+
3. WHEN the Splunk container is recreated, THEN indexed data and provisioning state SHALL persist via `splunk-var` and `splunk-etc` named volumes.
53+
4. WHEN `splunk/stage/` contains tarballs, THEN they SHALL be bind-mounted at `/tmp/apps` inside the container for tarball-based installs.
54+
55+
### Requirement 4: Multi-App Development
56+
57+
**User Story:** As a developer, I want to develop and test multiple Splunk apps simultaneously in one repo, so that I can work on related apps together.
58+
59+
#### Acceptance Criteria
60+
61+
1. WHEN multiple app directories exist in `splunk/config/apps/`, THEN all SHALL be live-mounted and visible in Splunk simultaneously.
62+
2. WHEN `task app:create APP_NAME=foo` is run, THEN a Splunk app skeleton SHALL be scaffolded with `app.conf` using `APP_NAME` as `[package] id` and a human-readable `[ui] label` (underscores → spaces).
63+
3. WHEN `task app:create` completes, THEN the new app SHALL be immediately visible in Splunk without container recreation (~2–10s).
64+
4. WHEN `task app:package APP_NAME=foo` is run, THEN `splunk/stage/foo.tgz` SHALL be produced.
65+
5. WHEN `task app:provision` is run, THEN all local apps (or a specific one) SHALL be packaged and installed into the running Splunk instance.
66+
6. WHEN `task app:sync-links` is run, THEN every app directory in `splunk/config/apps/` SHALL have a corresponding symlink in `/opt/splunk/etc/apps/` inside the container.
67+
68+
### Requirement 5: Splunkbase Dependency Management
69+
70+
**User Story:** As a developer, I want to declare Splunkbase app dependencies in a config file and install them idempotently, so that my team can reproduce the same Splunk environment.
71+
72+
#### Acceptance Criteria
73+
74+
1. WHEN `splunk/config/deps.yml` is populated with Splunkbase IDs/versions or direct URLs, THEN `task deps:install` SHALL download and install each dependency into the running Splunk instance.
75+
2. WHEN `task deps:install` is run and a dependency is already installed at the correct version, THEN it SHALL be skipped (idempotent).
76+
77+
### Requirement 6: React UI Development
78+
79+
**User Story:** As a developer building a React-based Splunk app, I want scaffolding, a live dev loop via symlinked stage/, and a packaging pipeline for staging, so that I can iterate on UI quickly.
80+
81+
#### Acceptance Criteria
82+
83+
1. WHEN `task react:create` is run, THEN a React app SHALL be scaffolded via `npx @splunk/create`, the app package detected, `APP_NAME` synced in `.env`, and an initial build run so `stage/` exists.
84+
2. WHEN `task react:link` is run, THEN `stage/` SHALL be symlinked into the dev Splunk container's `etc/apps/`. If `stage/` is missing, it SHALL auto-build first.
85+
3. WHEN `task react:start` is run, THEN webpack watch SHALL start, updating `stage/` live. Splunk reads changes via the symlink from `react:link`.
86+
4. WHEN `task react:build` is run, THEN a production webpack build SHALL always rebuild `stage/`.
87+
5. WHEN `task react:package` is run, THEN `react:build` SHALL run first, then `stage/` SHALL be packaged as `splunk/stage/<APP_NAME>.tgz` for staging image bake-in.
88+
6. WHEN `task react:add-page` is run, THEN a new page/component SHALL be added interactively via `@splunk/create`.
89+
90+
### Requirement 7: Task Automation
91+
92+
**User Story:** As a developer, I want all common operations available as short `task` commands, so that I don't need to remember long docker or curl commands.
93+
94+
#### Acceptance Criteria
95+
96+
1. WHEN `task --list` is run, THEN all tasks SHALL be organized into namespaces: `splunk:*`, `app:*`, `react:*`, `deps:*`, `python:*`, `test:*`.
97+
2. WHEN a task accepts `APP_NAME`, THEN it SHALL load the value from `.env` as default when not provided as a CLI argument.
98+
3. WHEN `task splunk:refresh` is run, THEN app configs and Splunk Web SHALL reload via REST API in ~2s without restarting splunkd.
99+
4. WHEN `task splunk:build` is run, THEN the dev Splunk image SHALL be built explicitly. `task splunk:up` SHALL NOT rebuild — it only starts the container.
100+
101+
### Requirement 8: Debugging
102+
103+
**User Story:** As a developer, I want to attach a debugger to Python code running inside Splunk and to React code in the browser, so that I can step through code without print-debugging.
104+
105+
#### Acceptance Criteria
106+
107+
1. WHEN a Python script calls `enable_debugging()` from SA-VSCode, THEN VSCode SHALL be able to attach via debugpy on port 5678 using the "Python: Attach to Splunk" launch config.
108+
2. WHEN VSCode opens the repo, THEN `launch.json` SHALL provide four debug configurations: Python remote attach, Chrome Splunk Web (dev :8000), Chrome React dev server (:3000), Chrome Staging Splunk Web (:18000).
109+
3. WHEN the `splunk-config-dev` app is installed, THEN `web.conf` SHALL set `js_no_cache`, `minify_js=false`, `enableWebDebug=true`, `minify_css=false` for JS debugging.
110+
111+
### Requirement 9: Simultaneous Dev + Staging Environments
112+
113+
**User Story:** As a developer, I want to run a staging Splunk instance alongside dev on different ports, so that I can validate baked-in app builds without disrupting my dev environment.
114+
115+
#### Acceptance Criteria
116+
117+
1. WHEN `task splunk:up-staging` is run, THEN a staging Splunk instance SHALL start on ports 18000/18089/18088 with apps baked into the image, using separate volumes (`splunk-staging-var`, `splunk-staging-etc`) isolated from dev.
118+
2. WHEN both dev and staging are running, THEN they SHALL not conflict (different ports, volumes, container names).
119+
120+
### Requirement 10: E2E Testing
121+
122+
**User Story:** As a maintainer, I want automated E2E tests that validate the full devcontainer and Splunk lifecycle, so that template changes don't silently break the developer experience.
123+
124+
#### Acceptance Criteria
125+
126+
1. WHEN `task test:e2e` is run, THEN it SHALL validate: devcontainer builds, `post-create.sh` completes, expected tools are on PATH, `task --list` works, and `docker compose config` validates for both compose files.
127+
2. WHEN the lifecycle E2E tests run, THEN they SHALL validate: `splunk:up` starts a healthy Splunk, `app:create` scaffolds and makes an app visible via REST API, `app:package` produces a tarball, `app:provision` installs it, `react:build` and `react:package` produce a valid tgz, and `splunk:build-staging` builds a staging image.
128+
3. WHEN lifecycle tests run, THEN they SHALL be split into focused, independently-runnable scripts with shared helpers and per-suite pass/fail reporting.
129+
4. WHEN skip-provision E2E runs, THEN it SHALL verify: restarting a provisioned container recovers in ≤60s without Ansible, and `task splunk:reprovision` runs full Ansible and re-creates the marker.
130+
131+
### Requirement 11: Documentation
132+
133+
**User Story:** As a developer cloning this template, I want clear documentation on the architecture and all available commands, so that I can understand and use the template without reading the source.
134+
135+
#### Acceptance Criteria
136+
137+
1. WHEN a developer reads `AGENTS.md`, THEN it SHALL provide a concise repo summary with key entry points and a windloop hint. No architecture details.
138+
2. WHEN a developer reads `ARCHITECTURE.md`, THEN it SHALL contain full documentation: directory structure, commands, debugging guides, how-it-works explanations, and troubleshooting.
139+
140+
### Requirement 12: Developer Workflow
141+
142+
**User Story:** As a developer using this template, I want a documented end-to-end workflow from first clone to daily iteration, so that I can get productive quickly.
143+
144+
#### Acceptance Criteria
145+
146+
1. WHEN a developer first opens the repo, THEN the documented workflow SHALL be: open in VS Code → "Reopen in Container" → `task splunk:up``task deps:install`.
147+
2. WHEN a developer creates a new app, THEN the documented workflow SHALL be: `task app:create APP_NAME=foo` → app visible in Splunk → edit `.conf``task splunk:refresh`.
148+
3. WHEN a developer does daily iteration, THEN the documented speed tiers SHALL be: refresh (~2s) → restartd (~10s) → new app (~2–10s) → image rebuild → full reset (~90s).
149+
4. WHEN a developer wants to verify a release build, THEN the documented workflow SHALL be: `task app:package``task splunk:build-staging``task splunk:up-staging`.
150+
151+
### Requirement 13: App Naming Model
152+
153+
**User Story:** As a developer, I want a single `APP_NAME` identifier to tie together the folder name, Splunk package ID, and React source directory, so that there's no ambiguity or manual synchronization.
154+
155+
#### Acceptance Criteria
156+
157+
1. WHEN `APP_NAME` is set in `.env`, THEN it SHALL be the folder name under `splunk/config/apps/`, equal `[package] id` in `app.conf`, and (for React apps) match the directory under `packages/`.
158+
2. WHEN `task app:create` runs, THEN `app.conf` SHALL have `[package] id = APP_NAME` and `[ui] label` derived by replacing underscores with spaces.
159+
3. WHEN `.env` and `splunk.env.example` are read, THEN they SHALL clearly document that `APP_NAME` is the primary app folder name used by `app:*`, `react:*`, and CI/CD.
160+
161+
### Requirement 14: GitHub Actions CI/CD
162+
163+
**User Story:** As a maintainer, I want CI/CD workflows that build and validate the primary app on every push and publish a release artifact on tag, so that quality is enforced automatically.
164+
165+
#### Acceptance Criteria
166+
167+
1. WHEN a push or PR targets `main`, THEN `ci.yml` SHALL build the primary app from `splunk/config/apps/${APP_NAME}` and run local AppInspect via `VatsalJagani/splunk-app-action@v5`.
168+
2. WHEN a tag matching `v*` is pushed, THEN `release.yml` SHALL build the primary app, run API AppInspect (cloud + SSAI checks), and upload the `.tgz` artifact.
169+
3. WHEN workflows run, THEN they SHALL read `APP_NAME` from `.env` — no fragile grep of `app.conf`.
170+
4. WHEN workflows are defined, THEN they SHALL use current action versions: `actions/checkout@v4`, `actions/setup-python@v5`, `actions/upload-artifact@v4`.
171+
172+
### Non-Functional
173+
174+
**NF 1**: Devcontainer rebuild completes in under 60 seconds.
175+
176+
**NF 2**: Splunk container restart in skip-provision mode completes in under 40 seconds.
177+
178+
**NF 3**: The template works on macOS (Docker Desktop) and Linux. The devcontainer provides a uniform environment for Windows developers via Docker Desktop + WSL2.
179+
180+
**NF 4**: All VS Code config uses the modern `customizations.vscode.*` schema — no deprecated top-level `settings` or `extensions` keys.
181+
182+
## Out of Scope
183+
184+
- Native (non-devcontainer) local development on macOS — planned as a future enhancement
185+
- Splunk Cloud deployment (ACS API)
186+
- Splunk clustering (multi-node)
187+
- Internal logic of user-developed apps — only the dev workflow around them
188+
- Automated Splunkbase publishing (release workflow builds + validates but does not auto-publish)

0 commit comments

Comments
 (0)