Skip to content

Commit

Permalink
ci(test): Test build python tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Nov 2, 2024
1 parent 09fc903 commit 27b67be
Showing 1 changed file with 46 additions and 202 deletions.
248 changes: 46 additions & 202 deletions .github/workflows/release-python-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,210 +42,53 @@ jobs:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker/javascript_worker.wasm

linux:
needs: build-js-worker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Rye
shell: bash
run: |
curl -L https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-linux.gz -o rye.gz
gunzip rye.gz
chmod +x rye
./rye self install --yes
echo "$HOME/.rye/shims" >> $GITHUB_PATH
echo "$HOME/.rye" >> $GITHUB_PATH
- uses: actions/download-artifact@v4
with:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker
- name: Build packages
run: |
# Create dist directory
mkdir -p bindings/python/dist
# Build lyric-task
cd bindings/python/lyric-task
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
# Build lyric-py-worker
cd ../lyric-py-worker
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
# Build lyric-js-worker
cd ../lyric-js-worker
mkdir -p src/lyric_js_worker/
cp ../../javascript/lyric-js-worker/javascript_worker.wasm src/lyric_js_worker/
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: bindings/python/dist

musllinux:
needs: build-js-worker
runs-on: ubuntu-latest
container:
image: quay.io/pypa/musllinux_1_1_x86_64
steps:
- uses: actions/checkout@v4
- name: Install build dependencies
run: |
apk add --no-cache curl bash python3 py3-pip
- name: Install Rye
shell: bash
run: |
curl -L https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-linux-musl.gz -o rye.gz
gunzip rye.gz
chmod +x rye
./rye self install --yes
echo "$HOME/.rye/shims" >> $GITHUB_PATH
echo "$HOME/.rye" >> $GITHUB_PATH
- uses: actions/download-artifact@v4
with:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker
- name: Build packages
run: |
# Create dist directory
mkdir -p bindings/python/dist
# Build lyric-task
cd bindings/python/lyric-task
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
# Build lyric-py-worker
cd ../lyric-py-worker
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
# Build lyric-js-worker
cd ../lyric-js-worker
mkdir -p src/lyric_js_worker/
cp ../../javascript/lyric-js-worker/javascript_worker.wasm src/lyric_js_worker/
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux
path: bindings/python/dist

windows:
needs: build-js-worker
strategy:
matrix:
arch: [x64, x86]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.arch }}
- name: Install Rye
shell: pwsh
run: |
$arch = "${{ matrix.arch }}"
if ($arch -eq "x64") {
$url = "https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-windows.exe"
} else {
$url = "https://github.com/astral-sh/rye/releases/latest/download/rye-x86-windows.exe"
}
Invoke-WebRequest -Uri $url -OutFile rye.exe
$env:RYE_NO_AUTO_INSTALL = "1"
.\rye.exe self install --yes
echo "$env:USERPROFILE\.rye\shims" >> $env:GITHUB_PATH
echo "$env:USERPROFILE\.rye" >> $env:GITHUB_PATH
- uses: actions/download-artifact@v4
with:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker
- name: Build packages
shell: pwsh
run: |
# Create dist directory
New-Item -ItemType Directory -Force -Path bindings\python\dist
# Build lyric-task
Set-Location bindings\python\lyric-task
rye sync --no-dev
rye build
Copy-Item dist\*.whl ..\dist\
# Build lyric-py-worker
Set-Location ..\lyric-py-worker
rye sync --no-dev
rye build
Copy-Item dist\*.whl ..\dist\
# Build lyric-js-worker
Set-Location ..\lyric-js-worker
New-Item -ItemType Directory -Force -Path src\lyric_js_worker
Copy-Item ..\..\javascript\lyric-js-worker\javascript_worker.wasm src\lyric_js_worker\
rye sync --no-dev
rye build
Copy-Item dist\*.whl ..\dist\
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.arch }}
path: bindings/python/dist

macos:
build-packages:
needs: build-js-worker
strategy:
fail-fast: false
matrix:
include:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
runs-on: ${{ matrix.runner }}
- os: ubuntu-latest
target: linux
- os: ubuntu-latest
target: musllinux
container:
image: quay.io/pypa/musllinux_1_1_x86_64
- os: windows-latest
target: windows-x64
arch: x64
- os: windows-latest
target: windows-x86
arch: x86
- os: macos-12
target: macos-x86_64
- os: macos-14
target: macos-aarch64

runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Remove lyric-py directory
shell: bash
run: rm -rf bindings/python/lyric-py
- uses: eifinger/setup-rye@v4
with:
python-version: '3.11'
- name: Install Rye
run: |
if [ "${{ matrix.target }}" = "aarch64" ]; then
curl -L https://github.com/astral-sh/rye/releases/latest/download/rye-aarch64-macos.gz -o rye.gz
else
curl -L https://github.com/astral-sh/rye/releases/latest/download/rye-x86_64-macos.gz -o rye.gz
fi
gunzip rye.gz
chmod +x rye
./rye self install --yes
echo "$HOME/.rye/shims" >> $GITHUB_PATH
echo "$HOME/.rye" >> $GITHUB_PATH
enable-cache: true
working-directory: bindings/python
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker

- name: Build packages
shell: bash
run: |
# Create dist directory
mkdir -p bindings/python/dist
cd bindings/python
# Build lyric-task
cd bindings/python/lyric-task
cd lyric-task
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
Expand All @@ -263,36 +106,36 @@ jobs:
rye sync --no-dev
rye build
cp dist/*.whl ../dist/
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
name: wheels-${{ matrix.target }}
path: bindings/python/dist

sdist:
needs: build-js-worker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Remove lyric-py directory
run: rm -rf bindings/python/lyric-py
- uses: eifinger/setup-rye@v4
with:
python-version: '3.11'
- name: Install Rye
shell: bash
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
enable-cache: true
working-directory: bindings/python
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: js-worker-wasm
path: bindings/javascript/lyric-js-worker

- name: Build sdist
run: |
# Create dist directory
mkdir -p bindings/python/dist
cd bindings/python
# Build lyric-task
cd bindings/python/lyric-task
cd lyric-task
rye sync --no-dev
rye build --sdist
cp dist/*.tar.gz ../dist/
Expand All @@ -310,6 +153,7 @@ jobs:
rye sync --no-dev
rye build --sdist
cp dist/*.tar.gz ../dist/
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
Expand All @@ -320,7 +164,7 @@ jobs:
# name: Release
# runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/')
# needs: [linux, musllinux, windows, macos, sdist]
# needs: [build-packages, sdist]
# environment: release
# permissions:
# id-token: write
Expand All @@ -340,7 +184,7 @@ jobs:
name: Test Wheels
runs-on: ubuntu-latest
if: github.event_name != 'release'
needs: [linux, musllinux, windows, macos, sdist]
needs: [build-packages, sdist]
steps:
- uses: actions/download-artifact@v4
with:
Expand Down

0 comments on commit 27b67be

Please sign in to comment.