Skip to content

feat: v2 — TypeScript rewrite with Flashlight, suites, PR comment, artifacts#1

Merged
PrestaEdit merged 7 commits into
mainfrom
feat/v2-rewrite
Jul 10, 2026
Merged

feat: v2 — TypeScript rewrite with Flashlight, suites, PR comment, artifacts#1
PrestaEdit merged 7 commits into
mainfrom
feat/v2-rewrite

Conversation

@PrestaEdit

Copy link
Copy Markdown
Contributor

Summary

Full v2 rewrite of the action in TypeScript. Keeps v1 usage (token + projectId only) working unchanged, adds:

  • Flashlight (flashlight: true + ps-version:): auto-provisions a PrestaShop Docker instance for tests to target. Detects the consuming repo type from composer.json and mounts it under modules/ or themes/. Port fallback 8000→8001→8002. Container is always torn down (logs captured on failure).
  • Suite filtering (suites: BackOffice,FrontOffice): forwarded to the PHP library via PRESTAFLOW_SUITES env var. Requires the matching change already merged in php-library#50.
  • PR comment (pr-comment: true, default on pull_request events): posts a summary comment with totals table + first 10 failing tests (source location + error). Updates the same comment in place across pushes via an HTML marker. Requires permissions: pull-requests: write on the calling workflow.
  • GitHub artifacts (upload-artifacts: true by default): uploads results.json + error screenshots as prestaflow-report-<run-id>-<attempt>.
  • Rich outputs: id, report-url, passed, failed, skipped, total, duration-ms, status. All set before any setFailed(), so if: always() downstream steps can consume them.

Architecture

  • Node 20 runtime (unchanged), TypeScript strict, @vercel/ncc-bundled dist/index.js committed.
  • Isolated modules: inputs, flashlight/{mount,compose-template,docker}, runner/{composer,suites}, upload/{api,artifacts}, reporter/{parse-results,outputs,pr-comment-body,pr-comment}. Single orchestrator in src/main.ts.
  • Uses the multi-suite envelope introduced in php-library#50 ({ "suites": [...] } with per-test source location). Legacy single-suite payload also parsed for backward compat.

Backward compatibility

v1 workflows (only token + projectId) continue to work: same endpoint, same payload, same id output.

Test plan

  • npm run lint — clean
  • npm test — 12 suites, 41 tests, all passing
  • npm run build — dist rebuilt (6.4 MB)
  • CI workflow .github/workflows/ci.yml fails when dist/ is stale
  • Smoke test on a consumer repo (PrestaFlow/prestaflow-prestashop) after merge and before tagging v2.0.0

Docs

Full docs updated in a separate PR on PrestaFlow/prestaflow.io.

Follow-ups

  • Tag v2.0.0 + moving v2 tag once this is merged and smoke-tested.

🤖 Generated with Claude Code

PrestaEdit and others added 7 commits July 10, 2026 20:40
- TypeScript 5.x with strict mode + ncc bundling to dist/index.js
- Jest with ts-jest for unit tests
- ESLint (@typescript-eslint) with plugin:recommended
- Node 20 runtime kept from v1
- Removes legacy github-action.js (replaced by TS sources)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- inputs.ts: parseInputs() with defaults for all 9 v2 inputs
- reporter/parse-results.ts: aggregates the multi-suite payload from
  php-library into a unified TestReport (passed/failed/skipped/todos/
  total/durationMs/failures with source location)
- reporter/outputs.ts: setOutputs() writes all GH Action outputs
- Fixtures for success, failure, multi-suite, and legacy shapes

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- buildCommentBody(): success (short form) and failure (table + <details>)
  markdown bodies, prefixed with an HTML marker for update-in-place
- postOrUpdatePrComment(): lists PR comments, updates the marker-matched
  one or creates a new one; failures logged as warnings, never throws

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- runComposer(): runs `composer run prestaflow:json:file` when
  composer.json is present; skips otherwise
- suitesEnv(): CSV list -> PRESTAFLOW_SUITES env var for the PHP lib

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- upload/api.ts: multipart POST to https://api.prestaflow.io/ci/github-action/
  (v1 endpoint/payload preserved for backward compatibility); returns
  {id, url}
- upload/artifacts.ts: uploads results.json + error screenshots as
  prestaflow-report-<runId>-<attempt> via @actions/artifact v2

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- mount.ts: resolves container mount target from composer.json type
  (prestashop-module/theme) with sensible fallbacks
- compose-template.ts: renders docker-compose.yml (image, port, volume,
  env)
- docker.ts: pickPort() with 8000-8002 fallback, assertDockerAvailable(),
  startFlashlight() with readiness poll and teardown handle
  (logs on failure via core.startGroup)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- main.ts: full v2 flow (inputs -> optional flashlight -> composer ->
  parse -> upload API/artifacts -> setOutputs -> optional PR comment ->
  setFailed on regressions, with finally teardown of the flashlight
  container). Outputs set before setFailed so `if: always()` steps can
  consume them.
- action.yml: publishes 9 inputs and 8 outputs for v2
- README.md: quick start + Flashlight example + docs pointer
- .github/workflows/ci.yml: PR/main lint + test + build + dist
  freshness check

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@PrestaEdit
PrestaEdit merged commit 19265bd into main Jul 10, 2026
1 check passed
@PrestaEdit
PrestaEdit deleted the feat/v2-rewrite branch July 10, 2026 18:54
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