Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 69 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,71 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

permissions:
contents: read

jobs:
static:
name: Static Analysis & Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0

- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
node-version: 22
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Check build coverage
run: npm run check:builds

- name: Build packages
run: npm run build:packages

- name: Validate package exports
run: |
npm run check:exports
for dir in packages/*/; do
echo "publint $dir"
(cd "$dir" && npx --no-install publint) || exit 1
done

- name: Static Analysis (Typecheck)
run: npm run typecheck && npm run typecheck:all

- name: Static Analysis (Lint)
run: npm run lint

- name: Build (client bundle)
run: npx vite build

- name: Build (worker bundle, dry run)
run: cd apps/worker && npx wrangler deploy --dry-run --outdir=.wrangler/dry

verify:
name: Verify Stability
needs: static
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgres:16
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: codra_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-cmd "pg_isready -U postgres -d codra_test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
Expand Down Expand Up @@ -69,53 +114,45 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Check build coverage
run: npm run check:builds

- name: Build packages
run: npm run build:packages

- name: Validate package exports
run: |
npm run check:exports
for dir in packages/*/; do
echo "publint $dir"
(cd "$dir" && npx --no-install publint) || exit 1
done

- name: Static Analysis (Typecheck)
run: npm run typecheck && npm run typecheck:all

- name: Static Analysis (Lint)
run: npm run lint
- name: Build packages, client, and Node server
run: npm run build:node

- name: Automated Tests
run: npm test

- name: Automated Tests (packages)
run: npm run test:all

- name: Build (client bundle)
run: npx vite build

- name: Build (worker bundle, dry run)
run: cd apps/worker && npx wrangler deploy --dry-run --outdir=.wrangler/dry
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-

- name: Install Playwright browsers
run: npx playwright install chromium --with-deps
- name: Install Playwright Chromium
run: |
if [ "${{ steps.playwright-cache.outputs.cache-hit }}" != "true" ]; then
npx playwright install chromium --with-deps
else
npx playwright install-deps chromium
fi

- name: Prepare E2E environment
run: |
cp .env.e2e.example .env.e2e
node -e "import('postgres').then(async ({default: p}) => { const sql = p('postgresql://postgres:postgres@127.0.0.1:5432/postgres'); await sql\`CREATE DATABASE codra_e2e\`.catch(() => {}); await sql.end(); })"
node -e "import('postgres').then(async ({default: p}) => { const sql = p('postgresql://postgres:postgres@127.0.0.1:5432/postgres'); try { await sql\`CREATE DATABASE codra_e2e\`; } catch (err) { if (err?.code !== '42P04') throw err; } finally { await sql.end(); } })"
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432/codra_e2e npm run migrate

- name: Run Playwright E2E tests
run: npm run test:e2e
id: e2e
run: npx playwright test

- name: Upload Playwright report
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
if: failure()
if: failure() && steps.e2e.outcome == 'failure'
with:
name: playwright-report
path: playwright-report/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { CopyButton, FileDiff } from "@codraoss/ui";
import { memo, useState, type ComponentPropsWithoutRef } from "react";
import {
isValidElement,
memo,
useState,
type ComponentPropsWithoutRef,
} from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { FileText, ThumbsDown, ThumbsUp } from "lucide-react";
Expand All @@ -26,6 +31,18 @@ const DISPOSITION_LABEL: Record<string, string> = {
};

export const markdownComponents = {
pre({
children,
...props
}: ComponentPropsWithoutRef<"pre">) {
if (
isValidElement<{ className?: string }>(children) &&
/language-(?:diff|patch)(?::|\b)/.test(children.props?.className ?? "")
) {
return <>{children}</>;
}
return <pre {...props}>{children}</pre>;
},
code({
className,
children,
Expand Down
2 changes: 1 addition & 1 deletion apps/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ COPY --from=builder /app/packages/db/scripts ./packages/db/scripts

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=3s CMD ["/nodejs/bin/node", "-e", "fetch('http://127.0.0.1:3000/health').then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD ["/nodejs/bin/node", "-e", "fetch('http://127.0.0.1:3000/health/ready').then((response) => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"]

CMD ["apps/node/dist/index.js"]
Loading
Loading