Skip to content

Commit

Permalink
ci: check version
Browse files Browse the repository at this point in the history
  • Loading branch information
CahidArda committed Nov 8, 2024
1 parent d871c0e commit 9d91801
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ jobs:
working-directory: examples/nextjs

- name: Run local tests
run: bun test .
run: node ci.mjs
working-directory: examples/nextjs

nextjs-pages-local-build:
Expand Down
32 changes: 32 additions & 0 deletions examples/nextjs/ci.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// this file is need for the Node 18 test

import { Client } from "@upstash/qstash"
import { serve } from "@upstash/workflow/nextjs"

const qstashClient = new Client({
baseUrl: "https://workflow-tests.requestcatcher.com/",
token: "mock"
})

const { POST: serveHandler } = serve(
async (context) => {
await context.sleep("sleeping", 10)
}, {
qstashClient,
receiver: undefined
}
)

const request = new Request("https://workflow-tests.requestcatcher.com/")
const response = await serveHandler(request)

const status = response.status
const body = await response.text()

if (status !== 500) {
throw new Error(`ci failed. incorrect status. status: ${status}, body: ${body}`)
}
if (body !== `{"error":"SyntaxError","message":"Unexpected token 'r', \\"request caught\\" is not valid JSON"}`) {
throw new Error(`ci failed. incorrect body. status: ${status}, body: ${body}`)
}
console.log(">>> CI SUCCESFUL")
2 changes: 2 additions & 0 deletions examples/nextjs/ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const { POST: serveHandler } = serve(
}
)

console.log(process.versions.node.split('.').map(Number));

describe("nextjs tests", () => {
test("first invocation", async () => {
const request = new Request("https://workflow-tests.requestcatcher.com/")
Expand Down
2 changes: 1 addition & 1 deletion src/context/auto-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,5 @@ const validateParallelSteps = (lazySteps: BaseLazyStep[], stepsFromRequest: Step
*/
const sortSteps = (steps: Step[]): Step[] => {
const getStepId = (step: Step) => step.targetStep || step.stepId;
return [...steps].sort((step, stepOther) => getStepId(step) - getStepId(stepOther));
return steps.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther));
};

0 comments on commit 9d91801

Please sign in to comment.