From 7b8f266039397bdb8cec4535ed745d8d54145a18 Mon Sep 17 00:00:00 2001 From: ccurme Date: Mon, 10 Mar 2025 08:59:59 -0400 Subject: [PATCH] infra: additional testing on core release (#30180) Here we add a job to the release workflow that, when releasing `langchain-core`, tests prior published versions of select packages against the new version of core. We limit the testing to the most recent published versions of langchain-anthropic and langchain-openai. This is designed to catch backward-incompatible updates to core. We sometimes update core and downstream packages simultaneously, so there may not be any commit in the history at which tests would fail. So although core and latest downstream packages could be consistent, we can benefit from testing prior versions of downstream packages against core. I tested the workflow by simulating a [breaking change](https://github.com/langchain-ai/langchain/pull/30180/commits/d7287248cf6edd0c4224f3b2dea65805802f8248) in core and running it with publishing steps disabled: https://github.com/langchain-ai/langchain/actions/runs/13741876345. The workflow correctly caught the issue. --- .github/workflows/_release.yml | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index 92dd272b769..e72ed2bce79 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -312,12 +312,79 @@ jobs: run: make integration_tests working-directory: ${{ inputs.working-directory }} + # Test select published packages against new core + test-prior-published-packages-against-new-core: + needs: + - build + - release-notes + - test-pypi-publish + - pre-release-checks + if: ${{ startsWith(inputs.working-directory, 'libs/core') }} + runs-on: ubuntu-latest + strategy: + matrix: + partner: [openai, anthropic] + fail-fast: false # Continue testing other partners if one fails + env: + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }} + AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} + AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }} + AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME }} + AZURE_OPENAI_LLM_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LLM_DEPLOYMENT_NAME }} + AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uv + uses: "./.github/actions/uv_setup" + with: + python-version: ${{ env.PYTHON_VERSION }} + + - uses: actions/download-artifact@v4 + with: + name: dist + path: ${{ inputs.working-directory }}/dist/ + + - name: Test against ${{ matrix.partner }} + run: | + # Identify latest tag + LATEST_PACKAGE_TAG="$( + git ls-remote --tags origin "langchain-${{ matrix.partner }}*" \ + | awk '{print $2}' \ + | sed 's|refs/tags/||' \ + | sort -Vr \ + | head -n 1 + )" + echo "Latest package tag: $LATEST_PACKAGE_TAG" + + # Shallow-fetch just that single tag + git fetch --depth=1 origin tag "$LATEST_PACKAGE_TAG" + + # Navigate to the partner directory + cd $GITHUB_WORKSPACE/libs/partners/${{ matrix.partner }} + + # Checkout the latest package files + git checkout "$LATEST_PACKAGE_TAG" -- . + + # Print as a sanity check + echo "Version number from pyproject.toml: " + cat pyproject.toml | grep "version = " + + # Run tests + uv sync --group test --group test_integration + uv pip install ../../core/dist/*.whl + make integration_tests + publish: needs: - build - release-notes - test-pypi-publish - pre-release-checks + - test-prior-published-packages-against-new-core runs-on: ubuntu-latest permissions: # This permission is used for trusted publishing: