ci: create a nightly build workflow (#3553)

* test poetry install

* Add nightly builds workflow

* remove old comments and fix poetry

* remove old debug statement

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Jordan Frazier 2024-09-05 12:13:04 -07:00 committed by GitHub
commit 7b3e51f769
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 1770 additions and 1055 deletions

View file

@ -12,22 +12,31 @@ on:
required: false
type: boolean
default: false
nightly_build:
required: false
type: boolean
default: false
workflow_dispatch:
inputs:
version:
required: true
description: "Version to build"
required: false
type: string
release_type:
description: "Type of release"
required: true
type: choice
options:
- base
- main
type: string
pre_release:
description: "Pre-release"
required: false
type: boolean
default: true
default: false
nightly_build:
description: "Build nightly build"
required: false
type: boolean
default: false
env:
POETRY_VERSION: "1.8.2"
TEST_TAG: "langflowai/langflow:test"
@ -48,19 +57,19 @@ jobs:
poetry-version: ${{ env.POETRY_VERSION }}
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
- name: Get Version from Input
if : ${{ inputs.version != '' }}
if: ${{ inputs.version != '' }}
id: get-version-input
run: |
version=${{ inputs.version }}
echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Main
if : ${{ inputs.version == '' && inputs.release_type == 'base' }}
- name: Get Version Base
if: ${{ inputs.version == '' && inputs.release_type == 'base' }}
id: get-version-base
run: |
version=$(cd src/backend/base && poetry version --short)
echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Base
if : ${{ inputs.version == '' && inputs.release_type == 'main' }}
- name: Get Version Main
if: ${{ inputs.version == '' && inputs.release_type == 'main' }}
id: get-version-main
run: |
version=$(poetry version --short)
@ -76,14 +85,19 @@ jobs:
- name: Set Dockerfile and Tags
id: set-vars
run: |
nightly_suffix=""
if [[ "${{ inputs.nightly_build }}" == "true" ]]; then
nightly_suffix="-nightly"
fi
if [[ "${{ inputs.release_type }}" == "base" ]]; then
echo "tags=langflowai/langflow:base-${{ needs.get-version.outputs.version }},langflowai/langflow:base-latest" >> $GITHUB_OUTPUT
echo "tags=langflowai/langflow${nightly_suffix}:base-${{ needs.get-version.outputs.version }},langflowai/langflow${nightly_suffix}:base-latest" >> $GITHUB_OUTPUT
echo "file=./docker/build_and_push_base.Dockerfile" >> $GITHUB_OUTPUT
else
if [[ "${{ inputs.pre_release }}" == "true" ]]; then
echo "tags=langflowai/langflow:${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT
echo "tags=langflowai/langflow${nightly_suffix}:${{ needs.get-version.outputs.version }}" >> $GITHUB_OUTPUT
else
echo "tags=langflowai/langflow:${{ needs.get-version.outputs.version }},langflowai/langflow:latest" >> $GITHUB_OUTPUT
echo "tags=langflowai/langflow${nightly_suffix}:${{ needs.get-version.outputs.version }},langflowai/langflow${nightly_suffix}:latest" >> $GITHUB_OUTPUT
fi
echo "file=./docker/build_and_push.Dockerfile" >> $GITHUB_OUTPUT
fi
@ -119,10 +133,10 @@ jobs:
include:
- component: backend
dockerfile: ./docker/build_and_push_backend.Dockerfile
tags: ${{ inputs.pre_release == 'true' && format('langflowai/langflow-backend:{0}', needs.get-version.outputs.version) || format('langflowai/langflow-backend:{0},langflowai/langflow-backend:latest', needs.get-version.outputs.version) }}
tags: ${{ inputs.pre_release == 'true' && format('langflowai/langflow-backend{0}:{1}', inputs.nightly_build && '-nightly' || '', needs.get-version.outputs.version) || format('langflowai/langflow-backend{0}:{1},langflowai/langflow-backend{0}:latest{1}', inputs.nightly_build && '-nightly' || '', needs.get-version.outputs.version) }}
- component: frontend
dockerfile: ./docker/frontend/build_and_push_frontend.Dockerfile
tags: ${{ inputs.pre_release == 'true' && format('langflowai/langflow-frontend:{0}', needs.get-version.outputs.version) || format('langflowai/langflow-frontend:{0},langflowai/langflow-frontend:latest', needs.get-version.outputs.version) }}
tags: ${{ inputs.pre_release == 'true' && format('langflowai/langflow-frontend{0}:{1}', inputs.nightly_build && '-nightly' || '', needs.get-version.outputs.version) || format('langflowai/langflow-frontend{0}:{1},langflowai/langflow-frontend{0}:latest{1}', inputs.nightly_build && '-nightly' || '', needs.get-version.outputs.version) }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
@ -140,7 +154,7 @@ jobs:
context: .
push: true
build-args: |
LANGFLOW_IMAGE=langflowai/langflow:${{ needs.get-version.outputs.version }}
LANGFLOW_IMAGE=langflowai/langflow${{ inputs.nightly_build && '-nightly' || '' }}:${{ needs.get-version.outputs.version }}
file: ${{ matrix.dockerfile }}
tags: ${{ matrix.tags }}
# provenance: false will result in a single manifest for all platforms which makes the image pullable from arm64 machines via the emulation (e.g. Apple Silicon machines)
@ -148,7 +162,7 @@ jobs:
restart-space:
name: Restart HuggingFace Spaces
if: ${{ inputs.release_type == 'main' }}
if: ${{ inputs.release_type == 'main' && inputs.nightly_build == 'false' }}
runs-on: ubuntu-latest
needs: build
strategy:

View file

@ -1,20 +1,29 @@
name: Integration tests
name: Integration Tests
on:
workflow_dispatch:
inputs:
branch:
description: "(Optional) Branch to checkout"
ref:
description: "(Optional) ref to checkout"
required: false
type: string
workflow_call:
inputs:
python-versions:
description: "(Optional) Python versions to test"
required: true
type: string
default: "['3.10', '3.11', '3.12']"
ref:
description: "(Optional) ref to checkout"
required: false
type: string
schedule:
- cron: "0 0 */2 * *" # Run every 2 days
env:
POETRY_VERSION: "1.8.2"
jobs:
test-integration:
integration-tests:
name: Run Integration Tests
runs-on: ubuntu-latest
strategy:
@ -32,7 +41,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
ref: ${{ inputs.ref || github.ref }}
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_caching"
with:

View file

@ -3,15 +3,142 @@ name: Nightly Build
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *" # Run every day at midnight (UTC)
# Run job at 6:30 UTC, 10.30pm PST, or 11.30pm PDT
- cron: "30 6 * * *"
env:
POETRY_VERSION: "1.8.2"
POETRY_VERSION: "1.8.3"
PYTHON_VERSION: "3.12"
jobs:
hello-world:
create-nightly-tag:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
# Required to create tag
contents: write
outputs:
main_tag: ${{ steps.create_tag.outputs.main_tag }}
base_tag: ${{ steps.create_tag.outputs.base_tag }}
steps:
- name: Run hello world
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_caching"
with:
python-version: ${{ env.PYTHON_VERSION }}
poetry-version: ${{ env.POETRY_VERSION }}
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: |
echo "Hello, world!"
poetry env use ${{ env.PYTHON_VERSION }}
poetry install
- name: Create tag
id: create_tag
run: |
git config --global user.email "bot-nightly-builds@langflow.org"
git config --global user.name "Langflow Bot"
# WARNING: These scripts must be run in this order.
# Poetry will use a different cached virtual environment once the main pyproject.toml
# project-name is updated, which does not have dependencies installed.
BASE_TAG="$(poetry run python ./scripts/ci/pypi_nightly_tag.py base)"
echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT
poetry run python ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
poetry run python ./scripts/ci/update_pyproject_version.py $BASE_TAG base
# This updates the dependency of langflow-base to langflow-base-nightly in {project_root}/pyproject.toml
poetry run python ./scripts/ci/update_lf_base_dependency.py $BASE_TAG
MAIN_TAG="$(poetry run python ./scripts/ci/pypi_nightly_tag.py main)"
echo "main_tag=$MAIN_TAG" >> $GITHUB_OUTPUT
poetry run python ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
poetry run python ./scripts/ci/update_pyproject_name.py langflow-nightly main
git add pyproject.toml src/backend/base/pyproject.toml
git commit -m "Update version and project name in files"
git tag -a $MAIN_TAG -m "Langflow nightly $MAIN_TAG"
git push origin $MAIN_TAG || echo "Tag push failed. Check if the tag already exists."
# TODO: notify on failure
frontend-tests:
name: Run Frontend Tests
needs: create-nightly-tag
uses: ./.github/workflows/typescript_test.yml
with:
tests_folder: "tests/end-to-end"
ref: ${{ needs.create-nightly-tag.outputs.tag }}
secrets:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
STORE_API_KEY: "${{ secrets.STORE_API_KEY }}"
backend-unit-tests:
name: Run Backend Unit Tests
needs: create-nightly-tag
uses: ./.github/workflows/python_test.yml
with:
python-versions: '["3.10", "3.11", "3.12"]'
ref: ${{ needs.create-nightly-tag.outputs.tag }}
# Not making nightly builds dependent on integration test success
# due to inherent flakiness of 3rd party integrations
# Revisit when https://github.com/langflow-ai/langflow/pull/3607 is merged.
# backend-integration-tests:
# name: Run Backend Integration Tests
# needs: create-nightly-tag
# uses: ./.github/workflows/integration_tests.yml
# with:
# python-versions: '["3.10", "3.11", "3.12"]'
# ref: ${{ needs.create-nightly-tag.outputs.tag }}
release-nightly-build:
name: Run Nightly Langflow Build
needs: [frontend-tests, backend-unit-tests, create-nightly-tag]
uses: ./.github/workflows/release_nightly.yml
with:
build_docker_base: false # TODO: Docker builds
build_docker_main: false
nightly_tag_main: ${{ needs.create-nightly-tag.outputs.main_tag }}
nightly_tag_base: ${{ needs.create-nightly-tag.outputs.base_tag }}
secrets: inherit
# slack-notification:
# name: Send Slack Notification
# needs: run-nightly-build
# runs-on: ubuntu-latest
# steps:
# - name: Send success notification to Slack
# if: success()
# uses: slackapi/slack-github-action@v1.26.0
# with:
# payload: |
# {
# "channel": "#langflow-nightly-builds",
# "username": "GitHub Actions",
# "text": "Nightly Build Successful :white_check_mark:",
# "icon_emoji": ":rocket:"
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
# - name: Send failure notification to Slack
# if: failure()
# uses: slackapi/slack-github-action@v1.26.0
# with:
# payload: |
# {
# "channel": "#langflow-nightly-builds",
# "username": "GitHub Actions",
# "text": "Nightly Build Failed :x:",
# "icon_emoji": ":warning:"
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

View file

@ -8,12 +8,17 @@ on:
required: true
type: string
default: "['3.10', '3.11', '3.12']"
workflow_dispatch:
inputs:
branch:
description: "(Optional) Branch to checkout"
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
workflow_dispatch:
inputs:
python-versions:
description: "(Optional) Python versions to test"
required: true
@ -35,7 +40,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
ref: ${{ inputs.ref || github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
id: setup-node
@ -88,6 +93,9 @@ jobs:
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12"]') }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_caching"
with:
@ -98,7 +106,12 @@ jobs:
id: check-version
run: |
version=$(cd src/backend/base && poetry version --short)
last_released_version=$(curl -s "https://pypi.org/pypi/langflow-base/json" | jq -r '.releases | keys | .[]' | sort -V | tail -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

View file

@ -29,7 +29,11 @@ on:
required: false
type: boolean
default: false
create_release:
description: "Whether to create a gh release"
required: false
type: boolean
default: true
env:
POETRY_VERSION: "1.8.2"
@ -155,7 +159,7 @@ jobs:
fi
- name: Wait for PyPI Propagation
if: needs.release-base.outputs.skipped == 'false'
run: sleep 300 # wait for 5 minutes to ensure PyPI propagation
run: sleep 300 # wait for 5 minutes to ensure PyPI propagation
- name: Build project for distribution
run: make build main=true
@ -188,7 +192,7 @@ jobs:
call_docker_build_base:
name: Call Docker Build Workflow for Langflow Base
if : inputs.build_docker_base == true
if: inputs.build_docker_base == true
uses: ./.github/workflows/docker-build.yml
strategy:
matrix:
@ -197,14 +201,14 @@ jobs:
with:
# version should be needs.release-base.outputs.version if release_type is base
# version should be needs.release-main.outputs.version if release_type is main
version: ''
version: ""
release_type: ${{ matrix.release_type }}
pre_release: ${{ inputs.pre_release }}
secrets: inherit
call_docker_build_main:
name: Call Docker Build Workflow for Langflow
if : inputs.build_docker_main == true
if: inputs.build_docker_main == true
uses: ./.github/workflows/docker-build.yml
strategy:
matrix:
@ -213,7 +217,7 @@ jobs:
with:
# version should be needs.release-base.outputs.version if release_type is base
# version should be needs.release-main.outputs.version if release_type is main
version: ''
version: ""
release_type: ${{ matrix.release_type }}
pre_release: ${{ inputs.pre_release }}
secrets: inherit
@ -236,4 +240,4 @@ jobs:
generateReleaseNotes: true
prerelease: ${{ inputs.pre_release }}
tag: v${{ needs.release-main.outputs.version }}
commit: ${{ github.ref }}
commit: ${{ github.ref }}

225
.github/workflows/release_nightly.yml vendored Normal file
View file

@ -0,0 +1,225 @@
name: Langflow Nightly Build
run-name: Langflow Nightly Release by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
build_docker_base:
description: "Build Docker Image for Langflow Nightly Base"
required: true
type: boolean
default: false
build_docker_main:
description: "Build Docker Image for Langflow Nightly"
required: true
type: boolean
default: false
nightly_tag_main:
description: "Tag for the nightly main build"
required: true
type: string
nightly_tag_base:
description: "Tag for the nightly base build"
required: true
type: string
workflow_call:
inputs:
build_docker_base:
description: "Build Docker Image for Langflow Nightly Base"
required: true
type: boolean
default: false
build_docker_main:
description: "Build Docker Image for Langflow Nightly"
required: true
type: boolean
default: false
nightly_tag_main:
description: "Tag for the nightly main build"
required: true
type: string
nightly_tag_base:
description: "Tag for the nightly base build"
required: true
type: string
env:
POETRY_VERSION: "1.8.3"
PYTHON_VERSION: "3.12"
jobs:
release-nightly-base:
name: Release Langflow Nightly Base
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Check out the code at a specific ref (e.g., nightly tag)
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main }}
persist-credentials: true
- name: Install poetry
run: |
pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Verify Nightly Name and Version
working-directory: src/backend/base
run: |
name=$(poetry version | cut -d' ' -f1)
version=$(poetry version --short)
if [ "$name" != "langflow-base-nightly" ]; then
echo "Name $name does not match langflow-base-nightly. Exiting the workflow."
exit 1
fi
if [ "$version" != "${{ inputs.nightly_tag_base }}" ]; then
echo "Version $version does not match nightly tag ${{ inputs.nightly_tag_base }}. Exiting the workflow."
exit 1
fi
- name: Build project for distribution
run: make build base=true
- name: Test CLI
run: |
python -m pip install src/backend/base/dist/*.whl
python -m langflow run --host 127.0.0.1 --port 7860 &
SERVER_PID=$!
# Wait for the server to start
timeout 120 bash -c 'until curl -f http://127.0.0.1:7860/api/v1/auto_login; do sleep 2; 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 10 # 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 1
else
echo "Server terminated successfully"
fi
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
make publish base=true
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: dist-base
path: src/backend/base/dist
release-nightly-main:
name: Release Langflow Nightly Main
needs: [release-nightly-base]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Check out the code at a specific ref (e.g., nightly tag)
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main }}
- name: Install poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Verify Nightly Name and Version
run: |
name=$(poetry version | cut -d' ' -f1)
version=$(poetry version --short)
if [ "$name" != "langflow-nightly" ]; then
echo "Name $name does not match langflow-nightly. Exiting the workflow."
exit 1
fi
if [ "$version" != "${{ inputs.nightly_tag_main }}" ]; then
echo "Version $version does not match nightly tag ${{ inputs.nightly_tag_main }}. Exiting the workflow."
exit 1
fi
- name: Wait for PyPI Propagation
run: sleep 300 # wait for 5 minutes to ensure PyPI propagation of base
- name: Build project for distribution
run: make build main=true
- name: Test CLI
run: |
python -m pip install dist/*.whl
python -m langflow run --host 127.0.0.1 --port 7860 --backend-only &
SERVER_PID=$!
# Wait for the server to start
timeout 120 bash -c 'until curl -f http://127.0.0.1:7860/health_check; do sleep 2; 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 10 # 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 1
else
echo "Server terminated successfully"
fi
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |
make publish main=true
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: dist-main
path: dist
call_docker_build_base:
name: Call Docker Build Workflow for Langflow Base
if: ${{ inputs.build_docker_base == 'true' }}
needs: [release-nightly-base]
uses: ./.github/workflows/docker-build.yml
strategy:
matrix:
release_type:
- base
with:
# version should be needs.release-base.outputs.version if release_type is base
# version should be needs.release-main.outputs.version if release_type is main
version: ""
release_type: ${{ matrix.release_type }}
nightly_build: true
secrets: inherit
call_docker_build_main:
name: Call Docker Build Workflow for Langflow
if: ${{ inputs.build_docker_main == 'true' }}
needs: [release-nightly-main]
uses: ./.github/workflows/docker-build.yml
strategy:
matrix:
release_type:
- main
with:
# version should be needs.release-base.outputs.version if release_type is base
# version should be needs.release-main.outputs.version if release_type is main
version: ""
release_type: ${{ matrix.release_type }}
nightly_build: true
secrets: inherit

View file

@ -13,12 +13,12 @@ on:
required: false
type: string
default: "tests"
workflow_dispatch:
inputs:
branch:
description: "(Optional) Branch to checkout"
ref:
description: "(Optional) ref to checkout"
required: false
type: string
workflow_dispatch:
inputs:
tests_folder:
description: "(Optional) Tests to run"
required: false
@ -54,9 +54,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
# If branch is passed as input, checkout that branch
# else checkout the default branch
ref: ${{ github.event.inputs.branch || github.ref }}
# If ref is passed as input, checkout that ref
# else checkout the default ref
ref: ${{ inputs.ref || github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4