Recipes
Common Inngest CI tasks, with the code for each and the page that explains it.
Inngest CI is an Inngest Labs project: early, moving fast, and shaped by your feedback. What's Labs?
Services and waiting
| Task | Code | Learn more |
|---|---|---|
| Start a server | const server = await $`pnpm start`.background() | Reference |
| Wait for a port | await waitForPort(3000) | Reference |
| Wait for a health check | await waitForHttp("http://127.0.0.1:3000/health") | Reference |
| Read server logs | await server.output() | Reference |
| Stop a server | await server.kill() | Reference |
| Wait for other checks | await github.waitForChecks({ names: ["vercel"] }) | Reference |
| Wait for an Actions workflow | await github.waitForWorkflow({ workflow: "npm_test.yml" }) | Reference |
| Run another pipeline | await step.invoke("contracts", { function: contracts, data: { sha } }) | Jobs |
Tests
| Task | Code | Learn more |
|---|---|---|
| Build once, test many | await from(build) | Machines |
| Skip unchanged tests | cache: { key: files("src/**", "test/**") } | Caching |
| Retry a flaky command | await $`pnpm test`.retries(2) | Commands |
| Test every Node version | ci.matrix over axes: { node: ["20", "22"] } | Jobs |
| Dump state when a command hangs | await $`pnpm test`.timeout("10m").onTimeout(async () => { return $`ps auxf`; }) | Reference |
Pull requests
| Task | Code | Learn more |
|---|---|---|
| Post a sticky comment | await github.stickyComment("preview", `Preview: ${url}`) | Reference |
| Annotate the diff | await report.annotate([{ path, line, message }]) | Checks and reports |
| Add a check summary | await report.summary("**Coverage:** 91%") | Checks and reports |
| Open or update a pull request | await github.upsertPullRequest({ head: "release/next", title, body }) | Reference |
| Alert on a broken main | A pipeline on github.checkSuite({ branch: "main" }) | Pipelines |
Changes and triggers
| Task | Code | Learn more |
|---|---|---|
| Run on changed files | if (await changed("docs/**")) { await docsSite(); } | Pipelines |
| Skip a whole run | return ci.skip("nothing changed") | Pipelines |
| Watch another repository | on: github.push({ repo: "inngest/inngestgo", branches: ["main"] }) | Pipelines |
| Slash commands | on: github.comment({ command: "/prerelease", minPermission: "write" }) | Pipelines |
| Typed manual runs | on: ci.manual({ pipelineId: "deploy", schema }) | Reference |
| Move a branch with no machine | await github.forcePushRef("heads/next", sha) | Reference |
| Cancel superseded runs | singleton: { key: "event.data.pull_request.number", mode: "cancel" } | Pipelines |
Debugging
| Task | Code | Learn more |
|---|---|---|
| Keep a failed machine | ci.job({ id: "test", keepOnFailure: "24h" }, fn) | Reference |
| Name a command in the trace | await $`pnpm test`.as("unit tests") | Commands |
| Turn off a job's check | ci.job({ id: "notify", check: false }, fn) | Checks and reports |
| Rename the pipeline check | check: { name: "CI" } | Pipelines |