From 1e7c393e185b8a954258ac8cce9690d969937d5d Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Mon, 27 Nov 2023 16:44:01 -0800 Subject: [PATCH] Refactor test (#86) * Refactor test runner --- .github/workflows/javascript_tests.yaml | 13 +++++-------- javascript-sdk/package.json | 2 +- javascript-sdk/tests/setup-and-run-tests.sh | 3 +-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/javascript_tests.yaml b/.github/workflows/javascript_tests.yaml index ad68e68..17e3272 100644 --- a/.github/workflows/javascript_tests.yaml +++ b/.github/workflows/javascript_tests.yaml @@ -15,9 +15,6 @@ jobs: test: runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'okay-to-test') || (github.event_name == 'push') - env: - CHROMA_URL: http://localhost:8000 - CHROMA_COLLECTION_NAME: javascript_tests steps: # https://github.com/actions/checkout/issues/518 @@ -26,9 +23,6 @@ jobs: with: ref: "${{ github.event.pull_request.merge_commit_sha }}" - - name: Install dependencies - run: make init-js-sdk - - name: Run tests working-directory: javascript-sdk env: @@ -36,9 +30,12 @@ jobs: PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} PINECONE_ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }} PINECONE_INDEX_NAME: ${{ secrets.PINECONE_INDEX_NAME }} + CHROMA_URL: http://localhost:8000 + CHROMA_COLLECTION_NAME: javascript_tests run: | - tests/setup-and-run-tests.sh - + npm install + npm test + - name: Dump docker logs if: failure() run: docker logs chroma diff --git a/javascript-sdk/package.json b/javascript-sdk/package.json index 486060c..e27f293 100644 --- a/javascript-sdk/package.json +++ b/javascript-sdk/package.json @@ -10,7 +10,7 @@ "lint": "eslint .", "lint:fix": "eslint . --fix", "lint:debug": "eslint src/sdk.ts --debug", - "test": "mocha --require ts-node/register tests/**/*.test.ts" + "test": "tests/setup-and-run-tests.sh" }, "repository": { "type": "git", diff --git a/javascript-sdk/tests/setup-and-run-tests.sh b/javascript-sdk/tests/setup-and-run-tests.sh index 6a95fa9..565a6d5 100755 --- a/javascript-sdk/tests/setup-and-run-tests.sh +++ b/javascript-sdk/tests/setup-and-run-tests.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash set -e # Exit with nonzero exit code if anything fails +set -x echo "Starting chroma server..." -export CHROMA_URL=http://localhost:8000 -export CHROMA_COLLECTION_NAME=javascript_tests docker pull chromadb/chroma docker stop chroma || true docker rm chroma || true