Skip to content

Add PR validation workflow with publish-preview signal - #18

Merged
rafaeelricco merged 11 commits into
mainfrom
adding-ci-for-PR
Apr 18, 2026
Merged

Add PR validation workflow with publish-preview signal#18
rafaeelricco merged 11 commits into
mainfrom
adding-ci-for-PR

Conversation

@rafaeelricco

Copy link
Copy Markdown
Owner

Motivation

Another valuable addition to the CI/CD process during PRs, ensuring only valid code gets merged. Enjoy!

What's New

CI/CD PR Validation Workflow

  • New .github/workflows/pr-validate.yml runs on pull_request events (opened, synchronize, reopened).
  • Job checks runs pnpm run typecheck, pnpm exec prettier . --check, and pnpm run build with the same GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET secrets used by publish.yml.
  • Job publish-preview compares package.json version against github.event.pull_request.base.sha, validates a forward semver bump via npm install -g semver, and queries the NPM registry for collisions.
  • Verdict written to $GITHUB_STEP_SUMMARY: Will publish on merge, No publish on merge, or failure on invalid/colliding bumps.
  • Pins actions/checkout@v6 and actions/setup-node@v6 (latest stable majors).

Project Layout Restructure

  • src/app/commands/*src/cli/* (commit, doctor, model, setup).
  • src/app/cli.tssrc/cli/parser.ts.
  • src/app/services/*src/infra/llm/* (anthropic, gemini, openai).
  • src/app/services/llm.tssrc/domain/llm/router.ts.
  • src/app/integrations.tssrc/infra/env.ts.
  • src/lib/*src/infra/* (auth, git, storage, ui).

Domain Layer Consolidation

  • New src/domain/llm/response-parser.ts centralizes AI response extraction across providers.
  • New src/domain/llm/auth-resolver.ts owns resolveProvider in the domain layer.
  • Added exhaustiveness utility in src/libs/types.ts.
  • Extracted src/infra/ui/model-picker.ts from other modules.

Housekeeping

  • Kebab-case filenames: authResolver.tsauth-resolver.ts, responseParser.tsresponse-parser.ts, model.tsmodels.ts.
  • package.json version bumped to 0.2.4.
  • .claude directory added to .gitignore.
  • README.md documents Anthropic as a supported provider.

PR Validate Flow

graph TD
    PR[PR opened / updated] --> Checks[Job: checks]
    PR --> Preview[Job: publish-preview]

    Checks --> TC[typecheck → prettier check → build]

    Preview --> Decide{package.json<br/>version changed?}
    Decide -->|No| NoPub[No publish on merge]
    Decide -->|Yes, valid bump,<br/>not on NPM| WillPub[Will publish on merge]
    Decide -->|Invalid bump<br/>or already on NPM| Fail[Fail the check]

    WillPub -.on merge.-> Publish[publish.yml → NPM]
    NoPub -.on merge.-> Skip[publish.yml skips]

    style Checks fill:#e1f5ff
    style Preview fill:#e1f5ff
    style WillPub fill:#c8e6c9
    style NoPub fill:#fff9c4
    style Fail fill:#ffcdd2
    style Publish fill:#c8e6c9
Loading

Testing & Feedback

  • Verify checks job runs typecheck, prettier --check, and build on every push to this PR.
  • Verify publish-preview reports No publish on merge while package.json version stays at 0.2.4; bump the version on a follow-up PR to exercise the Will publish on merge path.
  • Confirm imports resolve after the src/app/src/cli/ / src/domain/ / src/infra/ restructure (typecheck is the backstop).
  • Confirm all providers (anthropic, gemini, openai) go through the centralized response-parser.ts and auth-resolver.ts.
  • After merging, confirm publish.yml publishes 0.2.4 to NPM as expected.

If you find any bugs or have recommendations for improvements, please open an issue and assign it to me.

- Introduce `absurd` helper in `libs/types.ts` to replace ad-hoc `_exhaustiveCheck: never` patterns across the codebase
- Add `responseParser.ts` in `domain/provider` defining `RawResponse` and `extractResponse`, consolidating all per-provider text extraction logic into one place
- Refactor `anthropic.ts`, `gemini.ts`, and `openai.ts` to return raw API responses and delegate to `extractResponse`, removing duplicated empty-response checks
- Move `resolveProvider.ts` to `domain/provider/authResolver.ts` and replace inline exhaustiveness guards with `absurd`
- Update `prompts.ts` to accept `Maybe<string>` for the custom template instead of `string | undefined`, and fix a typo ("comic" → "commit")
- Update `llm.ts` and `commit.ts` signatures to pass `Maybe<string>` for `customTemplate`, eliminating `??` fallback logic at call sites
- Update imports in `commit.ts` and `model.ts` to use `resolveProvider` from `@/domain/provider/authResolver` instead of `@/app/services/resolveProvider`.
- Update imports in `anthropic.ts`, `gemini.ts`, and `openai.ts` to use `extractResponse` from `@/domain/provider/responseParser` instead of `@/app/services/responseExtractor`.
…omain/llm`

- Rename all files under `src/libs/` to `src/utils/`, updating all internal imports accordingly.
- Move `src/app/services/{anthropic,gemini,openai,llm}.ts` to `src/app/llm/`.
- Move `src/domain/provider/{authResolver,responseParser}.ts` to `src/domain/llm/`.
- Update all import paths across the codebase to reflect the new directory structure.
- Move command entry points from `src/app/commands` to `src/cli` and rename `cli.ts` to `cli/parser.ts`.
- Relocate infrastructure code (auth, git, llm providers, storage, ui, env) from `src/app` and `src/lib` into `src/infra`.
- Rename `src/utils` to `src/libs` and update all related imports across the codebase.
- Move LLM routing to `src/domain/llm/router.ts` and rename `domain/commit/model.ts` to `models.ts`.
- Extract `selectModelInteractively` into new `src/infra/ui/model-picker.ts` and move `model-selector` component under `src/infra/ui`.
- Update all `@/` path imports throughout `index.ts` and source files to reflect the new structure.
- Rename `authResolver.ts` to `auth-resolver.ts` and `responseParser.ts` to `response-parser.ts` for consistent file naming.
- Update all import paths in `commit.ts`, `model.ts`, `anthropic.ts`, `gemini.ts`, and `openai.ts` to reflect the new filenames.
- Add Anthropic (Claude) to the AI provider selection during setup.
- Document `claude setup-token` auth method alongside API key option.
- Move Anthropic from "coming soon" to the supported providers list.
- Reorder auth method descriptions to match each provider's options.
- Add a GitHub Actions workflow that runs on pull request open, sync, and reopen events.
- Run repository checkout, Node.js setup, dependency installation, typechecking, formatting checks, and project build validation.
- Add a preview job that compares `package.json` versions between the PR base and head to detect whether merging will trigger an npm publish.
- Reject invalid semver values, non-forward version bumps, and versions that are already published to npm.
- Write clear PR step summaries describing whether the merge will publish a new package version or why validation failed.
@rafaeelricco rafaeelricco self-assigned this Apr 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ccc1b3358

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/pr-validate.yml Outdated
@rafaeelricco

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b853c96ad

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/pr-validate.yml Outdated
@rafaeelricco
rafaeelricco merged commit b700b06 into main Apr 18, 2026
3 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.

1 participant