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
24 changes: 20 additions & 4 deletions .github/workflows/ci-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ jobs:
id: cache-check
uses: actions/cache@v4
with:
path: node_modules
path: |
node_modules
*/node_modules
packages/*/node_modules
apps/*/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}
lookup-only: true

Expand All @@ -51,7 +55,11 @@ jobs:
if: steps.cache-check.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: node_modules
path: |
node_modules
*/node_modules
packages/*/node_modules
apps/*/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}

type-check:
Expand All @@ -69,7 +77,11 @@ jobs:
id: cache-check
uses: actions/cache@v4
with:
path: node_modules
path: |
node_modules
*/node_modules
packages/*/node_modules
apps/*/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-node_modules

Expand All @@ -95,7 +107,11 @@ jobs:
id: cache-check
uses: actions/cache@v4
with:
path: node_modules
path: |
node_modules
*/node_modules
packages/*/node_modules
apps/*/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-node_modules

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Deploy to Fly.io
run: |
flyctl deploy --remote-only --config fly.toml \
flyctl deploy --remote-only --config apps/api/fly.toml \
--build-secret APP_ID="${{ vars.APP_ID }}" \
--build-secret PRIVATE_KEY="${{ secrets.PRIVATE_KEY }}" \
--build-secret WEBHOOK_SECRET="${{ secrets.WEBHOOK_SECRET }}" \
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ Thumbs.db
# Misc
.cache/
tmp/

# Turborepo
.turbo/
9 changes: 7 additions & 2 deletions Dockerfile → apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ FROM oven/bun:1.3.9-alpine AS build
WORKDIR /app

COPY package.json bun.lock ./
COPY apps/api/package.json ./apps/api/
COPY packages/core/package.json ./packages/core/

RUN bun install --frozen-lockfile --ignore-scripts

COPY tsconfig.json ./
COPY src/ ./src/
COPY apps/api/ ./apps/api/
COPY packages/core/ ./packages/core/

WORKDIR /app/apps/api
RUN bun build src/server.ts --outfile=dist/server.js --target=bun

FROM oven/bun:1.3.9-alpine
Expand All @@ -17,7 +22,7 @@ RUN apk add --no-cache git

WORKDIR /app

COPY --from=build /app/dist/server.js ./server.js
COPY --from=build /app/apps/api/dist/server.js ./server.js

EXPOSE 8080

Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "api",
"private": true,
"scripts": {
"dev": "bun run --hot src/app/index.ts",
"build": "bun build src/app/index.ts --outdir=dist --target=bun",
"types:check": "tsc --noEmit --skipLibCheck",
"lint:check": "biome check .",
"lint:fix": "biome check . --write"
},
"dependencies": {
"@pr-stack/core": "workspace:*",
"hono": "^4.11.10",
"typescript": "^5.9.3"
},
"devDependencies": {
"@biomejs/biome": "2.4.2",
"@types/bun": "latest"
}
}
3 changes: 0 additions & 3 deletions src/api/index.ts → apps/api/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import ci from "./routes/ci-check";
import health from "./routes/health";
import webhook from "./routes/webhook";

// Register webhook handlers
import "../core/github/handlers/on-pr-merged";

const app = new Hono();

app.route("/ci-check", ci);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ciCheckParamsSchema, shouldSkipCI } from "@pr-stack/core";
import { type Context, Hono } from "hono";
import { shouldSkipCI } from "../../core/application/ci-check";
import { ciCheckParamsSchema } from "../schemas/ci-check.schema";

const ci = new Hono();

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { githubApp } from "@pr-stack/core";
import { type Context, Hono } from "hono";
import { githubApp } from "../../core/github/app";

const webhook = new Hono();

Expand Down
2 changes: 1 addition & 1 deletion src/server.ts → apps/api/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { serve } from "bun";
import app from "./api/index";
import app from "./app/index";

serve({
fetch: app.fetch,
Expand Down
8 changes: 8 additions & 0 deletions apps/api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
},
"include": ["src"]
}
53 changes: 47 additions & 6 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{
"name": "pr-stack",
"license": "MIT",
"type": "module",
"private": true,
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"dev:api": "bun run --hot src/api/index.ts",
"build:api": "bun build src/api/index.ts --outdir=dist --target=bun",
"types:check": "tsc --noEmit --skipLibCheck",
"lint:check": "biome check .",
"lint:fix": "biome check . --write",
"dev": "turbo run dev",
"dev:api": "turbo run dev --filter=api",
"build": "turbo run build",
"build:api": "turbo run build --filter=api",
"types:check": "turbo run types:check",
"lint:check": "turbo run lint:check",
"lint:fix": "turbo run lint:fix",
"prepare:lefthook": "lefthook install && bun -e \"const fs=require('node:fs'); fs.writeFileSync('node_modules/lefthook/bin/index.js', fs.readFileSync('node_modules/lefthook/bin/index.js', 'utf8').replace(/^#!\\/usr\\/bin\\/env\\s+node/gm, '#!\\/usr\\/bin\\/env bun'))\"",
"postinstall": "bun prepare:lefthook"
},
"dependencies": {
"@datastructures-js/deque": "^1.0.8",
"hono": "^4.11.10",
"octokit": "^5.0.5",
"typescript": "^5.9.3",
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.4.2",
"@octokit/webhooks-types": "^7.6.1",
"@types/bun": "latest"
}
"@types/bun": "latest",
"turbo": "^2.9.3"
},
"packageManager": "bun@1.3.9"
}
23 changes: 23 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@pr-stack/core",
"private": true,
"scripts": {
"build": "bun build src/index.ts --outdir=dist --target=bun",
"types:check": "tsc --noEmit --skipLibCheck",
"lint:check": "biome check .",
"lint:fix": "biome check . --write"
},
"dependencies": {
"@datastructures-js/deque": "^1.0.8",
"@octokit/plugin-retry": "^8.0.3",
"hono": "^4.11.10",
"octokit": "^5.0.5",
"typescript": "^5.9.3",
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.4.2",
"@octokit/webhooks-types": "^7.6.1",
"@types/bun": "latest"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $ } from "bun";
import type { CiCheckParams } from "../../api/schemas/ci-check.schema";
import { getInstallationArtifacts } from "../github/auth";
import type { CiCheckParams } from "../schemas/ci-check.schema";
import { GitService } from "../services/git.service";
import { OctokitService } from "../services/octokit.service";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Deque } from "@datastructures-js/deque";
import { $ } from "bun";
import type { Octokit } from "octokit";
import type {
PullRequestData,
RepositoryData,
} from "../../api/schemas/shared.schema";
import { getInstallationArtifacts } from "../github/auth";
import type { PullRequest } from "../models/pull-request.model";
import type { PullRequestData, RepositoryData } from "../schemas/shared.schema";
import { GitService } from "../services/git.service";
import { OctokitService } from "./../services/octokit.service";
import { OctokitService } from "../services/octokit.service";

const REBASE_OPT_IN_LABEL = "pr-stack:auto-rebase";

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Register side-effect handlers
import "./github/handlers/on-pr-merged";

export * from "./application/ci-check";
export * from "./application/rebase";
export * from "./github/app";
export * from "./schemas/ci-check.schema";
export * from "./schemas/shared.schema";
4 changes: 4 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src"]
}
9 changes: 6 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"allowJs": true,
"types": ["bun"],

Expand All @@ -26,6 +24,11 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
"noPropertyAccessFromIndexSignature": false,

// Monorepo aliases
"paths": {
"@pr-stack/core": ["./packages/core/src"]
}
}
}
18 changes: 18 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://turborepo.dev/schema.json",
"tasks": {
"build": {
"outputs": ["dist/**"]
},
"dev": {
"persistent": true,
"cache": false
},
"types:check": {
"dependsOn": ["^types:check"]
},
"lint:check": {},
"lint:fix": {}
},
"ui": "tui"
}
Loading