2022-10-24 21:51:15 +00:00
|
|
|
name: lint
|
|
|
|
|
2022-12-04 00:42:59 +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-10-27 03:29:36 +00:00
|
|
|
langchain-location:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
description: "Relative path to the langchain library folder"
|
2022-12-04 00:42:59 +00:00
|
|
|
|
|
|
|
env:
|
2024-01-17 16:51:20 +00:00
|
|
|
POETRY_VERSION: "1.7.1"
|
2023-08-18 16:55:33 +00:00
|
|
|
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
|
2022-10-24 21:51:15 +00:00
|
|
|
|
2023-10-31 16:16:01 +00:00
|
|
|
# This env var allows us to get inline annotations when ruff has complaints.
|
|
|
|
RUFF_OUTPUT_FORMAT: github
|
|
|
|
|
2022-10-24 21:51:15 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2024-02-01 19:39:00 +00:00
|
|
|
name: "make lint #${{ matrix.python-version }}"
|
2022-10-24 21:51:15 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-08-18 14:26:38 +00:00
|
|
|
# Only lint on the min and max supported Python versions.
|
|
|
|
# It's extremely unlikely that there's a lint issue on any version in between
|
|
|
|
# that doesn't show up on the min or max versions.
|
|
|
|
#
|
|
|
|
# GitHub rate-limits how many jobs can be running at any one time.
|
|
|
|
# Starting new jobs is also relatively slow,
|
|
|
|
# so linting on fewer versions makes CI faster.
|
2022-12-13 13:48:53 +00:00
|
|
|
python-version:
|
|
|
|
- "3.8"
|
|
|
|
- "3.11"
|
2022-10-24 21:51:15 +00:00
|
|
|
steps:
|
2023-10-23 14:01:33 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-08-22 19:59:22 +00:00
|
|
|
|
|
|
|
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
|
|
|
|
uses: "./.github/actions/poetry_setup"
|
2022-12-13 13:48:53 +00:00
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
2023-08-22 19:59:22 +00:00
|
|
|
poetry-version: ${{ env.POETRY_VERSION }}
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2024-05-02 16:55:42 +00:00
|
|
|
# cache-key: lint-with-extras
|
2023-08-22 19:59:22 +00:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2022-12-13 13:48:53 +00:00
|
|
|
- name: Install dependencies
|
2023-09-06 15:15:28 +00:00
|
|
|
# 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.
|
2023-08-17 17:53:59 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2022-12-13 13:48:53 +00:00
|
|
|
run: |
|
2023-11-28 21:26:15 +00:00
|
|
|
poetry install --with lint,typing
|
2023-08-22 19:59:22 +00:00
|
|
|
|
2023-07-21 17:36:28 +00:00
|
|
|
- name: Install langchain editable
|
2023-08-17 17:53:59 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2023-10-29 22:50:09 +00:00
|
|
|
if: ${{ inputs.langchain-location }}
|
2023-10-27 03:29:36 +00:00
|
|
|
env:
|
2023-10-29 22:50:09 +00:00
|
|
|
LANGCHAIN_LOCATION: ${{ inputs.langchain-location }}
|
2023-07-21 17:36:28 +00:00
|
|
|
run: |
|
2023-11-20 21:09:30 +00:00
|
|
|
poetry run pip install -e "$LANGCHAIN_LOCATION"
|
|
|
|
|
2024-05-02 16:55:42 +00:00
|
|
|
# - 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${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
|
2023-12-11 21:53:30 +00:00
|
|
|
|
2023-08-17 17:53:59 +00:00
|
|
|
|
2022-12-13 13:48:53 +00:00
|
|
|
- name: Analysing the code with our lint
|
2023-08-17 17:53:59 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
2022-12-13 13:48:53 +00:00
|
|
|
run: |
|
2023-12-07 22:24:58 +00:00
|
|
|
make lint_package
|
|
|
|
|
2024-02-06 19:51:04 +00:00
|
|
|
- name: Install unit test dependencies
|
2023-12-07 22:24:58 +00:00
|
|
|
# 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.
|
2024-02-06 19:51:04 +00:00
|
|
|
if: ${{ ! startsWith(inputs.working-directory, 'libs/partners/') }}
|
2023-12-07 22:24:58 +00:00
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
run: |
|
2024-02-05 19:22:06 +00:00
|
|
|
poetry install --with test
|
2024-02-06 19:51:04 +00:00
|
|
|
- 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
|
2023-12-07 22:24:58 +00:00
|
|
|
|
2024-05-02 16:55:42 +00:00
|
|
|
# - 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${{ matrix.python-version }}-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/poetry.lock', inputs.working-directory)) }}
|
2023-12-07 22:24:58 +00:00
|
|
|
|
|
|
|
- name: Analysing the code with our lint
|
|
|
|
working-directory: ${{ inputs.working-directory }}
|
|
|
|
run: |
|
|
|
|
make lint_tests
|