ci: source-dir resolver from metadata entry_point (Refs #33) #36

Merged
jmiller merged 3 commits from fix/ci-resolve-source-dir into dev 2026-07-18 18:22:02 +00:00
Owner

Adds .mokogit/actions/resolve-source-dir composite action that resolves the source directory from the MokoGIT metadata API (entry_point), cross-checks the Makefile SRC_DIR, and errors on conflict. Wired into npm-publish.yml, npm-build-test.yml, npm-tool-inventory.yml. Supersedes PR #32 (which hardcoded ^src/).

Refs #33.

Review status

Two review passes run before this PR (code-reviewer + silent-failure-hunter); all Critical/High findings fixed in follow-up commits:

  • Composite action reads the token via inputs (not the inaccessible secrets context in composite actions).
  • Fail-closed source-dir resolver: metadata unreachable is distinguished from absent (strict callers hard-fail rather than silently defaulting); a genuine metadata↔Makefile conflict always errors.
  • Release: set -euo pipefail, non-empty artifact assertions, and gh release upload no longer error-suppressed.

Merge order

#33 (resolver) → #34 (source/ migration) → #35 (release)#35 references the composite action introduced by #33.

Authored-by: Moko Consulting

Adds `.mokogit/actions/resolve-source-dir` composite action that resolves the source directory from the MokoGIT metadata API (`entry_point`), cross-checks the Makefile `SRC_DIR`, and **errors on conflict**. Wired into `npm-publish.yml`, `npm-build-test.yml`, `npm-tool-inventory.yml`. Supersedes PR #32 (which hardcoded `^src/`). Refs #33. ### Review status Two review passes run before this PR (code-reviewer + silent-failure-hunter); all Critical/High findings fixed in follow-up commits: - Composite action reads the token via `inputs` (not the inaccessible `secrets` context in composite actions). - **Fail-closed** source-dir resolver: metadata *unreachable* is distinguished from *absent* (strict callers hard-fail rather than silently defaulting); a genuine metadata↔Makefile conflict always errors. - Release: `set -euo pipefail`, non-empty artifact assertions, and `gh release upload` no longer error-suppressed. ### Merge order **#33 (resolver) → #34 (source/ migration) → #35 (release)** — #35 references the composite action introduced by #33. Authored-by: Moko Consulting
jmiller added 3 commits 2026-07-18 18:20:54 +00:00
Add a shared composite action `.mokogit/actions/resolve-source-dir` that
resolves the repo source directory from the MokoGIT metadata API
(`.entry_point`) and cross-checks the Makefile `SRC_DIR`, erroring on
conflict. Values are normalized to a trailing slash and default to
`source/` when empty or unreachable. Outputs `source_dir` (e.g. `source/`)
and `source_glob` (e.g. `source/**`).

Wire the resolver into two workflows:
- npm-publish.yml: add the resolver step after Checkout and a Detect
  publishable changes step whose source-dir alternative is built from the
  resolved dir instead of a literal `src/`; guard Build/bump/Publish on
  the detect output.
- npm-build-test.yml: add `source/**` alongside `src/**` in the push and
  pull_request `paths:` filters (static YAML, kept transitionally), and
  point the tool-count grep at `${source_dir}index.ts` with a fallback to
  `src/index.ts`.

Copyright + SPDX headers preserved on all workflow files.

Authored-by: Moko Consulting
Add the shared resolve-source-dir composite action to the tool inventory
workflow and drive the source entry file from its output. Replace the
hardcoded `src/index.ts` runtime greps with
`${{ steps.srcdir.outputs.source_dir }}index.ts`, falling back to
`src/index.ts` when the resolved file is absent. List both `source/index.ts`
and `src/index.ts` in the push `paths:` filter transitionally, since static
YAML cannot consume step outputs.

Copyright + SPDX header preserved.

Authored-by: Moko Consulting
ci: harden source-dir resolver (fail-closed, token input, visibility) [#33]
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 15s
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Secret Scan (pull_request) Successful in 8s
Generic: Project CI / Lint & Validate (pull_request) Successful in 25s
Universal: Auto-Assign / Assign unassigned issues and PRs (pull_request_target) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Successful in 7s
Branch Cleanup / Delete merged branch (pull_request) Successful in 2s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Generic: Project CI / Tests (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
3d1f81f613
Composite action (resolve-source-dir):
- Add inputs.mokogit_token and inputs.strict; secrets are not accessible
  inside composite actions, so the token is passed in and used in the
  metadata curl instead of ${{ secrets.* }}.
- Fail-closed metadata handling: capture curl exit status (no `|| true`).
  On curl failure, error+exit when strict=true, else warn and treat
  entry_point as absent. Parse JSON without swallowing errors (invalid
  JSON is a hard error). Keep the MOKOGIT_URL/GIT_ORG/GIT_REPO guard.
- normalize(): a resolved "." / "./" (repo root) is treated as invalid
  and mapped to empty so it can never produce a bogus HEAD:. reference.
- A genuine metadata-vs-Makefile conflict still ALWAYS errors, regardless
  of strict.

npm-publish.yml:
- Pass mokogit_token + strict:'true' to the resolve step.
- Checkout fetch-depth: 2 for the before/HEAD~1 diff on shallow clones.
- Detect short-circuits changed=true on workflow_dispatch (no diff base).
- Fix the ERE metachar escaper so '.' is escaped correctly (class lists ]
  first and [ last to avoid a [. collating-symbol parse; the replacement
  reaches sed as a literal backslash + matched char). Verified the built
  pattern still matches 'source/' as a path prefix.
- Guard Setup Node.js and Install dependencies on changed=='true'.
- Emit a ::notice:: listing files when no publishable changes are found.

npm-build-test.yml + npm-tool-inventory.yml:
- Add job-level MOKOGIT_URL/GIT_ORG/GIT_REPO env (same vars.* || github.*
  defaults) so the resolver runs consistently.
- Pass mokogit_token + strict:'false' (warn+default on unreachable
  metadata; a real conflict still errors).
- Emit a ::warning:: before falling back to src/index.ts.
- Inventory only: assert the entry file is readable before counting tools
  so an unreadable file is not silently counted as zero.

Authored-by: Moko Consulting
jmiller merged commit eb939d9acb into dev 2026-07-18 18:22:02 +00:00
jmiller deleted branch fix/ci-resolve-source-dir 2026-07-18 18:22:03 +00:00
Sign in to join this conversation.