From b13f5c526e40884a994eef8aa4c6172c163e1044 Mon Sep 17 00:00:00 2001 From: Anirudh31415926535 Date: Tue, 9 Jul 2024 18:48:34 +0800 Subject: [PATCH] Add tests for langchain (#533) * Add tests for langchain * update langchain-cohere test to ensure that no new files are created * use current cohere-python changes for langchain-cohere test * logging for more infos * add more logging * minor logic changes to test ci * add cd dir * update cd dir * update paths * clean up ci.yaml file * Move langchain-cohere test to separate workflow * remove langchain-cohere from ci workflow * update python version to 3.10.14 * use same ci file for workflow * Update .github/workflows/ci.yml Co-authored-by: harry-cohere <127103098+harry-cohere@users.noreply.github.com> * Update ci.yml to use github actions poetry install * Poetry install --with test,test_integration * update poetry configs * Nits --------- Co-authored-by: harry-cohere <127103098+harry-cohere@users.noreply.github.com> --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05fd2f275..cc8a964a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,10 @@ jobs: with: python-version: 3.8 - name: Bootstrap poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + uses: snok/install-poetry@v1 + with: + version: 1.5.1 + virtualenvs-in-project: false - name: Install dependencies run: poetry install - name: Compile @@ -28,15 +30,66 @@ jobs: with: python-version: 3.8 - name: Bootstrap poetry - run: | - curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 + uses: snok/install-poetry@v1 + with: + version: 1.5.1 + virtualenvs-in-project: false - name: Install dependencies run: poetry install - name: Test run: poetry run pytest . env: CO_API_KEY: ${{ secrets.COHERE_API_KEY }} - + + test-langchain-cohere: + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: 3.10.14 + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + with: + version: 1.5.1 + virtualenvs-in-project: false + - name: Install dependencies + run: poetry install + - name: Test langchain-cohere + run: | + echo "Initial dir $(pwd)" + cd .. + echo "Cloning langchain-cohere..." + git clone https://github.com/langchain-ai/langchain-cohere.git && cd langchain-cohere/libs/cohere + echo "Cloned langchain-cohere, current dir $(pwd)" + + echo "poetry install --with test,test_integration" + poetry install --with test,test_integration + + echo "Going to uninstall cohere package, and install the current version from the repo" + cd ../../../cohere-python && echo "Current dir $(pwd)" + echo "Current dir $(ls)" + pip uninstall cohere + pip install . + cd ../langchain-cohere/libs/cohere + + echo "Current cohere installation: $(pip freeze | grep cohere)" + make test + make integration_test + echo "tests passed" + + set -eu + + STATUS="$(git status)" + echo "$STATUS" + + # grep will exit non-zero if the target message isn't found, + # and `set -e` above will cause the step to fail. + echo "$STATUS" | grep 'nothing to commit, working tree clean' + env: + COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} publish: needs: [compile, test]