try top level codspeed workflow

This commit is contained in:
Sydney Runkle 2025-05-29 09:39:40 -04:00
parent 0c8bb4381e
commit 7c5af3a84b
2 changed files with 31 additions and 34 deletions

View File

@ -119,9 +119,7 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
if job == "test-pydantic": if job == "test-pydantic":
return _get_pydantic_test_configs(dir_) return _get_pydantic_test_configs(dir_)
if job == "codspeed": if dir_ == "libs/core":
py_versions = ["3.12"] # 3.13 is not yet supported
elif dir_ == "libs/core":
py_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"] py_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
# custom logic for specific directories # custom logic for specific directories
elif dir_ == "libs/partners/milvus": elif dir_ == "libs/partners/milvus":
@ -212,8 +210,6 @@ def _get_configs_for_multi_dirs(
) )
elif job == "extended-tests": elif job == "extended-tests":
dirs = list(dirs_to_run["extended-test"]) dirs = list(dirs_to_run["extended-test"])
elif job == "codspeed":
dirs = list(dirs_to_run["codspeed"])
else: else:
raise ValueError(f"Unknown job: {job}") raise ValueError(f"Unknown job: {job}")
@ -229,7 +225,6 @@ if __name__ == "__main__":
"lint": set(), "lint": set(),
"test": set(), "test": set(),
"extended-test": set(), "extended-test": set(),
"codspeed": set(),
} }
docs_edited = False docs_edited = False
@ -253,8 +248,6 @@ if __name__ == "__main__":
dirs_to_run["extended-test"].update(LANGCHAIN_DIRS) dirs_to_run["extended-test"].update(LANGCHAIN_DIRS)
dirs_to_run["lint"].add(".") dirs_to_run["lint"].add(".")
if file.startswith("libs/core"):
dirs_to_run["codspeed"].add(f"libs/core")
if any(file.startswith(dir_) for dir_ in LANGCHAIN_DIRS): if any(file.startswith(dir_) for dir_ in LANGCHAIN_DIRS):
# add that dir and all dirs after in LANGCHAIN_DIRS # add that dir and all dirs after in LANGCHAIN_DIRS
# for extended testing # for extended testing
@ -293,7 +286,6 @@ if __name__ == "__main__":
if not filename.startswith(".") if not filename.startswith(".")
] != ["README.md"]: ] != ["README.md"]:
dirs_to_run["test"].add(f"libs/partners/{partner_dir}") dirs_to_run["test"].add(f"libs/partners/{partner_dir}")
dirs_to_run["codspeed"].add(f"libs/partners/{partner_dir}")
# Skip if the directory was deleted or is just a tombstone readme # Skip if the directory was deleted or is just a tombstone readme
elif file == "libs/packages.yml": elif file == "libs/packages.yml":
continue continue
@ -319,7 +311,6 @@ if __name__ == "__main__":
"compile-integration-tests", "compile-integration-tests",
"dependencies", "dependencies",
"test-pydantic", "test-pydantic",
"codspeed",
] ]
} }
map_job_to_configs["test-doc-imports"] = ( map_job_to_configs["test-doc-imports"] = (

View File

@ -1,55 +1,61 @@
name: CodSpeed name: CodSpeed
on: on:
workflow_call: push:
inputs: branches:
working-directory: - master
required: true pull_request:
type: string paths:
description: "From which folder this pipeline executes" - 'libs/core/**'
python-version: - 'libs/partners/**'
required: true
type: string
description: "Python version to use"
workflow_dispatch: workflow_dispatch:
env:
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME }}
DEEPSEEK_API_KEY: foo
FIREWORKS_API_KEY: foo
jobs: jobs:
codspeed: codspeed:
name: Run benchmarks name: Run benchmarks
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
- working-directory: libs/core
mode: walltime
- working-directory: libs/partners/openai
- working-directory: libs/partners/anthropic
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# We have to use 3.12 as 3.13 is not yet supported
- name: Install uv - name: Install uv
uses: astral-sh/setup-uv@v6 uses: astral-sh/setup-uv@v6
with: with:
python-version: ${{ inputs.python-version }} python-version: "3.12"
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: ${{ inputs.python-version }} python-version: "3.12"
- name: install deps - name: Install dependencies
run: uv sync --group test run: uv sync --group test
working-directory: ${{ inputs.working-directory }} working-directory: ${{ matrix.working-directory }}
- name: Run benchmarks - name: Run benchmarks
uses: CodSpeedHQ/action@v3 uses: CodSpeedHQ/action@v3
env:
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_LEGACY_CHAT_DEPLOYMENT_NAME }}
DEEPSEEK_API_KEY: foo
FIREWORKS_API_KEY: foo
with: with:
token: ${{ secrets.CODSPEED_TOKEN }} token: ${{ secrets.CODSPEED_TOKEN }}
run: | run: |
cd ${{ inputs.working-directory }} cd ${{ matrix.working-directory }}
if [ "${{ inputs.working-directory }}" = "libs/core" ]; then if [ "${{ matrix.working-directory }}" = "libs/core" ]; then
uv run --no-sync pytest ./tests/benchmarks --codspeed uv run --no-sync pytest ./tests/benchmarks --codspeed
else else
uv run --no-sync pytest ./tests/ --codspeed uv run --no-sync pytest ./tests/ --codspeed
fi fi
mode: walltime mode: ${{ matrix.mode || 'instrumentation' }}