Skip to content

Commit

Permalink
Add pages router test to nextjs example (#51)
Browse files Browse the repository at this point in the history
* feat: add pages router test to nextjs example

* chore: rename

* fix: ci teamid and organize envs
  • Loading branch information
ytkimirti authored Oct 25, 2024
1 parent 2ac9010 commit 6d1c549
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ jobs:
nextjs-deployed:
concurrency: nextjs-deployed
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: "prj_TmF7Y5rOxDXmq7FmuzCpL41ol7zo"
UPSTASH_VECTOR_REST_URL: ${{ secrets.UPSTASH_VECTOR_REST_URL }}
UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.UPSTASH_VECTOR_REST_TOKEN }}
needs:
- release
steps:
Expand All @@ -192,9 +197,6 @@ jobs:

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: "prj_MWdHzEWUMU4b1DmVGIMu3v8lhdoO"
working-directory: examples/nextjs

- name: Install dependencies
Expand All @@ -203,11 +205,6 @@ jobs:

- name: Build Project
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: "prj_MWdHzEWUMU4b1DmVGIMu3v8lhdoO"
UPSTASH_VECTOR_REST_URL: ${{ secrets.UPSTASH_VECTOR_REST_URL }}
UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.UPSTASH_VECTOR_REST_TOKEN }}
working-directory: examples/nextjs

- name: Deploy to Vercel
Expand All @@ -216,17 +213,11 @@ jobs:
--env UPSTASH_VECTOR_REST_URL=${{ secrets.UPSTASH_VECTOR_REST_URL }} \
--env UPSTASH_VECTOR_REST_TOKEN=${{ secrets.UPSTASH_VECTOR_REST_TOKEN }})
echo "DEPLOYMENT_URL=${DEPLOYMENT_URL}" >> $GITHUB_ENV
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: "prj_MWdHzEWUMU4b1DmVGIMu3v8lhdoO"
working-directory: examples/nextjs

- name: Test
run: bun test ci.test.ts
working-directory: examples/nextjs
env:
UPSTASH_VECTOR_REST_URL: ${{ secrets.UPSTASH_VECTOR_REST_URL }}
UPSTASH_VECTOR_REST_TOKEN: ${{ secrets.UPSTASH_VECTOR_REST_TOKEN }}

release:
name: Release
Expand Down
9 changes: 9 additions & 0 deletions examples/nextjs/ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ test("the server is running", async () => {

}, { timeout: 10000 });

test("pages router is working", async () => {
const res = await fetch(`${deploymentURL}/api/pages-test`);

if (res.status !== 200) {
console.log(await res.text());
}

expect(res.status).toEqual(200);
})

9 changes: 9 additions & 0 deletions examples/nextjs/src/pages/api/pages-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { index } from "@/app/api/vector";
import { NextApiRequest, NextApiResponse } from "next";

// This is a test route to check if imports are working with pages router
export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
const result = await index.query({ data: "test query", topK: 3, includeData: true })

res.status(200).json({ result })
}

0 comments on commit 6d1c549

Please sign in to comment.