Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end to end test suite to test NextJS app in Edge runtime w/TS client #304

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
44 changes: 34 additions & 10 deletions .github/actions/e2e-testing/edge/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Spin up Vercel App
inputs:
vercel-token:
required: true
description: 'Vercel token to deploy the app'
PINECONE_API_KEY:
required: true
description: 'Pinecone API key to send requests to the Vercel app'

runs:
using: 'composite'
Expand All @@ -27,27 +31,47 @@ runs:
uses: GuillaumeFalourd/clone-github-repo-action@main
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for the previous step: npm pack packages up the existing code on the existing branch, so it'll run the code devs are proposing to merge in their PR, rather than whatever code is on npm etc. This removes the need for us to merge things before testing them end to end.

with:
owner: 'pinecone-io'
repository: 'pinecone-rag-demo'
branch: 'main'
repository: 'ts-client-e2e-tests'
branch: 'Audrey/add-app'
aulorbe marked this conversation as resolved.
Show resolved Hide resolved

- name: Move package to pinecone-rag-demo
run: cd pinecone-rag-demo && mv ../pinecone-database-pinecone-*.tgz .
- name: Move package to ts-client-e2e-tests
run: mkdir ts-client-e2e-tests && cd ts-client-e2e-tests && mv ../pinecone-database-pinecone-*.tgz .
shell: bash

- name: Install rag-demo deps
run: cd pinecone-rag-demo && npm install
- name: Install e2e tests dependencies
run: cd ts-client-e2e-tests && npm install
shell: bash

- name: Install pinecone-ts-client "main" branch code into the Vercel app
run: cd pinecone-rag-demo && npm install pinecone-database-pinecone-*.tgz
run: cd ts-client-e2e-tests && npm install pinecone-database-pinecone-*.tgz
shell: bash

- name: Install Vercel CLI
run: cd pinecone-rag-demo && npm install vercel
run: cd ts-client-e2e-tests && npm install vercel
shell: bash

- name: Deploy Project Artifacts to Vercel
- name: Deploy app to Vercel
run: |
cd pinecone-rag-demo
cd ts-client-e2e-tests
vercel --scope=pinecone-io --token=${{ inputs.vercel-token }} --yes
shell: bash

- name: Send POST request to endpoint Vercel app endpoint api/createSeedQuery
run: |
API_URL="https://ts-client-e2e-tests.vercel.app/api/createSeedQuery"
API_KEY=${{ inputs.PINECONE_API_KEY }}
response=$(curl --silent --location --request POST "$API_URL" --header "PINECONE_API_KEY: $API_KEY")

match_count=$(echo "$response" | jq '.queryResult.matches | length')
if [ $? -ne 0 ]; then
echo "Error: Request failed."
exit 1
fi

if [ "$match_count" -lt 1 ]; then
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we assert on the response in CI

echo "Error: Expected at least one result in queryResult.matches, but found none."
exit 1
else
echo "Success: Found $match_count result(s) in queryResult.matches."
fi
shell: bash
1 change: 1 addition & 0 deletions .github/workflows/e2e-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
uses: ./.github/actions/e2e-testing/edge
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
Loading