From 04f2f6c896b32af58c210c03cebd719b64db9c04 Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 21 May 2025 09:30:13 -0400 Subject: [PATCH] update workflows --- .github/scripts/check_diff.py | 11 ++++++++++- .github/workflows/check_diffs.yml | 16 ++++++++++++++++ .github/workflows/codspeed.yml | 32 +++++++++++++++++-------------- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/scripts/check_diff.py b/.github/scripts/check_diff.py index f476455037a..3c27554115b 100644 --- a/.github/scripts/check_diff.py +++ b/.github/scripts/check_diff.py @@ -120,7 +120,9 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]: if job == "test-pydantic": return _get_pydantic_test_configs(dir_) - if dir_ == "libs/core": + if job == "codspeed": + 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"] # custom logic for specific directories elif dir_ == "libs/partners/milvus": @@ -211,6 +213,8 @@ def _get_configs_for_multi_dirs( ) elif job == "extended-tests": dirs = list(dirs_to_run["extended-test"]) + elif job == "codspeed": + dirs = list(dirs_to_run["codspeed"]) else: raise ValueError(f"Unknown job: {job}") @@ -226,6 +230,7 @@ if __name__ == "__main__": "lint": set(), "test": set(), "extended-test": set(), + "codspeed": set(), } docs_edited = False @@ -262,6 +267,8 @@ if __name__ == "__main__": found = True if found: dirs_to_run["extended-test"].add(dir_) + if file.startswith("libs/core"): + dirs_to_run["codspeed"].add(f"libs/core") elif file.startswith("libs/standard-tests"): # TODO: update to include all packages that rely on standard-tests (all partner packages) # note: won't run on external repo partners @@ -287,6 +294,7 @@ if __name__ == "__main__": if not filename.startswith(".") ] != ["README.md"]: 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 elif file == "libs/packages.yml": continue @@ -312,6 +320,7 @@ if __name__ == "__main__": "compile-integration-tests", "dependencies", "test-pydantic", + "codspeed", ] } map_job_to_configs["test-doc-imports"] = ( diff --git a/.github/workflows/check_diffs.yml b/.github/workflows/check_diffs.yml index 15e08816816..dcdf38280b0 100644 --- a/.github/workflows/check_diffs.yml +++ b/.github/workflows/check_diffs.yml @@ -42,6 +42,7 @@ jobs: dependencies: ${{ steps.set-matrix.outputs.dependencies }} test-doc-imports: ${{ steps.set-matrix.outputs.test-doc-imports }} test-pydantic: ${{ steps.set-matrix.outputs.test-pydantic }} + codspeed: ${{ steps.set-matrix.outputs.codspeed }} lint: name: cd ${{ matrix.job-configs.working-directory }} needs: [ build ] @@ -152,6 +153,21 @@ jobs: # grep will exit non-zero if the target message isn't found, # and `set -e` above will cause the step to fail. echo "$STATUS" | grep 'nothing to commit, working tree clean' + + codspeed: + name: cd ${{ matrix.job-configs.working-directory }} + needs: [ build ] + if: ${{ needs.build.outputs.codspeed != '[]' }} + strategy: + matrix: + job-configs: ${{ fromJson(needs.build.outputs.codspeed) }} + fail-fast: false + uses: ./.github/workflows/codspeed.yml + with: + working-directory: ${{ matrix.job-configs.working-directory }} + python-version: ${{ matrix.job-configs.python-version }} + secrets: inherit + ci_success: name: "CI Success" needs: [build, lint, test, compile-integration-tests, extended-tests, test-doc-imports, test-pydantic] diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 3da7e4e15a2..c27b1bd145e 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -1,44 +1,48 @@ name: CodSpeed on: - push: - branches: - - master - pull_request: - paths: - - 'libs/core/**' - # `workflow_dispatch` allows CodSpeed to trigger backtest - # performance analysis in order to generate initial data. + # Re-usable workflow + 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" + + # Manual run (you will be prompted for the two inputs) workflow_dispatch: jobs: codspeed: name: Run benchmarks - if: (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-codspeed-benchmarks')) || github.event_name == 'workflow_dispatch' || github.event_name == 'push' + if: contains(github.event.pull_request.labels.*.name, 'run-codspeed-benchmarks') || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # We have to use 3.12, 3.13 is not yet supported - name: Install uv uses: astral-sh/setup-uv@v6 with: - python-version: "3.12" + python-version: ${{ inputs.python-version }} # Using this action is still necessary for CodSpeed to work - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: ${{ inputs.python-version }} - name: install deps run: uv sync --group test - working-directory: ./libs/core + working-directory: ${{ inputs.working-directory }} - name: Run benchmarks uses: CodSpeedHQ/action@v3 with: token: ${{ secrets.CODSPEED_TOKEN }} run: | - cd libs/core + cd ${{ inputs.working-directory }} uv run --no-sync pytest ./tests/benchmarks --codspeed mode: walltime