Skip to content

fix(cli): omit per-module .github/ for in-repo create-module (#210) - #211

Merged
antosubash merged 3 commits into
mainfrom
fix-210-create-module-ci-skip
Jun 16, 2026
Merged

fix(cli): omit per-module .github/ for in-repo create-module (#210)#211
antosubash merged 3 commits into
mainfrom
fix-210-create-module-ci-skip

Conversation

@antosubash

Copy link
Copy Markdown
Owner

What

smpy create-module <name> scaffolds a .github/ (ci.yml + publish.yml) inside the module. For a module created inside an existing host repo — the documented monorepo modules/* layout — these are dead weight at best and a footgun at worst:

  1. Nested workflow dirs never run. GitHub only executes workflows from the repository-root .github/workflows/, so modules/<name>/.github/workflows/*.yml never triggers.
  2. ci.yml assumes the module is the repo root (runs uv sync/ruff/pytest from .) — wrong working dir/dependency graph inside a host's uv workspace.
  3. publish.yml is a PyPI-publish footgun — triggers on any v* tag to publish simple_module_<name> via OIDC.

Resolves the last of the issues from the consumer-app feedback batch (the others — #199/#200/#203/#206 — were resolved in #209 / v0.0.19; #210 was not covered).

Approach (context detection + opt-in flag, both implemented)

  • create_module() gains include_ci (default True, so the low-level API and its existing tests are unchanged). When False, the scaffolded .github/ is removed.
  • The CLI computes include_ci = standalone or not is_inside_existing_repo(target):
    • In-repo dest (an ancestor has .git or pyproject.toml) → omit .github/ by default, and print a discoverable note pointing at --standalone.
    • --standalone → always emit .github/ (for a module that lives in its own repo).
    • Truly standalone target (no repo/pyproject ancestor) → emit .github/ as before.
  • New is_inside_existing_repo() helper in scaffolding.py.
  • app_project._scaffold_sample_module (the smpy new sample module) now uses include_ci=False instead of a manual rmtree(".github") — same effect, one code path.

Tests

framework/cli/tests/test_create_module_ci_skip.py:

  • create_module(include_ci=False) omits .github/; default ships it.
  • CLI omits .github/ for an in-repo dest (+ prints the note); --standalone forces it; a clean standalone target keeps it.
  • Unit coverage for is_inside_existing_repo (.git parent, pyproject parent, clean target — the module's own scaffolded pyproject.toml doesn't count).

Verification

  • uv run pytest framework/cli/tests/173 passed.
  • Full Python suite → 1343 passed (the 2 failures are a pre-existing test-isolation quirk in framework/hosting/framework/testing, unrelated to this change — identical on main).
  • ruff check + ruff format --check + ty + 300-line file-size cap + readmes — all clean. scaffolding.py stays under the cap (298 lines).

Closes #210

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: ddbfbc3
Status: ✅  Deploy successful!
Preview URL: https://2306b78a.simple-module-python.pages.dev
Branch Preview URL: https://fix-210-create-module-ci-ski.simple-module-python.pages.dev

View logs

@antosubash
antosubash force-pushed the fix-210-create-module-ci-skip branch from cdf500f to b0e4a09 Compare June 15, 2026 22:36
…e_router

FastAPI 0.137 / Starlette 1.3 made `include_router()` lazy: included routes no
longer appear in `app.routes` (they sit behind `_IncludedRouter` wrappers and
resolve only at request time). Tests that introspected `app.routes` by `.path`
stopped seeing module/health routes — so `test_expected_routes_registered` and
`test_registers_module_routes_with_prefix` failed even though the routes still
work at runtime. (Surfaced via dependency drift since the last green run.)

- Add `simple_module_test.effective_route_paths(app)`: reads the OpenAPI schema
  (fully-resolved prefixes) unioned with top-level mounts — version-agnostic,
  and the supported way to assert on registered routes.
- Use it in the affected hosting/testing route tests; the absence assertions
  (`test_isolates_*`, `test_modules_enabled_*`) become meaningful again instead
  of passing vacuously under lazy inclusion.

The dashboard's bare-prefix Inertia alias is `include_in_schema=False`; its
behaviour stays covered by `TestProtectedPages`.
@antosubash

Copy link
Copy Markdown
Owner Author

Note: this PR's Python tests CI failure is a pre-existing failure on main (FastAPI 0.137 lazy include_router broke two route-introspection tests), not introduced by this change — the diff here is CLI-only (framework/cli/ + docs). It's fixed in #212; merging that first turns this PR's CI green. Verified locally: full suite 1345 passed with #212 applied.

`smpy create-module` scaffolds a `.github/` (ci.yml + publish.yml) that only
makes sense for a module living in its own repo. Inside an existing host repo
(the documented `modules/*` layout) those nested workflows never run — GitHub
only reads the repo-root `.github/workflows/` — and `publish.yml` (PyPI publish
on any `v*` tag) is a footgun.

- `create_module()` gains `include_ci` (default True); when False, the
  scaffolded `.github/` is removed.
- The CLI detects an in-repo dest (ancestor `.git`/`pyproject.toml`) and omits
  `.github/` by default with a discoverable note; `--standalone` forces it.
- New `is_inside_existing_repo()` helper in `scaffolding.py`.
- `app_project._scaffold_sample_module` now passes `include_ci=False` instead
  of a manual `rmtree`.

Closes #210
@antosubash
antosubash force-pushed the fix-210-create-module-ci-skip branch from b0e4a09 to 04e5d23 Compare June 15, 2026 23:03
@antosubash
antosubash changed the base branch from main to fix-fastapi-0137-route-tests June 15, 2026 23:03
@antosubash

Copy link
Copy Markdown
Owner Author

Restacked onto #212's branch so this PR's CI runs with the FastAPI-0.137 test fix included (the previous red was that pre-existing main failure, not this change). GitHub will auto-retarget this PR's base to main once #212 merges. Merge order: #212 first, then this PR (which closes #210).

@antosubash
antosubash changed the base branch from fix-fastapi-0137-route-tests to main June 16, 2026 05:26
@antosubash
antosubash merged commit b483cec into main Jun 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create-module scaffolds per-module .github/workflows that never run (and publish.yml is a footgun) for in-repo modules

1 participant