From c635688ddb587f11fe75a002786c8090efa9e38a Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 8 May 2024 12:36:54 -0700 Subject: [PATCH] Nick: test suite --- .github/workflows/test_suite.yml | 62 ++++++++++++++++++++++++++++++++ apps/test-suite/index.test.ts | 9 ++--- 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test_suite.yml diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.yml new file mode 100644 index 0000000..6a80d2e --- /dev/null +++ b/.github/workflows/test_suite.yml @@ -0,0 +1,62 @@ +name: Test Suite +on: + push: + branches: + - main + +env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + BULL_AUTH_KEY: ${{ secrets.BULL_AUTH_KEY }} + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} + HOST: ${{ secrets.HOST }} + LLAMAPARSE_API_KEY: ${{ secrets.LLAMAPARSE_API_KEY }} + LOGTAIL_KEY: ${{ secrets.LOGTAIL_KEY }} + POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} + POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }} + NUM_WORKERS_PER_QUEUE: ${{ secrets.NUM_WORKERS_PER_QUEUE }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + PLAYWRIGHT_MICROSERVICE_URL: ${{ secrets.PLAYWRIGHT_MICROSERVICE_URL }} + PORT: ${{ secrets.PORT }} + REDIS_URL: ${{ secrets.REDIS_URL }} + SCRAPING_BEE_API_KEY: ${{ secrets.SCRAPING_BEE_API_KEY }} + SUPABASE_ANON_TOKEN: ${{ secrets.SUPABASE_ANON_TOKEN }} + SUPABASE_SERVICE_TOKEN: ${{ secrets.SUPABASE_SERVICE_TOKEN }} + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + TEST_API_KEY: ${{ secrets.TEST_API_KEY }} + + +jobs: + pre-deploy: + name: Pre-deploy checks + runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6379:6379 + steps: + - uses: actions/checkout@v3 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + - name: Install pnpm + run: npm install -g pnpm + - name: Install dependencies + run: pnpm install + working-directory: ./apps/api + - name: Start the application + run: npm start & + working-directory: ./apps/api + id: start_app + - name: Start workers + run: npm run workers & + working-directory: ./apps/api + id: start_workers + - name: Install dependencies + run: pnpm install + working-directory: ./apps/test-suite + - name: Run E2E tests + run: | + npm run test + working-directory: ./apps/test-suite \ No newline at end of file diff --git a/apps/test-suite/index.test.ts b/apps/test-suite/index.test.ts index 3414843..d0dcbe9 100644 --- a/apps/test-suite/index.test.ts +++ b/apps/test-suite/index.test.ts @@ -5,6 +5,7 @@ import { numTokensFromString } from "./utils/tokens"; import OpenAI from "openai"; import { WebsiteScrapeError } from "./utils/types"; import { logErrors } from "./utils/log"; + const websitesData = require("./data/websites.json"); import "dotenv/config"; @@ -18,14 +19,14 @@ interface WebsiteData { expected_output: string; } +const TEST_URL = "http://127.0.0.1:3002"; + + describe("Scraping/Crawling Checkup (E2E)", () => { beforeAll(() => { if (!process.env.TEST_API_KEY) { throw new Error("TEST_API_KEY is not set"); } - if (!process.env.TEST_URL) { - throw new Error("TEST_URL is not set"); - } if (!process.env.OPENAI_API_KEY) { throw new Error("OPENAI_API_KEY is not set"); } @@ -53,7 +54,7 @@ describe("Scraping/Crawling Checkup (E2E)", () => { const batchPromise = Promise.all( batch.map(async (websiteData: WebsiteData) => { try { - const scrapedContent = await request(process.env.TEST_URL || "") + const scrapedContent = await request(TEST_URL || "") .post("/v0/scrape") .set("Content-Type", "application/json") .set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)