Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci matrix #14306

Merged
merged 22 commits into from
Dec 6, 2023
31 changes: 31 additions & 0 deletions .github/scripts/check_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json
import sys

ALL_DIRS = {
"libs/core",
"libs/langchain",
"libs/experimental",
# "libs/community",
# "libs/partners/openai",
}

if __name__ == "__main__":
files = sys.argv[1:]
dirs_to_run = set()

for file in files:
if any(dir_ in file for dir_ in (".github/workflows", ".github/tools", ".github/actions", "libs/core", ".github/scripts/check_diff.py")):
dirs_to_run = ALL_DIRS
break
elif "libs/community" in file:
dirs_to_run.update(("libs/community", "libs/langchain", "libs/experimental"))
elif "libs/partners" in file:
baskaryan marked this conversation as resolved.
Show resolved Hide resolved
partner_dir = file.split("/")[2]
dirs_to_run.update((f"libs/partners/{partner_dir}", "libs/langchain", "libs/experimental"))
elif "libs/langchain" in file:
dirs_to_run.update(("libs/langchain", "libs/experimental"))
elif "libs/experimental" in file:
dirs_to_run.add("libs/experimental")
else:
pass
print(json.dumps(list(dirs_to_run)))
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
---
name: libs/langchain CI
name: langchain CI

on:
push:
branches: [master]
pull_request:
paths:
- ".github/actions/poetry_setup/action.yml"
- ".github/tools/**"
- ".github/workflows/_lint.yml"
- ".github/workflows/_test.yml"
- ".github/workflows/_pydantic_compatibility.yml"
- ".github/workflows/langchain_ci.yml"
- "libs/*"
- "libs/langchain/**"
- "libs/core/**"
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
workflow_call:
inputs:
working-directory:
required: true
type: string
description: "From which folder this pipeline executes"

baskaryan marked this conversation as resolved.
Show resolved Hide resolved

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
Expand All @@ -24,36 +17,36 @@ on:
# a limited number of job runners to be active at the same time, so it's better to cancel
# pointless jobs early so that more useful jobs can run sooner.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.working-directory }}
cancel-in-progress: true

env:
POETRY_VERSION: "1.6.1"
WORKDIR: "libs/langchain"
WORKDIR: ${{ inputs.working-directory }}

jobs:
lint:
uses: ./.github/workflows/_lint.yml
with:
working-directory: libs/langchain
working-directory: ${{ inputs.working-directory }}
secrets: inherit

test:
uses: ./.github/workflows/_test.yml
with:
working-directory: libs/langchain
working-directory: ${{ inputs.working-directory }}
secrets: inherit

compile-integration-tests:
uses: ./.github/workflows/_compile_integration_test.yml
with:
working-directory: libs/langchain
working-directory: ${{ inputs.working-directory }}
secrets: inherit

pydantic-compatibility:
uses: ./.github/workflows/_pydantic_compatibility.yml
with:
working-directory: libs/langchain
working-directory: ${{ inputs.working-directory }}
secrets: inherit

extended-tests:
Expand All @@ -68,6 +61,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
if: ${{ inputs.working-directory }} == "libs/langchain"
name: Python ${{ matrix.python-version }} extended tests
steps:
- uses: actions/checkout@v4
Expand All @@ -77,7 +71,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ env.POETRY_VERSION }}
working-directory: libs/langchain
working-directory: ${{ inputs.working-directory }}
cache-key: extended

- name: Install dependencies
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/check_diffs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: Check library diffs

on:
push:
branches: [master]
pull_request:
paths:
- ".github/actions/**"
- ".github/tools/**"
- ".github/workflows/**"
- "libs/**"
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI

# If another push to the same PR or branch happens while this workflow is still running,
# cancel the earlier run in favor of the next run.
#
# There's no point in testing an outdated version of the code. GitHub only allows
# a limited number of job runners to be active at the same time, so it's better to cancel
# pointless jobs early so that more useful jobs can run sooner.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- id: files
uses: Ana06/[email protected]
baskaryan marked this conversation as resolved.
Show resolved Hide resolved
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
baskaryan marked this conversation as resolved.
Show resolved Hide resolved
echo "Do something with this ${changed_file}."
done
- id: set-matrix
run: echo "dirs-to-run=$(python .github/scripts/check_diff.py ${{ steps.files.outputs.all }})" >> $GITHUB_OUTPUT
outputs:
dirs-to-run: ${{ steps.set-matrix.outputs.dirs-to-run }}
ci:
needs: [ build ]
strategy:
matrix:
working-directory: ${{ fromJson(needs.build.outputs.dirs-to-run) }}
baskaryan marked this conversation as resolved.
Show resolved Hide resolved
uses: ./.github/workflows/_all_ci.yml
with:
working-directory: ${{ matrix.working-directory }}


47 changes: 0 additions & 47 deletions .github/workflows/langchain_cli_ci.yml

This file was deleted.

52 changes: 0 additions & 52 deletions .github/workflows/langchain_core_ci.yml

This file was deleted.

Loading
Loading