diff --git a/.github/agents/Management.agent.md b/.github/agents/Management.agent.md index aa1bcf73..23f45efa 100644 --- a/.github/agents/Management.agent.md +++ b/.github/agents/Management.agent.md @@ -127,10 +127,10 @@ fix: harden security suite integration test expectations The task is not complete until ALL of the following pass with zero issues: 1. **Playwright E2E Tests (MANDATORY - Run First)**: - - **PREREQUISITE**: Rebuild E2E container before each test run: - ```bash - .github/skills/scripts/skill-runner.sh docker-rebuild-e2e - ``` + - **PREREQUISITE**: Rebuild the E2E container when application or Docker build inputs change; skip rebuild for test-only changes if the container is already healthy: + ```bash + .github/skills/scripts/skill-runner.sh docker-rebuild-e2e + ``` This ensures the container has latest code and proper environment variables (emergency token, encryption key from `.env`). - **Run**: `npx playwright test --project=chromium --project=firefox --project=webkit` from project root - **No Truncation**: Never pipe output through `head`, `tail`, or other truncating commands. Playwright requires user input to quit when piped, causing hangs. diff --git a/.github/agents/Playwright_Dev.agent.md b/.github/agents/Playwright_Dev.agent.md index 107515d1..6b7e4502 100644 --- a/.github/agents/Playwright_Dev.agent.md +++ b/.github/agents/Playwright_Dev.agent.md @@ -27,10 +27,10 @@ You do not write code, strictly tests. If code changes are needed, inform the Ma 1. **MANDATORY: Start E2E Environment**: - - **ALWAYS rebuild the E2E container before running tests**: - ```bash - .github/skills/scripts/skill-runner.sh docker-rebuild-e2e - ``` + - **Rebuild the E2E container when application or Docker build inputs change. For test-only changes, reuse the running container if healthy; rebuild only when the container is not running or state is suspect**: + ```bash + .github/skills/scripts/skill-runner.sh docker-rebuild-e2e + ``` - This ensures the container has the latest code and proper environment variables - The container exposes: port 8080 (app), port 2020 (emergency), port 2019 (Caddy admin) - Verify container is healthy before proceeding diff --git a/.github/agents/QA_Security.agent.md b/.github/agents/QA_Security.agent.md index fe63cef8..e36f1b69 100644 --- a/.github/agents/QA_Security.agent.md +++ b/.github/agents/QA_Security.agent.md @@ -27,7 +27,7 @@ You are a QA AND SECURITY ENGINEER responsible for testing and vulnerability ass -1. **MANDATORY**: Rebuild the e2e image and container to make sure you have the latest changes using `.github/skills/scripts/skill-runner.sh docker-rebuild-e2e`. Rebuild every time code changes are made before running tests again. +1. **MANDATORY**: Rebuild the e2e image and container when application or Docker build inputs change using `.github/skills/scripts/skill-runner.sh docker-rebuild-e2e`. Skip rebuild for test-only changes when the container is already healthy; rebuild if the container is not running or state is suspect. 2. **Test Analysis**: - Review existing test coverage diff --git a/.github/instructions/testing.instructions.md b/.github/instructions/testing.instructions.md index 4252a6c8..cbfc5f9f 100644 --- a/.github/instructions/testing.instructions.md +++ b/.github/instructions/testing.instructions.md @@ -10,7 +10,20 @@ description: 'Strict protocols for test execution, debugging, and coverage valid ### PREREQUISITE: Start E2E Environment -**CRITICAL**: Always rebuild the E2E container before running Playwright tests: +**CRITICAL**: Rebuild the E2E container when application or Docker build inputs change. If changes are test-only and the container is already healthy, reuse it. If the container is not running or state is suspect, rebuild. + +**Rebuild required (application/runtime changes):** +- Application code or dependencies: backend/**, frontend/**, backend/go.mod, backend/go.sum, package.json, package-lock.json. +- Container build/runtime configuration: Dockerfile, .docker/**, .docker/compose/docker-compose.playwright-*.yml, .docker/docker-entrypoint.sh. +- Runtime behavior changes baked into the image. + +**Rebuild optional (test-only changes):** +- Playwright tests and fixtures: tests/**. +- Playwright config and runners: playwright.config.js, playwright.caddy-debug.config.js. +- Documentation or planning files: docs/**, requirements.md, design.md, tasks.md. +- CI/workflow changes that do not affect runtime images: .github/workflows/**. + +When a rebuild is required (or the container is not running), use: ```bash .github/skills/scripts/skill-runner.sh docker-rebuild-e2e diff --git a/.github/skills/test-e2e-playwright-coverage.SKILL.md b/.github/skills/test-e2e-playwright-coverage.SKILL.md index ea9fc52b..ccd3ed6b 100644 --- a/.github/skills/test-e2e-playwright-coverage.SKILL.md +++ b/.github/skills/test-e2e-playwright-coverage.SKILL.md @@ -84,7 +84,7 @@ Runs Playwright end-to-end tests with code coverage collection using `@bgotink/p - Node.js 18.0 or higher installed and in PATH - Playwright browsers installed (`npx playwright install`) - `@bgotink/playwright-coverage` package installed -- Charon application running (default: `http://localhost:8080`) +- Charon application running (default: `http://localhost:8080`, use `docker-rebuild-e2e` when app/runtime inputs change or the container is not running) - Test files in `tests/` directory using coverage-enabled imports ## Usage diff --git a/.github/skills/test-e2e-playwright-debug.SKILL.md b/.github/skills/test-e2e-playwright-debug.SKILL.md index 252a08a2..03c7eb3a 100644 --- a/.github/skills/test-e2e-playwright-debug.SKILL.md +++ b/.github/skills/test-e2e-playwright-debug.SKILL.md @@ -104,7 +104,7 @@ Runs Playwright E2E tests in headed/debug mode for troubleshooting. This skill p - Node.js 18.0 or higher installed and in PATH - Playwright browsers installed (`npx playwright install chromium`) -- Charon application running at localhost:8080 (use `docker-rebuild-e2e` skill) +- Charon application running at localhost:8080 (use `docker-rebuild-e2e` when app/runtime inputs change or the container is not running) - Display available (X11 or Wayland on Linux, native on macOS) - Test files in `tests/` directory diff --git a/.github/skills/test-e2e-playwright.SKILL.md b/.github/skills/test-e2e-playwright.SKILL.md index 9a3f51a1..d7ba4375 100644 --- a/.github/skills/test-e2e-playwright.SKILL.md +++ b/.github/skills/test-e2e-playwright.SKILL.md @@ -89,10 +89,10 @@ The skill runs non-interactively by default (HTML report does not auto-open), ma ### Quick Start: Ensure E2E Environment is Ready -Before running tests, ensure the Docker E2E environment is running: +Before running tests, ensure the Docker E2E environment is running. Rebuild when application or Docker build inputs change. If only tests or docs changed and the container is already healthy, skip rebuild. ```bash -# Start/rebuild E2E Docker container (recommended before testing) +# Start/rebuild E2E Docker container (required when app/runtime inputs change) .github/skills/scripts/skill-runner.sh docker-rebuild-e2e # Or for a complete clean rebuild: