Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix releases with uv #3971

Merged
merged 45 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0e70915
Update scripts
jordanrfrazier Oct 1, 2024
5e8eb93
update the base dep in uv deps
jordanrfrazier Oct 1, 2024
483b7de
update nightly scripts
jordanrfrazier Oct 1, 2024
e97fcf3
Add uv creds for publish
jordanrfrazier Oct 1, 2024
19b2b61
skip tests for now
jordanrfrazier Oct 1, 2024
20dce5d
fix version
jordanrfrazier Oct 1, 2024
a175b89
only build the wheel
jordanrfrazier Oct 1, 2024
3ee34b0
try again
jordanrfrazier Oct 1, 2024
fe21e88
add uv to python run
jordanrfrazier Oct 1, 2024
4c41d89
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 1, 2024
9159aa2
use uv cache
jordanrfrazier Oct 1, 2024
17ae9b3
more version fixe
jordanrfrazier Oct 1, 2024
9959e49
fixing versions
jordanrfrazier Oct 1, 2024
13837ed
fix base version
jordanrfrazier Oct 1, 2024
9271caf
Try no frozen?
jordanrfrazier Oct 1, 2024
19c4d85
skip everything to try docker build
jordanrfrazier Oct 1, 2024
9684f73
tag
jordanrfrazier Oct 1, 2024
7d4944b
frozen
jordanrfrazier Oct 1, 2024
b4be1fa
separate script for updating uv dep
jordanrfrazier Oct 1, 2024
fbcbb8f
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 1, 2024
1747906
hardcoded versions
jordanrfrazier Oct 1, 2024
aaf7e95
hardcoded versions
jordanrfrazier Oct 1, 2024
acb7caa
add version to editable package
jordanrfrazier Oct 1, 2024
f02355c
build project before docker file runs
jordanrfrazier Oct 1, 2024
c412db3
try again
jordanrfrazier Oct 1, 2024
cd3158c
fix uv patht o build
jordanrfrazier Oct 2, 2024
cb4fcf6
don't know why this would mkae a difference
jordanrfrazier Oct 2, 2024
1c26e29
debug statements
jordanrfrazier Oct 2, 2024
2758f9f
debug statements
jordanrfrazier Oct 2, 2024
a73a635
debug statements
jordanrfrazier Oct 2, 2024
b638d86
change path to whl :shrug:
jordanrfrazier Oct 2, 2024
2fadc1a
manually move the wheel...
jordanrfrazier Oct 2, 2024
8fbf81f
make dir
jordanrfrazier Oct 2, 2024
7a8f63e
try no sources
jordanrfrazier Oct 2, 2024
64452e0
add back tests
jordanrfrazier Oct 2, 2024
71af544
refactor uv to action
jordanrfrazier Oct 2, 2024
7a55e8e
add uv action
jordanrfrazier Oct 2, 2024
48514c7
Update nightly build workflow to include uv lock files in version upd…
ogabrielluiz Oct 2, 2024
fdce817
Update lint-py workflow to use specific ref for setup-uv action
ogabrielluiz Oct 2, 2024
e9f6e20
Add checkout step to style-check-py GitHub Actions workflow
ogabrielluiz Oct 2, 2024
9e0efa3
Remove redundant GitHub ref syntax in lint-py.yml workflow
ogabrielluiz Oct 2, 2024
0aa0808
Update lint-py.yml to use specific ref for setup-uv action
ogabrielluiz Oct 2, 2024
83ce5b7
Update action.yml: standardize quotes and remove redundant checkout step
ogabrielluiz Oct 2, 2024
d9ebd82
Add checkout step to GitHub Actions workflows for specific ref handling
ogabrielluiz Oct 2, 2024
dca107e
Add checkout step to Python test workflow with specific ref
ogabrielluiz Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/actions/setup-uv/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Setup uv"
description: "Checks out code, installs uv, and sets up Python environment"
inputs:
ref:
description: "Reference to check out"
required: false
default: "github.ref"

runs:
using: "composite"
steps:
- 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 }}
82 changes: 60 additions & 22 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
required: false
type: string
default: ''

workflow_dispatch:
inputs:
version:
Expand All @@ -48,7 +48,7 @@ on:
required: false
type: string
default: ''

env:
POETRY_VERSION: "1.8.2"
TEST_TAG: "langflowai/langflow:test"
Expand All @@ -65,44 +65,70 @@ jobs:
- name: Resolve nightly tag
id: resolve-nightly-tag
run: |
if [[ "${{ inputs.nightly_tag_main }}" != '' ]]; then
echo "nightly_tag=${{ inputs.nightly_tag_main }}" >> $GITHUB_OUTPUT
echo "nightly_build=true" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.nightly_tag_base }}" != '' ]]; then
# Note - this is more complex than I'd like. For `main` builds, we just pass the `main` tag.
# For `base` builds, we pass both the `base` and `main` tags. This is because the `main` tag is the
# version we need to check out for the build, but the `base` tag is the version we need to build.
#
# So, you need to check for `base` existence before `main`.

if [[ "${{ inputs.nightly_tag_base }}" != '' ]]; then
if [[ "${{ inputs.release_type }}" != "base" ]]; then
echo "Release type is not 'base'. Exiting the workflow."
exit 1
fi

# Main tag must not be empty, otherwise we have no valid tag to check out.
if [[ "${{ inputs.nightly_tag_main }}" == '' ]]; then
echo "Nightly tag main is empty. Exiting the workflow."
exit 1
fi

echo "nightly_tag=${{ inputs.nightly_tag_base }}" >> $GITHUB_OUTPUT
echo "nightly_build=true" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.nightly_tag_main }}" != '' ]]; then
if [[ "${{ inputs.release_type }}" != "main" ]]; then
echo "Release type is not 'main'. Exiting the workflow."
exit 1
fi
echo "nightly_tag=${{ inputs.nightly_tag_main }}" >> $GITHUB_OUTPUT
echo "nightly_build=true" >> $GITHUB_OUTPUT
else
echo "nightly_tag=" >> $GITHUB_OUTPUT
echo "nightly_build=false" >> $GITHUB_OUTPUT
fi

- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main || github.ref }}
- name: Set up Python 3.12 + Poetry ${{ env.POETRY_VERSION }}
uses: "./.github/actions/poetry_caching"
persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
with:
python-version: "3.12"
poetry-version: ${{ env.POETRY_VERSION }}
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
ref: ${{ inputs.nightly_tag_main || github.ref }}

- name: Install the project
run: uv sync --dev

- name: Get Version from Input
if: ${{ inputs.version != '' }}
id: get-version-input
run: |
version=${{ inputs.version }}
echo version=$version
echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Base
if: ${{ inputs.version == '' && inputs.release_type == 'base' }}
id: get-version-base
run: |
version=$(cd src/backend/base && poetry version --short)
version=$(uv tree | grep 'langflow-base' | awk '{print $3}' | sed 's/^v//')
echo version=$version
echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Main
if: ${{ inputs.version == '' && inputs.release_type == 'main' }}
id: get-version-main
run: |
version=$(poetry version --short)
version=$(uv tree | grep 'langflow' | grep -v 'langflow-base' | awk '{print $2}' | sed 's/^v//')
echo version=$version
echo version=$version >> $GITHUB_OUTPUT
setup:
runs-on: ubuntu-latest
Expand All @@ -111,8 +137,6 @@ jobs:
docker_tags: ${{ steps.set-vars.outputs.docker_tags }}
ghcr_tags: ${{ steps.set-vars.outputs.ghcr_tags }}
file: ${{ steps.set-vars.outputs.file }}
env:
NIGHTLY_TAG: ${{ needs.get-version.outputs.nightly-tag }}
steps:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
Expand All @@ -123,7 +147,7 @@ jobs:
id: set-vars
run: |
nightly_suffix=''
if [[ "${{ env.NIGHTLY_TAG }}" != '' ]]; then
if [[ "${{ needs.get-version.outputs.nightly-build }}" == "true" ]]; then
nightly_suffix="-nightly"
fi

Expand All @@ -148,7 +172,21 @@ jobs:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main || github.ref }}
ref: ${{ inputs.ref }}
persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
with:
ref: ${{ inputs.nightly_tag_main || github.ref }}

- name: Install the project
run: |
if [[ "${{ inputs.release_type }}" == "base" ]]; then
cd src/backend/base && uv sync --no-dev --no-sources
jordanrfrazier marked this conversation as resolved.
Show resolved Hide resolved
else
uv sync --no-dev --no-sources
fi

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down Expand Up @@ -213,8 +251,8 @@ jobs:
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.nightly_tag_main || github.ref }}
ref: ${{ inputs.nightly_tag_main || github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -224,15 +262,15 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Github Container Registry
if: ${{ matrix.component == 'ghcr-backend' }} || ${{ matrix.component == 'ghcr-frontend' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.TEMP_GHCR_TOKEN}}

- name: Wait for propagation (for backend)
run: sleep 120

Expand Down
23 changes: 6 additions & 17 deletions .github/workflows/lint-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,15 @@ jobs:
- "3.11"
- "3.10"
steps:
- uses: actions/checkout@v4
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch || github.ref }}
- name: Install uv
uses: astral-sh/setup-uv@v3
persist-credentials: true
- 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: 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.branch || github.ref }}
- name: Install the project
run: uv sync --dev
- name: Run Mypy
Expand Down
46 changes: 15 additions & 31 deletions .github/workflows/nightly_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,19 @@ jobs:
main_tag: ${{ steps.generate_main_tag.outputs.main_tag }}
base_tag: ${{ steps.set_base_tag.outputs.base_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
with:
persist-credentials: true
ref: ${{ github.ref }}

- 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: Generate main nightly tag
id: generate_main_tag
run: |
# NOTE: This outputs the tag with the `v` prefix.
MAIN_TAG="$(uv run python ./scripts/ci/pypi_nightly_tag.py main)"
MAIN_TAG="$(uv run ./scripts/ci/pypi_nightly_tag.py main)"
echo "main_tag=$MAIN_TAG" >> $GITHUB_OUTPUT
echo "main_tag=$MAIN_TAG"

Expand All @@ -72,7 +55,7 @@ jobs:
if: ${{ steps.check_main_tag.outputs.main_tag_exists == 'false' }}
run: |
# NOTE: This outputs the tag with the `v` prefix.
BASE_TAG="$(uv run python ./scripts/ci/pypi_nightly_tag.py base)"
BASE_TAG="$(uv run ./scripts/ci/pypi_nightly_tag.py base)"
echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT
echo "base_tag=$BASE_TAG"

Expand All @@ -85,24 +68,25 @@ jobs:
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="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG"
uv run python ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
uv run python ./scripts/ci/update_pyproject_version.py $BASE_TAG base
uv run ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
uv run ./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
uv run python ./scripts/ci/update_lf_base_dependency.py $BASE_TAG
# Note: Still necessary for poetry
uv run ./scripts/ci/update_lf_base_dependency.py $BASE_TAG

# Use the main tag created earlier
MAIN_TAG="${{ steps.generate_main_tag.outputs.main_tag }}"
echo "Updating main project version to $MAIN_TAG"
uv run python ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
uv run python ./scripts/ci/update_pyproject_name.py langflow-nightly main
uv run ./scripts/ci/update_pyproject_version.py $MAIN_TAG main
uv run ./scripts/ci/update_pyproject_name.py langflow-nightly main
uv run ./scripts/ci/update_uv_dependency.py $BASE_TAG
uv lock
cd src/backend/base && uv lock

git add pyproject.toml src/backend/base/pyproject.toml
git add pyproject.toml src/backend/base/pyproject.toml uv.lock src/backend/base/uv.lock
git commit -m "Update version and project name"

echo "Tagging main with $MAIN_TAG"
Expand Down
25 changes: 7 additions & 18 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,16 @@ jobs:
matrix:
python-version: ${{ fromJson(inputs.python-versions || '["3.10", "3.11", "3.12"]') }}
steps:
- uses: actions/checkout@v4
- name: Check out the code at a specific ref
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}

- 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
persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
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.ref || github.ref }}

- name: Check Version
id: check-version
# We need to print $3 because langflow-base is a dependency of langflow
Expand Down
Loading