diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8f63a1b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,45 @@ +version: 2 + +updates: + - package-ecosystem: "bun" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "09:00" + timezone: "Asia/Shanghai" + open-pull-requests-limit: 5 + labels: + - "dependencies" + commit-message: + prefix: "chore" + include: "scope" + groups: + bun-minor-patch: + update-types: + - "minor" + - "patch" + patterns: + - "*" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "monday" + time: "09:30" + timezone: "Asia/Shanghai" + open-pull-requests-limit: 3 + labels: + - "dependencies" + - "github-actions" + commit-message: + prefix: "ci" + include: "scope" + groups: + github-actions-minor-patch: + update-types: + - "minor" + - "patch" + patterns: + - "*" diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml new file mode 100644 index 0000000..1fce0fc --- /dev/null +++ b/.github/workflows/auto-merge.yml @@ -0,0 +1,58 @@ +name: Auto Merge + +on: + pull_request_target: + types: + - opened + - synchronize + - reopened + - ready_for_review + - labeled + - unlabeled + +permissions: + contents: write + pull-requests: write + +concurrency: + group: auto-merge-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + enable-auto-merge: + if: > + github.event.pull_request.draft == false && + github.event.pull_request.base.ref == 'main' && + contains(github.event.pull_request.labels.*.name, 'dependencies') && + ( + github.event.pull_request.head.repo.full_name == github.repository || + github.event.pull_request.user.login == 'dependabot[bot]' + ) + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Enable GitHub auto-merge + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: gh pr merge --auto --squash "$PR_URL" + + disable-auto-merge: + if: > + github.event.action == 'unlabeled' && + github.event.label.name == 'dependencies' && + github.event.pull_request.base.ref == 'main' && + ( + github.event.pull_request.head.repo.full_name == github.repository || + github.event.pull_request.user.login == 'dependabot[bot]' + ) + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Disable GitHub auto-merge + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: gh pr merge --disable-auto "$PR_URL" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e23e187..0caaf78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ permissions: jobs: validate: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - name: Check out repository @@ -25,6 +26,9 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile + - name: Generate Worker types + run: bun run cf-typegen + - name: Type check run: bun run typecheck diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bb9b868..1f20028 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,9 @@ concurrency: jobs: deploy: + if: ${{ secrets.CLOUDFLARE_API_TOKEN != '' && secrets.CLOUDFLARE_ACCOUNT_ID != '' }} runs-on: ubuntu-latest + timeout-minutes: 20 env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} @@ -33,11 +35,11 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile + - name: Generate Worker types + run: bun run cf-typegen + - name: Validate before deploy run: bun run check - - name: Verify Wrangler dry-run build - run: bunx wrangler deploy --dry-run - - name: Deploy Worker run: bun run deploy diff --git a/.gitignore b/.gitignore index d07aed6..bde7871 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ .wrangler/ coverage/ dist/ +worker-configuration.d.ts .dev.vars .env .DS_Store diff --git a/bun.lock b/bun.lock index 03d902e..1caf6ed 100644 --- a/bun.lock +++ b/bun.lock @@ -8,11 +8,11 @@ "@getpaseo/relay": "^0.1.52", }, "devDependencies": { - "@cloudflare/vitest-pool-workers": "^0.8.40", - "@types/node": "^24.3.0", - "typescript": "^5.9.2", + "@cloudflare/vitest-pool-workers": "^0.8.71", + "@types/node": "^24.12.2", + "typescript": "^5.9.3", "vitest": "^3.2.4", - "wrangler": "^4.39.0", + "wrangler": "^4.81.1", }, }, }, diff --git a/package.json b/package.json index 2bf518a..b247616 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,21 @@ { "name": "paseo-relay", - "version": "0.1.0", "private": true, + "license": "MIT", "type": "module", + "repository": { + "type": "git", + "url": "https://github.com/xixu-me/paseo-relay.git" + }, + "bugs": { + "url": "https://github.com/xixu-me/paseo-relay/issues" + }, + "homepage": "https://github.com/xixu-me/paseo-relay", "scripts": { "dev": "bunx wrangler dev", "deploy": "bunx wrangler deploy", - "check": "bun run typecheck && bun run test && bun run cf-typegen:check", - "typecheck": "tsc --noEmit", + "check": "bun run typecheck && bun run test && bun run cf-typegen:check && bunx wrangler deploy --dry-run", + "typecheck": "bun run cf-typegen && tsc --noEmit", "test": "vitest run", "test:watch": "vitest", "cf-typegen": "bunx wrangler types", @@ -17,11 +25,11 @@ "@getpaseo/relay": "^0.1.52" }, "devDependencies": { - "@cloudflare/vitest-pool-workers": "^0.8.40", - "@types/node": "^24.3.0", - "typescript": "^5.9.2", + "@cloudflare/vitest-pool-workers": "^0.8.71", + "@types/node": "^24.12.2", + "typescript": "^5.9.3", "vitest": "^3.2.4", - "wrangler": "^4.39.0" + "wrangler": "^4.81.1" }, "packageManager": "bun@1.3.12" } diff --git a/wrangler.jsonc b/wrangler.jsonc index c83ac42..d73ebe2 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -3,21 +3,37 @@ "name": "paseo-relay", "main": "src/index.ts", "compatibility_date": "2026-04-11", + "workers_dev": false, "alias": { - "@getpaseo/relay/cloudflare": "./node_modules/@getpaseo/relay/dist/cloudflare-adapter.js" + "@getpaseo/relay/cloudflare": "./node_modules/@getpaseo/relay/dist/cloudflare-adapter.js", }, "durable_objects": { "bindings": [ { "name": "RELAY", - "class_name": "RelayDurableObject" - } - ] + "class_name": "RelayDurableObject", + }, + ], }, "migrations": [ { "tag": "v1", - "new_sqlite_classes": ["RelayDurableObject"] - } - ] + "new_sqlite_classes": ["RelayDurableObject"], + }, + ], + "observability": { + "enabled": true, + "head_sampling_rate": 1, + "logs": { + "enabled": true, + "head_sampling_rate": 1, + "persist": true, + "invocation_logs": true, + }, + "traces": { + "enabled": true, + "persist": true, + "head_sampling_rate": 1, + }, + }, }