mirror of
https://github.com/hwchase17/langchain
synced 2024-11-11 19:11:02 +00:00
c2a3021bb0
Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Dan O'Donovan <dan.odonovan@gmail.com> Co-authored-by: Tom Daniel Grande <tomdgrande@gmail.com> Co-authored-by: Grande <Tom.Daniel.Grande@statsbygg.no> Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com> Co-authored-by: ZhangShenao <15201440436@163.com> Co-authored-by: Friso H. Kingma <fhkingma@gmail.com> Co-authored-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Nuno Campos <nuno@langchain.dev> Co-authored-by: Morgante Pell <morgantep@google.com>
109 lines
4.2 KiB
YAML
109 lines
4.2 KiB
YAML
name: lint
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
working-directory:
|
|
required: true
|
|
type: string
|
|
description: "From which folder this pipeline executes"
|
|
python-version:
|
|
required: true
|
|
type: string
|
|
description: "Python version to use"
|
|
|
|
env:
|
|
POETRY_VERSION: "1.7.1"
|
|
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
|
|
|
|
# This env var allows us to get inline annotations when ruff has complaints.
|
|
RUFF_OUTPUT_FORMAT: github
|
|
|
|
jobs:
|
|
build:
|
|
name: "make lint #${{ inputs.python-version }}"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ inputs.python-version }} + Poetry ${{ env.POETRY_VERSION }}
|
|
uses: "./.github/actions/poetry_setup"
|
|
with:
|
|
python-version: ${{ inputs.python-version }}
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
working-directory: ${{ inputs.working-directory }}
|
|
cache-key: lint-with-extras
|
|
|
|
- name: Check Poetry File
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry check
|
|
|
|
- name: Check lock file
|
|
shell: bash
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry lock --check
|
|
|
|
- name: Install dependencies
|
|
# Also installs dev/lint/test/typing dependencies, to ensure we have
|
|
# type hints for as many of our libraries as possible.
|
|
# This helps catch errors that require dependencies to be spotted, for example:
|
|
# https://github.com/langchain-ai/langchain/pull/10249/files#diff-935185cd488d015f026dcd9e19616ff62863e8cde8c0bee70318d3ccbca98341
|
|
#
|
|
# If you change this configuration, make sure to change the `cache-key`
|
|
# in the `poetry_setup` action above to stop using the old cache.
|
|
# It doesn't matter how you change it, any change will cause a cache-bust.
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry install --with lint,typing
|
|
|
|
- name: Get .mypy_cache to speed up mypy
|
|
uses: actions/cache@v4
|
|
env:
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
|
|
with:
|
|
path: |
|
|
${{ env.WORKDIR }}/.mypy_cache
|
|
key: mypy-lint-${{ runner.os }}-${{ runner.arch }}-py${{ inputs.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
|
|
|
|
|
|
- name: Analysing the code with our lint
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
make lint_package
|
|
|
|
- name: Install unit test dependencies
|
|
# Also installs dev/lint/test/typing dependencies, to ensure we have
|
|
# type hints for as many of our libraries as possible.
|
|
# This helps catch errors that require dependencies to be spotted, for example:
|
|
# https://github.com/langchain-ai/langchain/pull/10249/files#diff-935185cd488d015f026dcd9e19616ff62863e8cde8c0bee70318d3ccbca98341
|
|
#
|
|
# If you change this configuration, make sure to change the `cache-key`
|
|
# in the `poetry_setup` action above to stop using the old cache.
|
|
# It doesn't matter how you change it, any change will cause a cache-bust.
|
|
if: ${{ ! startsWith(inputs.working-directory, 'libs/partners/') }}
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry install --with test
|
|
- name: Install unit+integration test dependencies
|
|
if: ${{ startsWith(inputs.working-directory, 'libs/partners/') }}
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
poetry install --with test,test_integration
|
|
|
|
- name: Get .mypy_cache_test to speed up mypy
|
|
uses: actions/cache@v4
|
|
env:
|
|
SEGMENT_DOWNLOAD_TIMEOUT_MIN: "2"
|
|
with:
|
|
path: |
|
|
${{ env.WORKDIR }}/.mypy_cache_test
|
|
key: mypy-test-${{ runner.os }}-${{ runner.arch }}-py${{ inputs.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
|
|
|
|
- name: Analysing the code with our lint
|
|
working-directory: ${{ inputs.working-directory }}
|
|
run: |
|
|
make lint_tests
|