Open History to see the last commit
1import { defineWorkflow, pullRequest, push } from "@tanstack-source/ci";
2
3// `setup.pnpm()` reads only the top-level `packageManager` field, but this
4// project names its pnpm in `devEngines.packageManager`.
5const setupPnpm = {
6 name: "Set up pnpm",
7 run: `npm install --global "pnpm@$(node -p 'require("./package.json").devEngines.packageManager.version')"`,
8};
9const install = { name: "Install", run: "pnpm install --frozen-lockfile" };
10
11// Checks every pull request into `v2`, and deploys each push to `v2` to
12// https://v2.trytanstackdb.com (see `cloudflare.config.ts`).
13export default defineWorkflow("ci", {
14 on: [pullRequest({ branches: ["v2"] }), push({ branches: ["v2"] })],
15})
16 .job("check", {
17 egress: ["registry.npmjs.org"],
18 steps: [
19 setupPnpm,
20 install,
21 { name: "Format, lint and type check", run: "pnpm exec vp check" },
22 { name: "Test", run: "pnpm exec vp test" },
23 ],
24 })
25 .job("deploy", {
26 needs: ["check"],
27 if: (ctx) => ctx.event === "push",
28 secrets: { CLOUDFLARE_API_TOKEN: {} },
29 egress: ["registry.npmjs.org", "api.cloudflare.com"],
30 env: { CF_SEND_TELEMETRY: "false" },
31 steps: [setupPnpm, install, { name: "Deploy", run: "pnpm exec cf deploy" }],
32 });