mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 00:03:32 +08:00
* chore: bump backend unit test timeout from 30 to 40 minutes * ci: anchor langflow version grep so new workspace packages can't break it The pattern `uv tree | grep 'langflow' | grep -v 'langflow-base' | grep -v 'langflow-sdk'` was used in 8 places to pluck the root `langflow` (or `langflow-nightly`) line out of `uv tree`. It relied on enumerating every other workspace package that starts with `langflow-`. As soon as a new one was added (`langflow-stepflow`, via #12015) the filter let two lines through and the downstream `awk` / `cut` produced a multi-line string, e.g.: Name langflow-stepflow langflow-nightly does not match langflow-nightly. Exiting the workflow. Replace the enumeration with an anchored regex `grep -E '^langflow(-nightly)?[[:space:]]'` so only the exact `langflow` or `langflow-nightly` root line matches, regardless of how many other `langflow-*` workspace packages exist now or in the future. * ci: build, test, and publish src/bundles/* wheels Langflow main pins exact versions of every bundle (e.g. `lfx-arxiv-nightly==0.1.0.dev38`, `lfx-arxiv==0.1.0`), but neither the nightly workflow nor the release workflow built or published those bundle wheels. So when cross-platform tests (or downstream consumers) ran `pip install langflow-nightly`, the resolver couldn't find `lfx-arxiv-nightly` / `lfx-duckduckgo-nightly` on PyPI and bailed: Because lfx-arxiv-nightly was not found in the package registry and langflow-nightly==1.10.0.dev38 depends on lfx-arxiv-nightly==0.1.0.dev38, we can conclude that langflow-nightly==1.10.0.dev38 cannot be used. Add a build → test → publish lane for every package under `src/bundles/*/` in both workflows, plus a matching bundle install step in cross-platform-test.yml. `release_nightly.yml` - `build-nightly-bundles`: iterates `src/bundles/*/pyproject.toml`, builds each wheel, uploads as `dist-nightly-bundles`. - `test-cross-platform` now passes `bundles-artifact-name` so the cross-platform test installs bundles before installing main. - `publish-nightly-bundles`: publishes each bundle wheel to PyPI after cross-platform passes and lfx is already published. - `publish-nightly-main` now waits on `publish-nightly-bundles` so main reaches PyPI only after its bundle deps do. `release.yml` - New `release_bundles` input (false by default). - `validate-dependencies` rejects `release_package_main=true` without `release_bundles=true`, mirroring the existing lfx/sdk gate. - `build-bundles`, `publish-bundles` mirror the nightly jobs. - `publish-main` now needs `publish-bundles`. `cross-platform-test.yml` - New optional `bundles-artifact-name` input; download step is gated on it being set. - `build-if-needed` (workflow_dispatch path) also builds bundles and publishes the artifact, so adhoc runs stay self-contained. - Each of the four "Install main package from wheel" steps gets a preceding "Install bundle packages from wheel" step that runs only when the artifact is present, leaving non-bundle callers (e.g. pre-bundle release branches) unaffected. * ci: drop mapfile from bundle install (macOS Bash 3.2 compat) `mapfile` is a Bash 4+ builtin and the macOS runners use the system Bash (3.2). The "Install bundle packages from wheel (Unix)" step failed on `Install & Run - macos amd64 3.12` with: mapfile: command not found find: stdout: Broken pipe Replace with the `shopt -s nullglob` + glob-array pattern already used in the bundle build/publish steps, which works on Bash 3.2. All artifact wheels live at the top level of ./bundles-dist, so the simple glob is equivalent to the previous `find` (which also wasn't recursing anywhere useful). --------- Co-authored-by: Claude <noreply@anthropic.com>
256 lines
9.1 KiB
YAML
256 lines
9.1 KiB
YAML
name: Python tests
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
OPENAI_API_KEY:
|
|
required: true
|
|
ANTHROPIC_API_KEY:
|
|
required: true
|
|
CODECOV_TOKEN:
|
|
required: false
|
|
inputs:
|
|
python-versions:
|
|
description: "(Optional) Python versions to test"
|
|
required: true
|
|
type: string
|
|
default: "['3.10', '3.11', '3.12', '3.13', '3.14']"
|
|
ref:
|
|
description: "(Optional) ref to checkout"
|
|
required: false
|
|
type: string
|
|
nightly:
|
|
description: "Whether run is from the nightly build"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
runs-on:
|
|
description: "Runner to use for the tests"
|
|
required: false
|
|
type: string
|
|
default: "ubuntu-latest"
|
|
workflow_dispatch:
|
|
inputs:
|
|
python-versions:
|
|
description: "(Optional) Python versions to test"
|
|
required: true
|
|
type: string
|
|
default: "['3.10', '3.11', '3.12', '3.13', '3.14']"
|
|
runs-on:
|
|
description: "Runner to use for the tests"
|
|
required: false
|
|
type: choice
|
|
options:
|
|
- ubuntu-latest
|
|
- self-hosted
|
|
- '["self-hosted", "linux", "ARM64", "langflow-ai-arm64-40gb-ephemeral"]'
|
|
default: ubuntu-latest
|
|
env:
|
|
POETRY_VERSION: "1.8.2"
|
|
NODE_VERSION: "22"
|
|
PYTEST_RUN_PATH: "src/backend/tests"
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
|
|
jobs:
|
|
build:
|
|
name: Unit Tests - Python ${{ matrix.python-version }} - Group ${{ matrix.group }}
|
|
runs-on: ${{ (inputs['runs-on'] && startsWith(format('{0}', inputs['runs-on']), '[') && fromJSON(inputs['runs-on'])) || inputs['runs-on'] || github.event.inputs['runs-on'] || 'ubuntu-latest' }}
|
|
strategy:
|
|
matrix:
|
|
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12", "3.13", "3.14"]') }}
|
|
splitCount: [5]
|
|
group: [1, 2, 3, 4, 5]
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
id: setup-node
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: "Setup Environment"
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
python-version: ${{ matrix.python-version }}
|
|
prune-cache: false
|
|
|
|
- name: Install the project
|
|
run: uv sync
|
|
|
|
- name: Generate dynamic coverage configuration
|
|
run: |
|
|
echo "Generating dynamic coverage configuration..."
|
|
python3 scripts/generate_coverage_config.py
|
|
echo "Generated .coveragerc with the following exclusions:"
|
|
echo "Bundled components and legacy files excluded from coverage"
|
|
|
|
- name: Run unit tests
|
|
uses: nick-fields/retry@v3
|
|
with:
|
|
timeout_minutes: 40
|
|
max_attempts: 2
|
|
command: make unit_tests args="-x -vv --splits ${{ matrix.splitCount }} --group ${{ matrix.group }} --reruns 5 --cov --cov-config=src/backend/.coveragerc --cov-report=xml --cov-report=html"
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
if: matrix.python-version == '3.10'
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./coverage.xml
|
|
flags: backend
|
|
name: backend-coverage-group-${{ matrix.group }}
|
|
fail_ci_if_error: false
|
|
directory: ./
|
|
|
|
- name: Upload coverage artifacts
|
|
uses: actions/upload-artifact@v6
|
|
if: matrix.python-version == '3.10'
|
|
with:
|
|
name: backend-coverage-report-group-${{ matrix.group }}
|
|
path: |
|
|
coverage.xml
|
|
htmlcov/
|
|
retention-days: 30
|
|
|
|
integration-tests:
|
|
name: Integration Tests - Python ${{ matrix.python-version }}
|
|
runs-on: ${{ (inputs['runs-on'] && startsWith(format('{0}', inputs['runs-on']), '[') && fromJSON(inputs['runs-on'])) || inputs['runs-on'] || github.event.inputs['runs-on'] || 'ubuntu-latest' }}
|
|
strategy:
|
|
matrix:
|
|
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12", "3.13", "3.14"]') }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
- name: "Setup Environment"
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
python-version: ${{ matrix.python-version }}
|
|
prune-cache: false
|
|
- name: Install the project
|
|
run: uv sync
|
|
- name: Run integration tests
|
|
run: make integration_tests_no_api_keys
|
|
env:
|
|
PYLEAK_LOG_LEVEL: debug # enable pyleak logging
|
|
DO_NOT_TRACK: true # disable telemetry reporting
|
|
|
|
lfx-tests:
|
|
name: LFX Tests - Python ${{ matrix.python-version }}
|
|
runs-on: ${{ (inputs['runs-on'] && startsWith(format('{0}', inputs['runs-on']), '[') && fromJSON(inputs['runs-on'])) || inputs['runs-on'] || github.event.inputs['runs-on'] || 'ubuntu-latest' }}
|
|
strategy:
|
|
matrix:
|
|
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12", "3.13", "3.14"]') }}
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
- name: "Setup Environment"
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
python-version: ${{ matrix.python-version }}
|
|
prune-cache: false
|
|
- name: Run lfx tests
|
|
run: make lfx_tests
|
|
env:
|
|
DO_NOT_TRACK: true # disable telemetry reporting
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
if: matrix.python-version == '3.10'
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: ./src/lfx/coverage.xml
|
|
flags: lfx
|
|
name: lfx-coverage
|
|
fail_ci_if_error: false
|
|
directory: ./src/lfx/
|
|
|
|
- name: Upload coverage artifacts
|
|
uses: actions/upload-artifact@v6
|
|
if: matrix.python-version == '3.10'
|
|
with:
|
|
name: lfx-coverage-report
|
|
path: |
|
|
src/lfx/coverage.xml
|
|
src/lfx/htmlcov/
|
|
retention-days: 30
|
|
|
|
test-cli:
|
|
name: Test CLI - Python ${{ matrix.python-version }}
|
|
runs-on: ${{ (inputs['runs-on'] && startsWith(format('{0}', inputs['runs-on']), '[') && fromJSON(inputs['runs-on'])) || inputs['runs-on'] || github.event.inputs['runs-on'] || 'ubuntu-latest' }}
|
|
strategy:
|
|
matrix:
|
|
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12", "3.13", "3.14"]') }}
|
|
steps:
|
|
- name: Check out the code at a specific ref
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
- name: "Setup Environment"
|
|
uses: astral-sh/setup-uv@v6
|
|
with:
|
|
enable-cache: true
|
|
cache-dependency-glob: "uv.lock"
|
|
python-version: ${{ matrix.python-version }}
|
|
prune-cache: false
|
|
|
|
- name: Check Version
|
|
id: check-version
|
|
# We need to print $3 because langflow-base is a dependency of langflow
|
|
# For langlow we'd use print $2
|
|
run: |
|
|
version=$(uv tree | grep 'langflow-base' | awk '{print $3}' | sed 's/^v//' | head -n 1)
|
|
url="https://pypi.org/pypi/langflow-base/json"
|
|
if [ ${{ inputs.nightly }} == true ]; then
|
|
url="https://pypi.org/pypi/langflow-base-nightly/json"
|
|
fi
|
|
|
|
last_released_version=$(curl -s $url | jq -r '.releases | keys | .[]' | sort -V | tail -n 1)
|
|
if [ "$version" != "$last_released_version" ]; then
|
|
echo "Version $version has not been released yet. Skipping the rest of the job."
|
|
echo skipped=true >> $GITHUB_OUTPUT
|
|
exit 0
|
|
else
|
|
echo version=$version >> $GITHUB_OUTPUT
|
|
echo skipped=false >> $GITHUB_OUTPUT
|
|
fi
|
|
- name: Build wheel
|
|
if: steps.check-version.outputs.skipped == 'false'
|
|
run: |
|
|
make build main=true
|
|
- name: Install wheel and Test CLI
|
|
if: steps.check-version.outputs.skipped == 'false'
|
|
run: |
|
|
uv venv new-venv
|
|
source new-venv/bin/activate
|
|
uv pip install dist/*.whl
|
|
- name: Test CLI
|
|
if: steps.check-version.outputs.skipped == 'false'
|
|
run: |
|
|
source new-venv/bin/activate
|
|
python -m langflow run --host localhost --port 7860 --backend-only &
|
|
SERVER_PID=$!
|
|
# Wait for the server to start
|
|
timeout 120 bash -c 'until curl -f http://localhost:7860/api/v1/auto_login; do sleep 5; done' || (echo "Server did not start in time" && kill $SERVER_PID && exit 1)
|
|
# Terminate the server
|
|
kill $SERVER_PID || (echo "Failed to terminate the server" && exit 1)
|
|
sleep 20 # give the server some time to terminate
|
|
# Check if the server is still running
|
|
if kill -0 $SERVER_PID 2>/dev/null; then
|
|
echo "Failed to terminate the server"
|
|
exit 0
|
|
else
|
|
echo "Server terminated successfully"
|
|
fi
|