Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

ci.ts

33 lines1.3 KB

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`. The CI image already
5// has a pnpm, so `--force` replaces its `pnpm`/`pnpx` binaries.
6const setupPnpm = {
7 name: "Set up pnpm",
8 run: `npm install --global --force "pnpm@$(node -p 'require("./package.json").devEngines.packageManager.version')"`,
9};
10const install = { name: "Install", run: "pnpm install --frozen-lockfile" };
11​
12// Checks every pull request into `v2`, and deploys each push to `v2` to
13// https://v2.trytanstackdb.com (see `cloudflare.config.ts`).
14export default defineWorkflow("ci", {
15 on: [pullRequest({ branches: ["v2"] }), push({ branches: ["v2"] })],
16})
17 .job("check", {
18 egress: ["registry.npmjs.org"],
19 steps: [
20 setupPnpm,
21 install,
22 { name: "Format, lint and type check", run: "pnpm exec vp check" },
23 { name: "Test", run: "pnpm exec vp test" },
24 ],
25 })
26 .job("deploy", {
27 needs: ["check"],
28 if: (ctx) => ctx.event === "push",
29 secrets: { CLOUDFLARE_API_TOKEN: {} },
30 egress: ["registry.npmjs.org", "api.cloudflare.com"],
31 env: { CF_SEND_TELEMETRY: "false" },
32 steps: [setupPnpm, install, { name: "Deploy", run: "pnpm exec cf deploy" }],
33 });