gradio/.github/workflows/build-pr.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
2.6 KiB
YAML
Raw Normal View History

name: Build PR Artifacts
on:
pull_request:
branches:
- main
jobs:
comment-spaces-start:
uses: "./.github/workflows/comment-queue.yml"
secrets:
gh_token: ${{ secrets.COMMENT_TOKEN }}
with:
pr_number: ${{ github.event.pull_request.number }}
message: spaces~pending~null
build_pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version: 18
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install pip
run: python -m pip install build requests
- name: Get PR Number
id: get_pr_number
run: |
python -c "import os;print(os.environ['GITHUB_REF'].split('/')[2])" > pr_number.txt
echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_OUTPUT
echo "GRADIO_VERSION=$(python -c 'import requests;print(requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"])')" >> $GITHUB_OUTPUT
- name: Build pr package
run: |
echo ${{ steps.get_pr_number.outputs.GRADIO_VERSION }} > gradio/version.txt
pnpm i --frozen-lockfile --ignore-scripts
pnpm build
python3 -m build -w
env:
NODE_OPTIONS: --max_old_space_size=8192
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl
path: dist/gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl
- name: Set up Demos
run: |
python scripts/copy_demos.py https://gradio-builds.s3.amazonaws.com/${{ github.sha }}/gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl \
"gradio-client @ git+https://github.com/gradio-app/gradio@${{ github.sha }}#subdirectory=client/python"
- name: Upload all_demos
uses: actions/upload-artifact@v3
with:
name: all_demos
path: demo/all_demos
- name: Create metadata artifact
run: |
python -c "import json; json.dump({'gh_sha': '${{ github.sha }}', 'pr_number': ${{ steps.get_pr_number.outputs.pr_number }}, 'version': '${{ steps.get_pr_number.outputs.GRADIO_VERSION }}', 'wheel': 'gradio-${{ steps.get_pr_number.outputs.GRADIO_VERSION }}-py3-none-any.whl'}, open('metadata.json', 'w'))"
- name: Upload metadata
uses: actions/upload-artifact@v3
with:
name: metadata.json
path: metadata.json