2023-01-16 02:35:21 +00:00
|
|
|
name: release
|
2024-01-05 23:24:57 +00:00
|
|
|
run-name: Release ${{ inputs.working-directory }} by @${{ github.actor }}
|
2023-01-16 02:35:21 +00:00
|
|
|
on:
|
2023-07-21 16:20:24 +00:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
working-directory:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: "From which folder this pipeline executes"
|
2023-12-11 21:53:30 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
working-directory:
|
|
|
|
required: true
|
infra: cut down on integration steps (#14785)
<!-- Thank you for contributing to LangChain!
Replace this entire comment with:
- **Description:** a description of the change,
- **Issue:** the issue # it fixes (if applicable),
- **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!
Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.
See contribution guidelines for more information on how to write/run
tests, lint, etc:
https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md
If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.
If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
-->
---------
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-12-17 20:55:59 +00:00
|
|
|
type: string
|
2023-12-11 21:53:30 +00:00
|
|
|
default: 'libs/langchain'
|
2023-01-16 02:35:21 +00:00
|
|
|
|
|
|
|
env:
|
2023-10-30 21:10:14 +00:00
|
|
|
PYTHON_VERSION: "3.10"
|
2024-01-17 16:51:20 +00:00
|
|
|
POETRY_VERSION: "1.7.1"
|
2023-01-16 02:35:21 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-10-30 21:10:14 +00:00
|
|
|
build:
|
2023-12-11 22:40:24 +00:00
|
|
|
if: github.ref == 'refs/heads/master'
|
2024-01-18 22:28:01 +00:00
|
|
|
environment: Scheduled testing
|
2023-01-16 02:35:21 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-10-30 21:10:14 +00:00
|
|
|
|
|
|
|
outputs:
|
|
|
|
pkg-name: ${{ steps.check-version.outputs.pkg-name }}
|
|
|
|
version: ${{ steps.check-version.outputs.version }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
|
|
|
uses: "./.github/actions/poetry_setup"
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
cache-key: release
|
|
|
|
|
|
|
|
# We want to keep this build stage *separate* from the release stage,
|
|
|
|
# so that there's no sharing of permissions between them.
|
|
|
|
# The release stage has trusted publishing and GitHub repo contents write access,
|
|
|
|
# and we want to keep the scope of that access limited just to the release job.
|
|
|
|
# Otherwise, a malicious `build` step (e.g. via a compromised dependency)
|
|
|
|
# could get access to our GitHub or PyPI credentials.
|
|
|
|
#
|
|
|
|
# Per the trusted publishing GitHub Action:
|
|
|
|
# > It is strongly advised to separate jobs for building [...]
|
|
|
|
# > from the publish job.
|
|
|
|
# https://github.com/pypa/gh-action-pypi-publish#non-goals
|
|
|
|
- name: Build project for distribution
|
|
|
|
run: poetry build
|
2023-10-30 23:58:34 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-10-30 21:10:14 +00:00
|
|
|
|
|
|
|
- name: Upload build
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: dist
|
|
|
|
path: ${{ inputs.working-directory }}/dist/
|
|
|
|
|
|
|
|
- name: Check Version
|
|
|
|
id: check-version
|
|
|
|
shell: bash
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
run: |
|
2023-11-01 01:36:26 +00:00
|
|
|
echo pkg-name="$(poetry version | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
|
2023-10-30 21:10:14 +00:00
|
|
|
echo version="$(poetry version --short)" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
test-pypi-publish:
|
|
|
|
needs:
|
|
|
|
- build
|
2023-11-01 01:36:38 +00:00
|
|
|
uses:
|
|
|
|
./.github/workflows/_test_release.yml
|
|
|
|
with:
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
secrets: inherit
|
2023-10-31 17:02:50 +00:00
|
|
|
|
2023-10-30 21:10:14 +00:00
|
|
|
pre-release-checks:
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
- test-pypi-publish
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-12-14 21:28:13 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
2023-10-30 21:10:14 +00:00
|
|
|
# We explicitly *don't* set up caching here. This ensures our tests are
|
|
|
|
# maximally sensitive to catching breakage.
|
|
|
|
#
|
|
|
|
# For example, here's a way that caching can cause a falsely-passing test:
|
|
|
|
# - Make the langchain package manifest no longer list a dependency package
|
|
|
|
# as a requirement. This means it won't be installed by `pip install`,
|
|
|
|
# and attempting to use it would cause a crash.
|
|
|
|
# - That dependency used to be required, so it may have been cached.
|
|
|
|
# When restoring the venv packages from cache, that dependency gets included.
|
|
|
|
# - Tests pass, because the dependency is present even though it wasn't specified.
|
|
|
|
# - The package is published, and it breaks on the missing dependency when
|
|
|
|
# used in the real world.
|
2023-12-14 21:11:19 +00:00
|
|
|
|
|
|
|
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
|
|
|
uses: "./.github/actions/poetry_setup"
|
2023-10-30 21:10:14 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2023-12-14 21:11:19 +00:00
|
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-10-30 21:10:14 +00:00
|
|
|
|
2023-12-14 21:11:19 +00:00
|
|
|
- name: Import published package
|
2023-10-30 21:10:14 +00:00
|
|
|
shell: bash
|
2023-12-15 00:57:41 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-10-30 21:10:14 +00:00
|
|
|
env:
|
|
|
|
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
|
|
|
|
VERSION: ${{ needs.build.outputs.version }}
|
2023-11-14 23:08:35 +00:00
|
|
|
# Here we use:
|
|
|
|
# - The default regular PyPI index as the *primary* index, meaning
|
|
|
|
# that it takes priority (https://pypi.org/simple)
|
|
|
|
# - The test PyPI index as an extra index, so that any dependencies that
|
2023-10-30 21:10:14 +00:00
|
|
|
# are not found on test PyPI can be resolved and installed anyway.
|
2023-11-14 23:08:35 +00:00
|
|
|
# (https://test.pypi.org/simple). This will include the PKG_NAME==VERSION
|
|
|
|
# package because VERSION will not have been uploaded to regular PyPI yet.
|
infra: retry release if not found on test pypi (#15913)
<!-- Thank you for contributing to LangChain!
Please title your PR "<package>: <description>", where <package> is
whichever of langchain, community, core, experimental, etc. is being
modified.
Replace this entire comment with:
- **Description:** a description of the change,
- **Issue:** the issue # it fixes if applicable,
- **Dependencies:** any dependencies required for this change,
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!
Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` from the root
of the package you've modified to check this locally.
See contribution guidelines for more information on how to write/run
tests, lint, etc: https://python.langchain.com/docs/contributing/
If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.
If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
-->
2024-01-12 17:36:52 +00:00
|
|
|
# - attempt install again after 5 seconds if it fails because there is
|
|
|
|
# sometimes a delay in availability on test pypi
|
2023-10-30 21:10:14 +00:00
|
|
|
run: |
|
2023-12-15 00:57:41 +00:00
|
|
|
poetry run pip install \
|
2023-11-14 23:08:35 +00:00
|
|
|
--extra-index-url https://test.pypi.org/simple/ \
|
infra: retry release if not found on test pypi (#15913)
<!-- Thank you for contributing to LangChain!
Please title your PR "<package>: <description>", where <package> is
whichever of langchain, community, core, experimental, etc. is being
modified.
Replace this entire comment with:
- **Description:** a description of the change,
- **Issue:** the issue # it fixes if applicable,
- **Dependencies:** any dependencies required for this change,
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!
Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` from the root
of the package you've modified to check this locally.
See contribution guidelines for more information on how to write/run
tests, lint, etc: https://python.langchain.com/docs/contributing/
If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.
If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
-->
2024-01-12 17:36:52 +00:00
|
|
|
"$PKG_NAME==$VERSION" || \
|
|
|
|
( \
|
|
|
|
sleep 5 && \
|
|
|
|
poetry run pip install \
|
|
|
|
--extra-index-url https://test.pypi.org/simple/ \
|
|
|
|
"$PKG_NAME==$VERSION" \
|
|
|
|
)
|
2023-10-30 21:10:14 +00:00
|
|
|
|
2023-10-31 16:40:34 +00:00
|
|
|
# Replace all dashes in the package name with underscores,
|
|
|
|
# since that's how Python imports packages with dashes in the name.
|
|
|
|
IMPORT_NAME="$(echo "$PKG_NAME" | sed s/-/_/g)"
|
|
|
|
|
2023-12-15 00:57:41 +00:00
|
|
|
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
|
2023-10-30 21:10:14 +00:00
|
|
|
|
2023-12-14 21:11:19 +00:00
|
|
|
- name: Import test dependencies
|
|
|
|
run: poetry install --with test,test_integration
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
|
|
|
|
# Overwrite the local version of the package with the test PyPI version.
|
|
|
|
- name: Import published package (again)
|
2023-12-15 00:57:41 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-12-14 21:11:19 +00:00
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
|
|
|
|
VERSION: ${{ needs.build.outputs.version }}
|
|
|
|
run: |
|
|
|
|
poetry run pip install \
|
|
|
|
--extra-index-url https://test.pypi.org/simple/ \
|
|
|
|
"$PKG_NAME==$VERSION"
|
|
|
|
|
2023-12-15 00:57:41 +00:00
|
|
|
- name: Run unit tests
|
|
|
|
run: make tests
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
|
2024-01-05 23:03:39 +00:00
|
|
|
- name: 'Authenticate to Google Cloud'
|
|
|
|
id: 'auth'
|
|
|
|
uses: google-github-actions/auth@v2
|
|
|
|
with:
|
|
|
|
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
|
|
|
|
|
2023-12-14 21:11:19 +00:00
|
|
|
- name: Run integration tests
|
|
|
|
if: ${{ startsWith(inputs.working-directory, 'libs/partners/') }}
|
|
|
|
env:
|
|
|
|
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
|
2023-12-20 02:55:19 +00:00
|
|
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
2023-12-19 15:34:19 +00:00
|
|
|
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
|
2023-12-20 02:48:32 +00:00
|
|
|
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
|
2024-01-05 23:03:28 +00:00
|
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
2024-01-18 22:20:02 +00:00
|
|
|
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
|
2024-01-18 22:06:38 +00:00
|
|
|
GOOGLE_SEARCH_API_KEY: ${{ secrets.GOOGLE_SEARCH_API_KEY }}
|
2024-01-18 22:12:00 +00:00
|
|
|
GOOGLE_CSE_ID: ${{ secrets.GOOGLE_CSE_ID }}
|
2023-12-14 21:11:19 +00:00
|
|
|
run: make integration_tests
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
|
2024-01-03 16:28:35 +00:00
|
|
|
- name: Run unit tests with minimum dependency versions
|
2024-01-03 16:34:46 +00:00
|
|
|
if: ${{ (inputs.working-directory == 'libs/langchain') || (inputs.working-directory == 'libs/community') || (inputs.working-directory == 'libs/experimental') }}
|
2024-01-03 16:28:35 +00:00
|
|
|
run: |
|
|
|
|
poetry run pip install -r _test_minimum_requirements.txt
|
|
|
|
make tests
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-12-14 21:11:19 +00:00
|
|
|
|
2023-10-30 21:10:14 +00:00
|
|
|
publish:
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
- test-pypi-publish
|
|
|
|
- pre-release-checks
|
|
|
|
runs-on: ubuntu-latest
|
2023-08-21 18:44:29 +00:00
|
|
|
permissions:
|
|
|
|
# This permission is used for trusted publishing:
|
|
|
|
# https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
|
|
|
|
#
|
|
|
|
# Trusted publishing has to also be configured on PyPI for each package:
|
|
|
|
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
|
|
|
|
id-token: write
|
2023-08-22 15:38:18 +00:00
|
|
|
|
2023-10-30 21:10:14 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
|
|
|
uses: "./.github/actions/poetry_setup"
|
|
|
|
with:
|
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
cache-key: release
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: dist
|
|
|
|
path: ${{ inputs.working-directory }}/dist/
|
|
|
|
|
|
|
|
- name: Publish package distributions to PyPI
|
|
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
with:
|
|
|
|
packages-dir: ${{ inputs.working-directory }}/dist/
|
|
|
|
verbose: true
|
|
|
|
print-hash: true
|
|
|
|
|
|
|
|
mark-release:
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
- test-pypi-publish
|
|
|
|
- pre-release-checks
|
|
|
|
- publish
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
# This permission is needed by `ncipollo/release-action` to
|
|
|
|
# create the GitHub release.
|
2023-08-22 15:38:18 +00:00
|
|
|
contents: write
|
2023-10-30 21:10:14 +00:00
|
|
|
|
2023-07-21 16:20:24 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-10-30 21:10:14 +00:00
|
|
|
|
2023-01-16 02:35:21 +00:00
|
|
|
steps:
|
2023-10-23 14:01:33 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-28 14:20:48 +00:00
|
|
|
|
|
|
|
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }}
|
|
|
|
uses: "./.github/actions/poetry_setup"
|
2023-01-16 02:35:21 +00:00
|
|
|
with:
|
2023-10-30 21:10:14 +00:00
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2023-08-28 14:20:48 +00:00
|
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
cache-key: release
|
|
|
|
|
2023-10-30 21:10:14 +00:00
|
|
|
- uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: dist
|
|
|
|
path: ${{ inputs.working-directory }}/dist/
|
|
|
|
|
2023-01-16 02:35:21 +00:00
|
|
|
- name: Create Release
|
|
|
|
uses: ncipollo/release-action@v1
|
2023-07-29 00:16:51 +00:00
|
|
|
if: ${{ inputs.working-directory == 'libs/langchain' }}
|
2023-01-16 02:35:21 +00:00
|
|
|
with:
|
|
|
|
artifacts: "dist/*"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
draft: false
|
|
|
|
generateReleaseNotes: true
|
2023-10-30 21:10:14 +00:00
|
|
|
tag: v${{ needs.build.outputs.version }}
|
2023-01-16 02:35:21 +00:00
|
|
|
commit: master
|