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

@ -13,25 +13,13 @@ def update_base_dep(pyproject_path: str, new_version: str) -> None:
with open(filepath, "r") as file:
content = file.read()
# Regex to match the langflow-base dep line under [tool.poetry]
# NOTE: this functions similarly to `update_dependencies.py`.
# The order of operations for these scripts is more complex than it needs to be;
# this is a reminder to revisit this process.
# Currently, the process is as follows:
# 1. nightly-build workflow updates all names, version, and the langflow-base
# dependency in pyproject.toml, and commits the changes and creates a tag.
# 2. release-nightly workflow runs, which calls update_dependencies.py to update
# the langflow-base dependency in pyproject.toml _again_. This is redundant, but
# necessary because the release workflow relies on that script to update the base
# dependency.
pattern = re.compile(r'langflow-base = \{ path = "\./src/backend/base", develop = true \}')
if not pattern.search(content):
raise Exception(f'langflow-base dependency not found in "{filepath}"')
replacement = f'langflow-base-nightly = "{new_version}"'
content = pattern.sub(replacement, content)
# Updates the pattern for poetry
pattern = re.compile(r'langflow-base = \{ path = "\./src/backend/base", develop = true \}')
if not pattern.search(content):
raise Exception(f'langflow-base poetry dependency not found in "{filepath}"')
content = pattern.sub(replacement, content)
with open(filepath, "w") as file:
file.write(content)

View file

@ -16,13 +16,35 @@ def update_pyproject_name(pyproject_path: str, new_project_name: str) -> None:
if not pattern.search(content):
raise Exception(f'Project name not found in "{filepath}"')
content = pattern.sub(new_project_name, content)
with open(filepath, "w") as file:
file.write(content)
def update_uv_dep(pyproject_path: str, new_project_name: str) -> None:
"""Update the langflow-base dependency in pyproject.toml."""
filepath = os.path.join(BASE_DIR, pyproject_path)
with open(filepath, "r") as file:
content = file.read()
if new_project_name == "langflow-nightly":
pattern = re.compile(r"langflow = \{ workspace = true \}")
replacement = "langflow-nightly = { workspace = true }"
elif new_project_name == "langflow-base-nightly":
pattern = re.compile(r"langflow-base = \{ workspace = true \}")
replacement = "langflow-base-nightly = { workspace = true }"
else:
raise ValueError(f"Invalid project name: {new_project_name}")
# Updates the dependency name for uv
if not pattern.search(content):
raise Exception(f"{replacement} uv dependency not found in {filepath}")
content = pattern.sub(replacement, content)
with open(filepath, "w") as file:
file.write(content)
def main() -> None:
if len(sys.argv) != 3:
raise Exception("Must specify project name and build type, e.g. langflow-nightly base")
@ -31,8 +53,10 @@ def main() -> None:
if build_type == "base":
update_pyproject_name("src/backend/base/pyproject.toml", new_project_name)
update_uv_dep("pyproject.toml", new_project_name)
elif build_type == "main":
update_pyproject_name("pyproject.toml", new_project_name)
update_uv_dep("pyproject.toml", new_project_name)
else:
raise ValueError(f"Invalid build type: {build_type}")

View file

@ -0,0 +1,42 @@
import os
import sys
import re
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
def update_uv_dep(base_version: str) -> None:
"""Update the langflow-base dependency in pyproject.toml."""
pyproject_path = os.path.join(BASE_DIR, "pyproject.toml")
# Read the pyproject.toml file content
with open(pyproject_path, "r") as file:
content = file.read()
# For the main project, update the langflow-base dependency in the UV section
pattern = re.compile(r'(dependencies\s*=\s*\[\s*\n\s*)("langflow-base==[\d.]+")')
replacement = r'\1"langflow-base-nightly=={}"'.format(base_version)
# Check if the pattern is found
if not pattern.search(content):
raise Exception(f"{pattern} UV dependency not found in {pyproject_path}")
# Replace the matched pattern with the new one
content = pattern.sub(replacement, content)
# Write the updated content back to the file
with open(pyproject_path, "w") as file:
file.write(content)
def main() -> None:
if len(sys.argv) != 2:
raise Exception("specify base version")
base_version = sys.argv[1]
base_version = base_version.lstrip("v")
update_uv_dep(base_version)
if __name__ == "__main__":
main()