ci: resolve source directory from metadata entry_point (single source of truth, error on Makefile conflict) #33

Open
opened 2026-07-18 17:03:33 +00:00 by jmiller · 1 comment
Owner

Summary

Every npm workflow hardcodes src/ as the source directory. The authoritative source-dir value already lives in the MokoGIT metadata API as entry_point. Because the MokoGIT release system zips from the source directory, a wrong/duplicated source-dir value ships the wrong tree. This issue introduces a single, shared resolver so CI reads the source dir from metadata and hard-fails on any conflict with the Makefile.

Background

  • Metadata endpoint: GET ${MOKOGIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}/metadata
  • Relevant field: entry_point (e.g. source/). Today this repo returns "entry_point": "src/" (fixed in the standardization issue).
  • The Makefile references $(SRC_DIR) in the minify target but never defines it (currently empty).
  • Hardcoded src/ occurs in npm-publish.yml, npm-build-test.yml, and npm-auto-release.yml.

Requirements

  1. Add a reusable composite action at .mokogit/actions/resolve-source-dir/action.yml that:
    • GETs the metadata endpoint and reads .entry_point; normalizes the trailing slash; defaults to source/ if empty/unreachable.
    • Reads the Makefile's SRC_DIR (e.g. make -pRrq 2>/dev/null | awk -F' := ' '/^SRC_DIR /{print $2}' or a grep fallback), normalized the same way.
    • If both are present and differ → echo "::error::..." and exit 1 (do not guess).
    • If only one is present, use it. If neither, default source/.
    • Exposes outputs: source_dir (with trailing slash) and source_glob (<dir>/**).
  2. Wire the action into npm-publish.yml (this replaces PR #32's hardcoded ^src/ gate — the detect grep must use the resolved dir) and npm-build-test.yml (path filters + the src/index.ts tool-count reference).
  3. All touched workflow files keep their Copyright + SPDX header block (Moko standard).

Acceptance Criteria

  • Changing entry_point in metadata changes what the publish gate and build-test consider "source" — no workflow edit required.
  • A Makefile SRC_DIR that disagrees with metadata entry_point fails the job with a clear ::error:: message.
  • npm-publish.yml no longer contains a hardcoded ^src/ (or ^source/) literal in the detect step.
  • npm-build-test.yml path filters and tool-count path derive from the resolved dir.
  • Header blocks preserved on all edited workflow files.

Notes

  • Supersedes PR #32 (fix/npm-publish-change-gate), which hardcodes ^src/. That gate should read the resolved dir instead.
  • Depends on nothing at author time (resolver defaults to source/); pairs with the standardization issue and the release-zip issue, which consume the same entry_point.

Authored-by: Moko Consulting

## Summary Every npm workflow hardcodes `src/` as the source directory. The authoritative source-dir value already lives in the MokoGIT **metadata API** as `entry_point`. Because the MokoGIT release system **zips from the source directory**, a wrong/duplicated source-dir value ships the wrong tree. This issue introduces a single, shared resolver so CI reads the source dir from metadata and hard-fails on any conflict with the Makefile. ## Background - Metadata endpoint: `GET ${MOKOGIT_URL}/api/v1/repos/${GIT_ORG}/${GIT_REPO}/metadata` - Relevant field: **`entry_point`** (e.g. `source/`). Today this repo returns `"entry_point": "src/"` (fixed in the standardization issue). - The `Makefile` references `$(SRC_DIR)` in the `minify` target but **never defines it** (currently empty). - Hardcoded `src/` occurs in `npm-publish.yml`, `npm-build-test.yml`, and `npm-auto-release.yml`. ## Requirements 1. Add a reusable composite action at **`.mokogit/actions/resolve-source-dir/action.yml`** that: - `GET`s the metadata endpoint and reads `.entry_point`; normalizes the trailing slash; defaults to `source/` if empty/unreachable. - Reads the Makefile's `SRC_DIR` (e.g. `make -pRrq 2>/dev/null | awk -F' := ' '/^SRC_DIR /{print $2}'` or a grep fallback), normalized the same way. - **If both are present and differ → `echo "::error::..."` and `exit 1`** (do not guess). - If only one is present, use it. If neither, default `source/`. - Exposes outputs: `source_dir` (with trailing slash) and `source_glob` (`<dir>/**`). 2. Wire the action into **`npm-publish.yml`** (this replaces PR #32's hardcoded `^src/` gate — the detect grep must use the resolved dir) and **`npm-build-test.yml`** (path filters + the `src/index.ts` tool-count reference). 3. All touched workflow files keep their Copyright + SPDX header block (Moko standard). ## Acceptance Criteria - [ ] Changing `entry_point` in metadata changes what the publish gate and build-test consider "source" — no workflow edit required. - [ ] A Makefile `SRC_DIR` that disagrees with metadata `entry_point` fails the job with a clear `::error::` message. - [ ] `npm-publish.yml` no longer contains a hardcoded `^src/` (or `^source/`) literal in the detect step. - [ ] `npm-build-test.yml` path filters and tool-count path derive from the resolved dir. - [ ] Header blocks preserved on all edited workflow files. ## Notes - **Supersedes PR #32** (`fix/npm-publish-change-gate`), which hardcodes `^src/`. That gate should read the resolved dir instead. - Depends on nothing at author time (resolver defaults to `source/`); pairs with the standardization issue and the release-zip issue, which consume the same `entry_point`. Authored-by: Moko Consulting
jmiller added the size/mci-cdstandards-driftmokostandards labels 2026-07-18 17:03:33 +00:00
Author
Owner

Status: implemented, pending testing (merged to dev via PR #36, promoted to main via #39).

Testing checklist (verify in a child npm/MCP repo synced from the template):

  • Resolver reads entry_point from the metadata API and reports the resolved dir in the step log.
  • Token reaches the API via the mokogit_token input (no 401 / no silent default).
  • Set Makefile SRC_DIR ≠ metadata entry_point → job fails with the ::error::source dir conflict message.
  • Metadata unreachable with strict: 'true' (publish/release) → job fails closed; with strict: 'false' (build-test/tool-inventory) → ::warning:: + default, job continues.
  • npm-publish.yml: workflow_dispatch publishes; a README-only change publishes; a docs-only/no-source change logs the ::notice:: and skips.

Authored-by: Moko Consulting

**Status: implemented, pending testing** (merged to `dev` via PR #36, promoted to `main` via #39). Testing checklist (verify in a child npm/MCP repo synced from the template): - [ ] Resolver reads `entry_point` from the metadata API and reports the resolved dir in the step log. - [ ] Token reaches the API via the `mokogit_token` input (no 401 / no silent default). - [ ] Set Makefile `SRC_DIR` ≠ metadata `entry_point` → job **fails** with the `::error::source dir conflict` message. - [ ] Metadata unreachable with `strict: 'true'` (publish/release) → job **fails closed**; with `strict: 'false'` (build-test/tool-inventory) → `::warning::` + default, job continues. - [ ] `npm-publish.yml`: `workflow_dispatch` publishes; a README-only change publishes; a docs-only/no-source change logs the `::notice::` and skips. Authored-by: Moko Consulting
Sign in to join this conversation.