ci: fix releases with uv (#3971)

* Update scripts

* update the base dep in uv deps

* update nightly scripts

* Add uv creds for publish

* skip tests for now

* fix version

* only build the wheel

* try again

* add uv to python run

* [autofix.ci] apply automated fixes

* use uv cache

* more version fixe

* fixing versions

* fix base version

* Try no frozen?

* skip everything to try docker build

* tag

* frozen

* separate script for updating uv dep

* [autofix.ci] apply automated fixes

* hardcoded versions

* hardcoded versions

* add version to editable package

* build project before docker file runs

* try again

* fix uv patht o build

* don't know why this would mkae a difference

* debug statements

* debug statements

* debug statements

* change path to whl 🤷

* manually move the wheel...

* make dir

* try no sources

* add back tests

* refactor uv to action

* add uv action

* Update nightly build workflow to include uv lock files in version update commit

* Update lint-py workflow to use specific ref for setup-uv action

* Add checkout step to style-check-py GitHub Actions workflow

* Remove redundant GitHub ref syntax in lint-py.yml workflow

* Update lint-py.yml to use specific ref for setup-uv action

* Update action.yml: standardize quotes and remove redundant checkout step

* Add checkout step to GitHub Actions workflows for specific ref handling

- Introduced `actions/checkout@v4` step to multiple workflows to ensure code is checked out at a specific ref.
- Updated `.github/workflows/docker-build.yml`, `.github/workflows/release_nightly.yml`, `.github/workflows/lint-py.yml`, and `.github/workflows/style-check-py.yml` to include the new checkout step.
- Ensured credentials are persisted during the checkout process.

* Add checkout step to Python test workflow with specific ref

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Jordan Frazier 2024-10-02 05:37:04 -07:00 • committed by GitHub
commit e19d90bd6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 259 additions and 232 deletions

View file

@ -54,41 +54,26 @@ jobs:
defaults:
run:
shell: bash
outputs:
version: ${{ steps.verify.outputs.version }}
steps:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main }}
persist-credentials: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Set up Nodejs 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
ref: ${{ inputs.nightly_tag_main }}
- name: Install the project
run: uv sync --dev
- name: Verify Nightly Name and Version
working-directory: src/backend/base
id: verify
run: |
name=$(uv tree | grep 'langflow-base' | awk '{print $1}')
version=$(uv tree | grep 'langflow-base' | awk '{print $2}')
name=$(uv tree | grep 'langflow-base' | awk '{print $2}')
version=$(uv tree | grep 'langflow-base' | awk '{print $3}')
if [ "$name" != "langflow-base-nightly" ]; then
echo "Name $name does not match langflow-base-nightly. Exiting the workflow."
exit 1
@ -97,14 +82,21 @@ jobs:
echo "Version $version does not match nightly tag ${{ inputs.nightly_tag_base }}. Exiting the workflow."
exit 1
fi
# Strip the leading `v` from the version
version=$(echo $version | sed 's/^v//')
echo "version=$version" >> $GITHUB_OUTPUT
- name: Build project for distribution
run: make build base=true
run: make build base=true args="--wheel"
- name: Test CLI
run: |
python -m pip install src/backend/base/dist/*.whl
python -m langflow run --host 127.0.0.1 --port 7860 &
# TODO: unsure why the whl is not built in src/backend/base
# uv pip install src/backend/base/dist/*.whl
mkdir src/backend/base/dist
mv dist/*.whl src/backend/base/dist/
uv pip install src/backend/base/dist/*.whl
uv run 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/api/v1/auto_login; do sleep 2; done' || (echo "Server did not start in time" && kill $SERVER_PID && exit 1)
@ -122,6 +114,7 @@ jobs:
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
make publish base=true
@ -135,56 +128,49 @@ jobs:
name: Release Langflow Nightly Main
needs: [release-nightly-base]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.verify.outputs.version }}
defaults:
run:
shell: bash
steps:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
with:
ref: ${{ inputs.nightly_tag_main }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --dev
- name: Verify Nightly Name and Version
id: verify
run: |
name=$(uv tree | grep 'langflow' | awk '{print $1}')
version=$(uv tree | grep 'langflow' | awk '{print $2}')
name=$(uv tree | grep 'langflow' | grep -v 'langflow-base' | awk '{print $1}')
version=$(uv tree | grep 'langflow' | grep -v 'langflow-base' | awk '{print $2}')
if [ "$name" != "langflow-nightly" ]; then
echo "Name $name does not match langflow-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."
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
# Strip the leading `v` from the version
version=$(echo $version | sed 's/^v//')
echo "version=$version" >> $GITHUB_OUTPUT
- 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 args="--no-sources"
run: make build main=true args="--no-sources --wheel"
- name: Test CLI
run: |
python -m pip install dist/*.whl
python -m langflow run --host 127.0.0.1 --port 7860 --backend-only &
uv pip install dist/*.whl
uv run 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)
@ -201,6 +187,7 @@ jobs:
- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
make publish main=true
- name: Upload Artifact
@ -212,18 +199,14 @@ jobs:
call_docker_build_base:
name: Call Docker Build Workflow for Langflow Base
if: always() && ${{ inputs.build_docker_base == 'true' }}
needs: [release-nightly-base]
needs: [release-nightly-base, release-nightly-main]
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 }}
# Version should _not_ contain the leading `v`
version: ${{ needs.release-nightly-base.outputs.version }}
release_type: base
nightly_tag_base: ${{ inputs.nightly_tag_base }}
nightly_tag_main: ${{ inputs.nightly_tag_main }}
secrets: inherit
call_docker_build_main:
@ -231,14 +214,9 @@ jobs:
if: always() && ${{ 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 }}
# Version should _not_ contain the leading `v`
version: ${{ needs.release-nightly-main.outputs.version }}
release_type: main
nightly_tag_main: ${{ inputs.nightly_tag_main }}
secrets: inherit