From 40f7832bf7336a7a1d2c235a20d99a9b4159f311 Mon Sep 17 00:00:00 2001 From: txtsd Date: Wed, 23 Oct 2024 11:33:25 +0530 Subject: [PATCH] feat(ci): Build and release python sdist and wheel using uv Signed-off-by: txtsd --- .github/files_to_copy | 3 -- .github/scripts/create_asset.sh | 5 ++- .github/workflows/ci.yml | 43 +++++++++++++++----- .github/workflows/release_dev_to_master.yaml | 13 ++++++ .release-it.json | 2 +- dev-requirements.txt | 10 ----- postgres-requirements.txt | 1 - requirements.txt | 6 --- 8 files changed, 51 insertions(+), 32 deletions(-) delete mode 100644 dev-requirements.txt delete mode 100644 postgres-requirements.txt delete mode 100644 requirements.txt diff --git a/.github/files_to_copy b/.github/files_to_copy index d4e5aacb1..64e20a47a 100644 --- a/.github/files_to_copy +++ b/.github/files_to_copy @@ -1,8 +1,5 @@ bazarr custom_libs frontend/build -libs bazarr.py -requirements.txt -postgres-requirements.txt migrations diff --git a/.github/scripts/create_asset.sh b/.github/scripts/create_asset.sh index c60256347..de3645583 100755 --- a/.github/scripts/create_asset.sh +++ b/.github/scripts/create_asset.sh @@ -25,4 +25,7 @@ cp VERSION $to_dist pushd __builds__/bazarr zip -r ../bazarr.zip . -b "$(mktemp -d)" popd -rm -rf $to_dist \ No newline at end of file +rm -rf $to_dist + +uv build +cp --parents dist/bazarr-* __builds__ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7aebfac4..1fec18bf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,11 +6,11 @@ on: paths: - frontend/** - bazarr/** - - libs/** - migrations/** - bazarr.py - - requirements.txt - - dev-requirements.txt + - pyproject.toml + - uv.lock + - .python-version - .github/workflows/ci.yml pull_request: branches: [development] @@ -75,10 +75,33 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v5 + - name: Cache node_modules + uses: actions/cache@v4 with: - python-version: "3.8" + path: "${{ env.UI_DIRECTORY }}/node_modules" + key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-modules- + + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version-file: "${{ env.UI_DIRECTORY }}/.nvmrc" + + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.4.25" # Best practice: pin uv version + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Set up Python + run: uv python install python3.8 + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Remove non-development frontend build + run: rm -rf "${{ env.UI_DIRECTORY }}/build" - name: Install UI uses: actions/download-artifact@v4 @@ -86,12 +109,9 @@ jobs: name: ${{ env.UI_ARTIFACT_NAME }} path: "${{ env.UI_DIRECTORY }}/build" - - name: Install Python dependencies - run: pip install -r requirements.txt - - name: Unit Tests run: | - python3 bazarr.py --no-update & + uv run -- bazarr.py --no-update & PID=$! sleep 15 if kill -s 0 $PID @@ -103,3 +123,6 @@ jobs: echo "**** Bazarr launch failed ****" exit 1 fi + + - name: Minimize uv cache + run: uv cache prune --ci diff --git a/.github/workflows/release_dev_to_master.yaml b/.github/workflows/release_dev_to_master.yaml index 13eaefee7..4ec5c4e64 100644 --- a/.github/workflows/release_dev_to_master.yaml +++ b/.github/workflows/release_dev_to_master.yaml @@ -42,6 +42,19 @@ jobs: with: node-version-file: "${{ env.UI_DIRECTORY }}/.nvmrc" + - name: Install uv + uses: astral-sh/setup-uv@v3 + with: + version: "0.4.25" # Best practice: pin uv version + enable-cache: true + cache-dependency-glob: "uv.lock" + + - name: Set up Python + run: uv python install python3.8 + + - name: Install the project + run: uv sync --all-extras --dev + - name: Install Global Tools run: npm install -g release-it auto-changelog diff --git a/.release-it.json b/.release-it.json index d8a2de9f0..65d5e1055 100644 --- a/.release-it.json +++ b/.release-it.json @@ -7,7 +7,7 @@ "github": { "release": true, "releaseName": "v${version}", - "assets": ["__builds__/*.zip"] + "assets": ["__builds__/*.zip", "__builds__/*.tar.gz", "__builds__/*.whl"] }, "npm": { "publish": false, diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 5241aefd7..000000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -sympy -vcrpy>=1.6.1 -pytest -pytest-pep8 -pytest-flakes -pytest-cov -pytest-vcr -pytest-mock -requests-mock -setuptools diff --git a/postgres-requirements.txt b/postgres-requirements.txt deleted file mode 100644 index 2b39b96f4..000000000 --- a/postgres-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -psycopg2-binary>=2.9.5 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 469b8808b..000000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -setuptools -lxml>=4.3.0, <5.0.0 -numpy>=1.12.0 -webrtcvad-wheels>=2.0.10 -Pillow>=9.0.0 --only-binary=Pillow -pywin32; platform_system == "Windows"