3 Commits

Author SHA1 Message Date
peptiderepo
029c090361 ci: fix deploy.yml permissions and secrets for reusable workflow
Deploy workflow must declare `permissions: contents: write` at workflow level
to allow the nested reusable ci.yml (which needs write for phpcbf auto-commit)
to run. Also adds `secrets: inherit` to the ci job so secrets propagate through.

Pre-existing issue introduced during CI standardization (startup_failure root cause).

Agent-Session: fix-e2e-ref-20260617
2026-06-17 11:29:02 +07:00
peptiderepo
7994d43eec ci: fix peptide-e2e reusable-workflow org ref (peptiderepo→peptide-repo) (#9)
Reusable workflow uses: refs do not follow GitHub transfer redirects.
Update owner string from peptiderepo to peptide-repo post org-migration.

Agent-Session: fix-e2e-ref-20260617
2026-06-17 11:17:12 +07:00
peptiderepo
31ad0463f7 Adopt reusable CI standard + PHPUnit suite (#8)
* feat(ci): adopt estate CI + add PHPUnit suite from scratch (v1.2.0)

- Add PHPUnit 9.6 test suite (WP stubs, tests: stubs) — 40 tests across 4 files:
  MathTest: 25 tests covering all PRC_Math public methods and calculate()
  orchestrator with real peptide scenarios (BPC-157/TB-500/Semaglutide/MK-677/
  Ipamorelin) plus edge cases (zero water, negative inputs, floor rounding,
  rounding precision, mcg↔mg conversion).
  DefaultPresetsTest: 11 tests — all 8 expected slugs, required keys per preset
  (dataProvider), dose_unit validity, min<max range, source field, spot-checks.
  RestControllerTest: 7 tests — calculate() 200 + correct values (mcg+mg),
  get_presets() 200, get_preset() 200 for known slug / WP_Error for unknown.
  PresetProviderTest: 4 tests — fallback to defaults sans PR Core, slug key
  present, cache invalidation, idempotent invalidation.
- Add phpunit.xml.dist + tests/bootstrap.php (WP function/class stubs).
- Add composer test script: vendor/bin/phpunit --configuration phpunit.xml.dist.
- Add phpunit/phpunit ^9.6 + yoast/phpunit-polyfills ^2.0 to require-dev.
- Replace standalone ci.yml with thin caller to estate reusable workflow:
  uses: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main
  with: tests: stubs, has_js: true
  permissions: contents: write (required for phpcbf commit-back)
  workflow_call (required for deploy.yml gate).
- deploy.yml unchanged — already gates on ./ci.yml + uses shared deploy-app.yml.
- Version bump 1.1.0 → 1.2.0.

Agent-Session: claude/adopt-ci-20260616

* style: auto-fix PHPCS violations via phpcbf

* fix(ci): resolve latent PHPCS + JS lint failures

Latent debt surfaced by the reusable PHPCS job (previously continue-on-error).

PHPCS fixes (all pre-existing, not introduced by this PR):
- Add @package PeptideReconstitutionCalculator to file docblocks in all 12 PHP
  files (previously missing; phpcbf cannot insert missing docblock tags).
- Replace two short-ternary ?: operators in class-prc-preset-provider.php with
  full ternary (Universal.Operators.DisallowShortTernary.Found; lines 136+152).

JS lint fix:
- Add package.json + package-lock.json (no deps; lint script = node --check)
  so the reusable lint-js job's npm ci / cache: npm steps succeed. The
  calculator ships vanilla JS with no build toolchain — package.json is the
  minimal stub the reusable workflow requires for has_js: true.

Agent-Session: claude/adopt-ci-20260616

* style: auto-fix PHPCS violations via phpcbf

* fix(phpcs): suppress intentional warnings with phpcs:ignore annotations

uninstall.php: direct wpdb->query() intentional in uninstall (no caching
available); add phpcs:ignore DirectDatabaseQuery.DirectQuery and NoCaching.
class-prc-rest-controller.php get_presets(): request param required by
WP REST API callback contract; add phpcs:ignore UnusedFunctionParameter.

Agent-Session: claude/adopt-ci-20260616

---------

Co-authored-by: peptiderepo <bot@peptiderepo.com>
Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
2026-06-17 01:25:11 +07:00
2 changed files with 5 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
# #
# Delegates all lint/test/file-size jobs to the estate reusable workflow. # Delegates all lint/test/file-size jobs to the estate reusable workflow.
# Per estate standard: workflow_call is required so deploy.yml can gate on it. # Per estate standard: workflow_call is required so deploy.yml can gate on it.
# See: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main for job definitions. # See: peptide-repo/peptide-e2e/.github/workflows/ci.yml@main for job definitions.
## ##
name: CI name: CI
@@ -20,7 +20,7 @@ permissions:
jobs: jobs:
ci: ci:
uses: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main uses: peptide-repo/peptide-e2e/.github/workflows/ci.yml@main
with: with:
tests: stubs tests: stubs
has_js: true has_js: true

View File

@@ -5,7 +5,7 @@ on:
branches: [ main ] branches: [ main ]
permissions: permissions:
contents: read contents: write
concurrency: concurrency:
group: deploy-peptide-reconstitution-calculator group: deploy-peptide-reconstitution-calculator
@@ -15,11 +15,12 @@ jobs:
ci: ci:
name: Pre-deploy CI name: Pre-deploy CI
uses: ./.github/workflows/ci.yml uses: ./.github/workflows/ci.yml
secrets: inherit
deploy: deploy:
name: Deploy (shared pipeline) name: Deploy (shared pipeline)
needs: ci needs: ci
uses: peptiderepo/peptide-e2e/.github/workflows/deploy-app.yml@main uses: peptide-repo/peptide-e2e/.github/workflows/deploy-app.yml@main
with: with:
target_path: wp-content/plugins/peptide-reconstitution-calculator target_path: wp-content/plugins/peptide-reconstitution-calculator
secrets: inherit secrets: inherit