chore: import upstream snapshot with attribution
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
publish / version_or_publish (push) Has been cancelled
storybook-build / changes (push) Has been cancelled
storybook-build / :storybook-build (push) Has been cancelled
Sync Gradio Skills to Hugging Face / sync-skills (push) Has been cancelled
functional / changes (push) Has been cancelled
functional / build-frontend (push) Has been cancelled
functional / functional-test-SSR=false (push) Has been cancelled
functional / functional-reload (push) Has been cancelled
js / changes (push) Has been cancelled
js / js-test (push) Has been cancelled
docs-build / changes (push) Has been cancelled
docs-build / docs-build (push) Has been cancelled
docs-build / website-build (push) Has been cancelled
functional / functional-test-SSR=true (push) Has been cancelled
hygiene / hygiene-test (push) Has been cancelled
python / changes (push) Has been cancelled
python / build (push) Has been cancelled
python / test-ubuntu-latest-flaky (push) Has been cancelled
python / test-ubuntu-latest-not-flaky (push) Has been cancelled
python / test-windows-latest-flaky (push) Has been cancelled
python / test-windows-latest-not-flaky (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
name: Comment on pull request without race conditions
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr_number:
|
||||
type: string
|
||||
message:
|
||||
required: true
|
||||
type: string
|
||||
tag:
|
||||
required: false
|
||||
type: string
|
||||
default: "previews"
|
||||
additional_text:
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
secrets:
|
||||
gh_token:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
environment: comment_pr
|
||||
concurrency:
|
||||
group: ${{inputs.pr_number || inputs.tag}}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: comment on pr
|
||||
uses: "gradio-app/github/actions/comment-pr@main"
|
||||
with:
|
||||
gh_token: ${{ secrets.gh_token }}
|
||||
tag: ${{ inputs.tag }}
|
||||
pr_number: ${{ inputs.pr_number}}
|
||||
message: ${{ inputs.message }}
|
||||
additional_text: ${{ inputs.additional_text }}
|
||||
@@ -0,0 +1,42 @@
|
||||
# safe runs from main
|
||||
|
||||
name: Delete Stale Spaces
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
daysStale:
|
||||
description: "How stale a space needs to be to be deleted (days)"
|
||||
required: true
|
||||
default: "7"
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
delete-old-spaces:
|
||||
permissions:
|
||||
contents: read
|
||||
environment: deploy_spaces
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install pip
|
||||
run: python -m pip install pip wheel requests
|
||||
- name: Install Hub Client Library
|
||||
run: pip install huggingface-hub==0.9.1
|
||||
- name: Set daysStale
|
||||
env:
|
||||
DEFAULT_DAYS_STALE: "7"
|
||||
DAYS_STALE: ${{ github.event.inputs.daysStale || env.DEFAULT_DAYS_STALE}}
|
||||
run: echo DAYS_STALE= "$DAYS_STALE" >> $GITHUB_ENV
|
||||
- name: Find and delete stale spaces
|
||||
run: |
|
||||
python scripts/delete_old_spaces.py $DAYS_STALE \
|
||||
gradio-pr-deploys \
|
||||
${{ secrets.WEBSITE_SPACES_DEPLOY_TOKEN }}
|
||||
@@ -0,0 +1,172 @@
|
||||
name: "frontend-profiling"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
concurrency:
|
||||
group: "frontend-profiling-${{ github.event.pull_request.number }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
benchmark:
|
||||
env:
|
||||
UV_EXCLUDE_NEWER: 7 days
|
||||
PLAYWRIGHT_VERSION: 1.60.0
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
name: "frontend-benchmark"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "js"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Find latest release tag
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
id: latest_tag
|
||||
run: echo "tag=$(git tag --list 'gradio@*' --sort=-v:refname | head -n 1)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Python
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Install uv
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
run: curl -LsSf https://astral.sh/uv/0.11.3/install.sh | sh
|
||||
|
||||
- name: Install pnpm
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # @v4
|
||||
with:
|
||||
version: 10.17.0
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
cache-dependency-path: pnpm-lock.yaml
|
||||
|
||||
# Install the benchmark "base" (latest release) straight from PyPI instead
|
||||
# of checking out the tag and rebuilding it — the published wheel already
|
||||
# ships the built frontend (gradio/templates), so this drops the ~4min base
|
||||
# `pnpm build` on every run. We stay on the PR checkout the whole job: the
|
||||
# benchmark spec + demo are the PR's versions for both runs, and the demo is
|
||||
# launched as `python <runner>.py` (the runner/demo dir is on sys.path, not
|
||||
# the cwd), so `import gradio` resolves to the installed package — the wheel
|
||||
# here, the editable PR build later. Base and PR use separate venvs so the
|
||||
# PR's editable install can't shadow the base wheel.
|
||||
- name: Install base gradio from the published release (base)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
run: |
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
uv venv --python=3.10 venv_base
|
||||
. venv_base/bin/activate
|
||||
TAG="${{ steps.latest_tag.outputs.tag }}"
|
||||
uv pip install "gradio==${TAG#gradio@}"
|
||||
|
||||
- name: Install frontend test deps (base)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
# node_modules is only needed to run the Playwright benchmark (no build).
|
||||
run: |
|
||||
pnpm i --frozen-lockfile --ignore-scripts
|
||||
pnpm add -Dw --ignore-scripts playwright@$PLAYWRIGHT_VERSION @playwright/test@$PLAYWRIGHT_VERSION
|
||||
|
||||
- name: Cache Playwright Browsers
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
playwright-${{ runner.os }}-
|
||||
|
||||
- name: Install Playwright (base)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
timeout-minutes: 3
|
||||
run: pnpm exec playwright install chromium --only-shell
|
||||
|
||||
- name: Run benchmark (base)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
run: |
|
||||
. venv_base/bin/activate
|
||||
PERF_RESULTS_FILE=/tmp/bench_base.json pnpm exec playwright test \
|
||||
--config .config/playwright.config.js \
|
||||
js/spa/test/big_complex_demo.spec.ts
|
||||
|
||||
- name: Install and build PR
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
run: |
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
uv venv --allow-existing venv --python=3.10
|
||||
. venv/bin/activate
|
||||
uv pip install -e client/python
|
||||
uv pip install -e ".[oauth,mcp]"
|
||||
pnpm install --no-frozen-lockfile
|
||||
pnpm css && pnpm build
|
||||
|
||||
- name: Install Playwright (PR)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
timeout-minutes: 3
|
||||
run: pnpm exec playwright install chromium --only-shell
|
||||
|
||||
- name: Run benchmark (PR)
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
PERF_RESULTS_FILE=/tmp/bench_pr.json pnpm exec playwright test \
|
||||
--config .config/playwright.config.js \
|
||||
js/spa/test/big_complex_demo.spec.ts
|
||||
|
||||
- name: Compare results
|
||||
id: compare
|
||||
if: steps.changes.outputs.should_run == 'true'
|
||||
env:
|
||||
BASE_TAG: ${{ steps.latest_tag.outputs.tag }}
|
||||
run: node scripts/compare_frontend_benchmarks.js
|
||||
|
||||
- name: Post or update PR comment
|
||||
if: steps.compare.outputs.failed == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
const body = fs.readFileSync('/tmp/bench_comment.md', 'utf8');
|
||||
const marker = '<!-- frontend-perf-benchmark -->';
|
||||
const commentBody = marker + '\n' + body;
|
||||
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
});
|
||||
|
||||
const existing = comments.find(c => c.body.includes(marker));
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: existing.id,
|
||||
body: commentBody,
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: commentBody,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
name: Generate changeset
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["trigger-changeset"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
env:
|
||||
CI: true
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}"
|
||||
cancel-in-progress: false
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
get-pr:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
outputs:
|
||||
found_pr: ${{ steps.pr_details.outputs.found_pr }}
|
||||
pr_number: ${{ steps.pr_details.outputs.pr_number }}
|
||||
source_repo: ${{ steps.pr_details.outputs.source_repo }}
|
||||
source_branch: ${{ steps.pr_details.outputs.source_branch }}
|
||||
actor: ${{ steps.pr_details.outputs.actor }}
|
||||
sha: ${{ steps.pr_details.outputs.sha }}
|
||||
steps:
|
||||
- name: get pr details
|
||||
id: pr_details
|
||||
uses: gradio-app/github/actions/find-pr@main
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
comment-changes-start:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: get-pr
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||
message: changes~pending~null
|
||||
version:
|
||||
permissions:
|
||||
contents: read
|
||||
environment: changeset
|
||||
name: version
|
||||
needs: get-pr
|
||||
runs-on: ubuntu-latest
|
||||
if: needs.get-pr.outputs.found_pr == 'true'
|
||||
outputs:
|
||||
skipped: ${{ steps.version.outputs.skipped }}
|
||||
comment_url: ${{ steps.version.outputs.comment_url }}
|
||||
approved: ${{ steps.version.outputs.approved }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ needs.get-pr.outputs.source_repo }}
|
||||
ref: ${{ needs.get-pr.outputs.source_branch }}
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMENT_TOKEN }}
|
||||
- name: generate changeset
|
||||
id: version
|
||||
uses: "gradio-app/github/actions/generate-changeset@main"
|
||||
with:
|
||||
github_token: ${{ secrets.CHANGESET_GITHUB_TOKEN }}
|
||||
main_pkg: gradio
|
||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||
branch_name: ${{ needs.get-pr.outputs.source_branch }}
|
||||
actor: ${{ needs.get-pr.outputs.actor }}
|
||||
update-status:
|
||||
permissions:
|
||||
actions: read
|
||||
statuses: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, get-pr]
|
||||
steps:
|
||||
- name: update status
|
||||
uses: gradio-app/github/actions/commit-status@main
|
||||
with:
|
||||
sha: ${{ needs.get-pr.outputs.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Changeset Results"
|
||||
pr: ${{ needs.get-pr.outputs.pr_number }}
|
||||
# Temporarily disabled: the changeset approval requirement was more hassle than
|
||||
# it was worth (the check failed whenever a maintainer hadn't ticked the approval
|
||||
# checkbox). Force the check to pass for now. To re-enable, restore the line below.
|
||||
# result: ${{ needs.version.outputs.approved == 'true' && 'success' || 'failure' }}
|
||||
result: success
|
||||
type: all
|
||||
comment-changes-skipped:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [get-pr, version]
|
||||
if: needs.version.result == 'success' && needs.version.outputs.skipped == 'true'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||
message: changes~warning~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
comment-changes-success:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [get-pr, version]
|
||||
if: needs.version.result == 'success' && needs.version.outputs.skipped == 'false'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||
message: changes~success~${{ needs.version.outputs.comment_url }}
|
||||
comment-changes-failure:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [get-pr, version]
|
||||
if: always() && needs.version.result == 'failure'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.get-pr.outputs.pr_number }}
|
||||
message: changes~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
@@ -0,0 +1,58 @@
|
||||
name: "npm"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
pr_number: ${{ steps.changes.outputs.pr_number }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "js"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
preview:
|
||||
permissions:
|
||||
contents: read
|
||||
name: npm-previews
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-frontend-deps@main"
|
||||
with:
|
||||
skip_build: true
|
||||
- name: Setup Node.js 24
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "24"
|
||||
- name: package
|
||||
run: pnpm package
|
||||
- name: build client
|
||||
run: pnpm --filter @gradio/client --filter @gradio/preview build
|
||||
- name: publish npm previews
|
||||
run: pnpx pkg-pr-new@latest publish './js/*' './client/js' --comment=off
|
||||
@@ -0,0 +1,77 @@
|
||||
name: "previews-build"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
gradio_version: ${{ steps.changes.outputs.gradio_version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "functional"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
build:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "previews-build"
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.12"
|
||||
skip_docs_gen: true
|
||||
- name: install deps
|
||||
run: python -m pip install build
|
||||
- name: Build pr package
|
||||
run: |
|
||||
python -c 'import json; j = json.load(open("gradio/package.json")); j["version"] = "${{ needs.changes.outputs.gradio_version }}"; json.dump(j, open("gradio/package.json", "w"))'
|
||||
python3 -m build -w
|
||||
- name: Upload Python package
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gradio-build
|
||||
path: dist/gradio-${{ needs.changes.outputs.gradio_version }}-py3-none-any.whl
|
||||
- name: copy demos
|
||||
uses: "gradio-app/github/actions/copy-demos@main"
|
||||
with:
|
||||
gradio_version: "https://huggingface.co/buckets/gradio/pypi-previews/resolve/${{ needs.changes.outputs.sha }}/gradio-${{ needs.changes.outputs.gradio_version }}-py3-none-any.whl"
|
||||
gradio_client_version: "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python"
|
||||
config_path: ".config/demos.json"
|
||||
- name: upload demos
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: all_demos
|
||||
path: demo
|
||||
- name: Build JS client
|
||||
run: pnpm --filter @gradio/client build
|
||||
- name: Upload JS client dist artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: js-client-dist
|
||||
path: client/js/dist
|
||||
@@ -0,0 +1,156 @@
|
||||
name: "previews-deploy"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["previews-build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
gradio_version: ${{ steps.json.outputs.gradio_version }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
|
||||
comment-spaces-start:
|
||||
needs: changes
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
if: ${{ needs.changes.outputs.should_run == 'true' }}
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: spaces~pending~null
|
||||
deploy:
|
||||
name: "previews-deploy"
|
||||
environment: deploy_spaces
|
||||
outputs:
|
||||
space_url: ${{ steps.upload-demo.outputs.SPACE_URL }}
|
||||
needs: changes
|
||||
if: ${{ (github.event.workflow_run.conclusion == 'success' && needs.changes.outputs.should_run == 'true') || github.event.workflow_run.event == 'workflow_dispatch' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
steps:
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: list artifacts
|
||||
run: ls -R .
|
||||
|
||||
- name: Set wheel name
|
||||
id: set_wheel_name
|
||||
run: |
|
||||
wheel_file=$(find ./gradio-build -maxdepth 1 -type f -name "*.whl" -print -quit)
|
||||
echo "wheel_name=$wheel_file" >> $GITHUB_OUTPUT
|
||||
- name: Install hf CLI
|
||||
run: curl -LsSf https://hf.co/cli/install.sh | bash -s
|
||||
- name: Upload wheel
|
||||
run: hf buckets cp ${{ steps.set_wheel_name.outputs.wheel_name }} hf://buckets/gradio/pypi-previews/${{ needs.changes.outputs.sha }}/
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.PYPI_PREVIEWS_TOKEN }}
|
||||
|
||||
- name: Upload JS client dist to HF
|
||||
run: |
|
||||
if [ -d ./js-client-dist ]; then
|
||||
hf buckets sync ./js-client-dist hf://buckets/gradio/npm-previews/${{ needs.changes.outputs.sha }}
|
||||
else
|
||||
echo "Skipping JS client dist upload: ./js-client-dist not found."
|
||||
fi
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.PYPI_PREVIEWS_TOKEN }}
|
||||
|
||||
- name: Install Hub Client Library
|
||||
run: |
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install huggingface-hub==0.23.2
|
||||
# temporary, but ensures the script cannot be modified in a PR
|
||||
- name: Get deploy scripts
|
||||
run: |
|
||||
mkdir scripts
|
||||
curl https://raw.githubusercontent.com/gradio-app/gradio/main/scripts/upload_demo_to_space.py -o scripts/upload_demo_to_space.py
|
||||
curl https://raw.githubusercontent.com/gradio-app/gradio/main/scripts/upload_website_demos.py -o scripts/upload_website_demos.py
|
||||
- name: make dirs
|
||||
run: mkdir -p demo && mv all_demos/* demo/
|
||||
- name: Upload demo to spaces
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
id: upload-demo
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
python scripts/upload_demo_to_space.py all_demos \
|
||||
gradio-pr-deploys/pr-${{ needs.changes.outputs.pr_number }}-all-demos \
|
||||
${{ secrets.WEBSITE_SPACES_DEPLOY_TOKEN }} \
|
||||
--gradio-version ${{ needs.changes.outputs.gradio_version }} > url.txt
|
||||
echo "SPACE_URL=$(tail -n 1 url.txt)" >> $GITHUB_OUTPUT
|
||||
- name: Upload Website Demos
|
||||
if: github.event.workflow_run.event == 'workflow_dispatch'
|
||||
id: upload-website-demos
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
python scripts/upload_website_demos.py --AUTH_TOKEN ${{ secrets.WEBSITE_SPACES_DEPLOY_TOKEN }} \
|
||||
--WHEEL_URL https://huggingface.co/buckets/gradio/pypi-previews/resolve/${{ needs.changes.outputs.sha }}/ \
|
||||
--CLIENT_URL "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python" \
|
||||
--GRADIO_VERSION ${{ needs.changes.outputs.gradio_version }}
|
||||
|
||||
comment-spaces-success:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: needs.changes.outputs.should_run == 'true' && needs.deploy.result == 'success'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: spaces~success~${{ needs.deploy.outputs.space_url }}
|
||||
additional_text: |
|
||||
**Install Gradio from this PR**
|
||||
```bash
|
||||
pip install https://huggingface.co/buckets/gradio/pypi-previews/resolve/${{ needs.changes.outputs.sha }}/gradio-${{ needs.changes.outputs.gradio_version }}-py3-none-any.whl
|
||||
```
|
||||
|
||||
**Install Gradio Python Client from this PR**
|
||||
```bash
|
||||
pip install "gradio-client @ git+https://github.com/gradio-app/gradio@${{ needs.changes.outputs.sha }}#subdirectory=client/python"
|
||||
```
|
||||
|
||||
**Import Gradio JS Client from this PR via CDN**
|
||||
```js
|
||||
import { Client } from "https://huggingface.co/buckets/gradio/npm-previews/resolve/${{ needs.changes.outputs.sha }}/browser.js";
|
||||
```
|
||||
comment-spaces-failure:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: always() && needs.deploy.result == 'failure' && needs.changes.outputs.should_run == 'true'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: spaces~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
@@ -0,0 +1,92 @@
|
||||
# safe runs from main
|
||||
|
||||
name: publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PNPM_CACHE_FOLDER: .pnpm-store
|
||||
jobs:
|
||||
version_or_publish:
|
||||
runs-on: ubuntu-22.04
|
||||
environment: publish
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.12"
|
||||
skip_build: "false"
|
||||
skip_docs_gen: true
|
||||
- name: Build packages
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
pnpm package
|
||||
pnpm --filter @gradio/client build
|
||||
- name: update npm
|
||||
run: npm i -g npm@latest
|
||||
- name: check node version
|
||||
run: node -v
|
||||
- name: check npm version
|
||||
run: npm -v
|
||||
- name: create and publish versions
|
||||
id: changesets
|
||||
uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # @v1
|
||||
with:
|
||||
version: pnpm ci:version
|
||||
commit: "chore: update versions"
|
||||
title: "chore: update versions"
|
||||
publish: pnpm ci:publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GRADIO_PAT }}
|
||||
- name: Upload npm logs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: npm-logs
|
||||
path: |
|
||||
/home/runner/.npm/_logs/
|
||||
~/.npm/_logs/
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
- name: add label to skip chromatic build
|
||||
if: ${{ steps.changesets.outputs.pullRequestNumber != '' && steps.changesets.outputs.pullRequestNumber != 'undefined' }}
|
||||
run: gh pr edit "$PR_NUMBER" --add-label "no-visual-update"
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
|
||||
GITHUB_TOKEN: ${{ secrets.GRADIO_PAT }}
|
||||
- name: add label to run flaky tests
|
||||
if: ${{ steps.changesets.outputs.pullRequestNumber != '' && steps.changesets.outputs.pullRequestNumber != 'undefined' }}
|
||||
run: gh pr edit "$PR_NUMBER" --add-label "flaky-tests"
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
|
||||
GITHUB_TOKEN: ${{ secrets.GRADIO_PAT }}
|
||||
- name: add label to run backend tests on Windows
|
||||
if: ${{ steps.changesets.outputs.pullRequestNumber != '' && steps.changesets.outputs.pullRequestNumber != 'undefined' }}
|
||||
run: gh pr edit "$PR_NUMBER" --add-label "windows-tests"
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
|
||||
GITHUB_TOKEN: ${{ secrets.GRADIO_PAT }}
|
||||
- name: publish to pypi
|
||||
if: steps.changesets.outputs.hasChangesets != 'true'
|
||||
uses: "gradio-app/github/actions/publish-pypi@main"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.SDK_AWS_S3_BUCKET_ACCESS_KEY }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_AWS_S3_BUCKET_SECRET_ACCESS_KEY }}
|
||||
AWS_DEFAULT_REGION: us-west-2
|
||||
with:
|
||||
use-oidc: true
|
||||
- name: trigger spaces deploy workflow
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMENT_TOKEN }}
|
||||
run: gh workflow run previews-build.yml
|
||||
@@ -0,0 +1,68 @@
|
||||
name: semgrep ci
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["trigger-semgrep"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
semgrep:
|
||||
permissions:
|
||||
contents: read
|
||||
name: semgrep/ci
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: semgrep/semgrep
|
||||
options: --volume ${{ github.workspace }}/.github/configs:/mnt/ --name semgrepcontainer
|
||||
outputs:
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
if: (github.actor != 'dependabot[bot]')
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ steps.json.outputs.source_repo }}
|
||||
ref: ${{ steps.json.outputs.sha }}
|
||||
- name: restart docker
|
||||
uses: docker://docker
|
||||
with:
|
||||
args: docker restart semgrepcontainer
|
||||
- run: ls -la /mnt
|
||||
- run: semgrep ci --config=/mnt/semgrep_rules.yaml
|
||||
update-status:
|
||||
permissions:
|
||||
actions: read
|
||||
statuses: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: semgrep
|
||||
steps:
|
||||
- name: update status
|
||||
uses: gradio-app/github/actions/commit-status@main
|
||||
with:
|
||||
sha: ${{ needs.semgrep.outputs.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Semgrep Results"
|
||||
pr: ${{ needs.semgrep.outputs.pr_number }}
|
||||
result: ${{ needs.semgrep.result == 'success' && 'success' || 'failure' }}
|
||||
type: all
|
||||
@@ -0,0 +1,81 @@
|
||||
name: "storybook-build"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 5.0-dev
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "visual"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
build:
|
||||
permissions:
|
||||
contents: read
|
||||
name: :storybook-build
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.changes.outputs.source_branch }}
|
||||
repository: ${{ needs.changes.outputs.source_repo }}
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.10"
|
||||
skip_build: true
|
||||
skip_docs_gen: true
|
||||
- name: build client
|
||||
run: pnpm --filter @gradio/client build
|
||||
- name: generate theme.css
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
python scripts/generate_theme.py --outfile js/storybook/theme.css
|
||||
- name: cache playwright browsers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
playwright-${{ runner.os }}-
|
||||
- name: install playwright
|
||||
timeout-minutes: 3
|
||||
run: pnpm exec playwright install chromium --only-shell
|
||||
- name: build storybook
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
pnpm build-storybook --quiet --stats-json
|
||||
- name: upload storybook
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: storybook-static
|
||||
path: storybook-static
|
||||
@@ -0,0 +1,127 @@
|
||||
name: "storybook-deploy"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["storybook-build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
comment-chromatic-start:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || contains(needs.changes.outputs.labels, 'no-visual-update')
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: |
|
||||
storybook~pending~null
|
||||
update-status:
|
||||
permissions:
|
||||
actions: read
|
||||
statuses: write
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'false' || contains(needs.changes.outputs.labels, 'no-visual-update')
|
||||
steps:
|
||||
- name: update status
|
||||
uses: gradio-app/github/actions/set-commit-status@main
|
||||
with:
|
||||
sha: ${{ needs.changes.outputs.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "UI Tests"
|
||||
run_id: ${{ needs.changes.outputs.run_id }}
|
||||
deploy:
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
environment: storybook
|
||||
name: "storybook-deploy"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' && github.repository == 'gradio-app/gradio' && !contains(needs.changes.outputs.labels, 'no-visual-update')
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
changes: ${{ steps.publish-chromatic.outputs.changeCount }}
|
||||
errors: ${{ steps.publish-chromatic.outputs.errorCount }}
|
||||
storybook_url: ${{ steps.publish-chromatic.outputs.storybookUrl }}
|
||||
build_url: ${{ steps.publish-chromatic.outputs.buildUrl }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.changes.outputs.source_branch }}
|
||||
repository: ${{ needs.changes.outputs.source_repo }}
|
||||
fetch-depth: 0
|
||||
- name: dowload storybook artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: storybook-static
|
||||
path: storybook-static
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: list artifacts
|
||||
run: ls -R .
|
||||
- name: create dummy pkg.json
|
||||
run: echo "{}" > package.json
|
||||
- name: publish to chromatic
|
||||
id: publish-chromatic
|
||||
uses: chromaui/action@v13
|
||||
with:
|
||||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
|
||||
token: ${{ secrets.COMMIT_STATUS }}
|
||||
onlyChanged: true
|
||||
exitOnceUploaded: true
|
||||
storybookBuildDir: storybook-static
|
||||
untraced: "package.json pnpm-lock.yaml .github/** **/*.py **/*.md"
|
||||
|
||||
comment-chromatic-end:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: |
|
||||
storybook~success~${{ needs.deploy.outputs.storybook_url }}
|
||||
|
||||
comment-chromatic-fail:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: always() && needs.deploy.result == 'failure'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: |
|
||||
storybook~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
@@ -0,0 +1,32 @@
|
||||
name: "sync-frontend"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- changeset-release/main
|
||||
|
||||
permissions: {}
|
||||
|
||||
env:
|
||||
CI: true
|
||||
|
||||
jobs:
|
||||
sync-frontend:
|
||||
permissions:
|
||||
contents: read
|
||||
environment: deploy_spaces
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install pip
|
||||
run: python -m pip install pip wheel requests
|
||||
- name: Install Hub Client Library
|
||||
run: pip install huggingface-hub
|
||||
- name: Sync Front End Files To Hub
|
||||
run: |
|
||||
python scripts/sync_frontend.py \
|
||||
${{ secrets.SYNC_FRONTEND }}
|
||||
@@ -0,0 +1,74 @@
|
||||
name: Sync Gradio Skills to Hugging Face
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- ".agents/skills/**"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync-skills:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout gradio repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Determine PR title
|
||||
id: pr_title
|
||||
run: |
|
||||
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||
echo "title=Sync Gradio Skills (${{ github.sha }})" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "title=Sync Gradio Skills (manual trigger)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Checkout skills repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: huggingface/skills
|
||||
token: ${{ secrets.GRADIO_PAT }}
|
||||
path: skills-repo
|
||||
|
||||
- name: Copy gradio skill files
|
||||
run: |
|
||||
mkdir -p skills-repo/skills/gradio/references
|
||||
cp -r .agents/skills/gradio/* skills-repo/skills/gradio/
|
||||
|
||||
- name: Copy hf-gradio skill files
|
||||
run: |
|
||||
mkdir -p skills-repo/skills/hf-gradio
|
||||
cp -r .agents/skills/hf-gradio/* skills-repo/skills/hf-gradio/
|
||||
|
||||
- name: Regenerate skills repo artifacts
|
||||
working-directory: skills-repo
|
||||
run: ./scripts/publish.sh
|
||||
|
||||
- name: Check for changes
|
||||
id: check_changes
|
||||
working-directory: skills-repo
|
||||
run: |
|
||||
git diff --quiet && echo "changed=false" >> $GITHUB_OUTPUT || echo "changed=true" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.check_changes.outputs.changed == 'true'
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GRADIO_PAT }}
|
||||
path: skills-repo
|
||||
branch: sync/gradio-skills-${{ github.run_id }}
|
||||
delete-branch: true
|
||||
title: ${{ steps.pr_title.outputs.title }}
|
||||
body: |
|
||||
Auto-generated from [gradio@${{ github.sha }}](https://github.com/gradio-app/gradio/commit/${{ github.sha }})
|
||||
|
||||
Triggered by changes to `.agents/skills/`
|
||||
|
||||
---
|
||||
This PR was created automatically by the [sync-skills](https://github.com/gradio-app/gradio/blob/main/.github/workflows/sync-skills.yml) workflow.
|
||||
commit-message: "Sync Gradio skills from gradio@${{ github.sha }}"
|
||||
labels: |
|
||||
automated
|
||||
@@ -0,0 +1,151 @@
|
||||
name: "functional"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 5.0-dev
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
env:
|
||||
CI: true
|
||||
UV_EXCLUDE_NEWER: 7 days
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
pr_number: ${{ steps.changes.outputs.pr_number }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "functional"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
build:
|
||||
name: "build-frontend"
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-20.04-16core
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# Build the frontend exactly once and share it with both SSR test legs
|
||||
# (below) via an artifact. Previously each leg rebuilt it independently,
|
||||
# paying the ~3min `pnpm build` twice. This action sets up node/pnpm,
|
||||
# installs deps and builds into `gradio/templates/**` (the SPA + the SSR
|
||||
# server bundle) — no Python/venv needed (the build only reads the
|
||||
# checked-in `gradio/package.json` for the version string).
|
||||
- name: build frontend
|
||||
uses: "gradio-app/gradio/.github/actions/install-frontend-deps@main"
|
||||
- name: upload built frontend templates
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gradio-templates
|
||||
path: gradio/templates
|
||||
retention-days: 1
|
||||
include-hidden-files: true
|
||||
test:
|
||||
# Browser legs keep their original check names (functional-test-SSR=true/
|
||||
# false); reload runs as its own leg named functional-reload.
|
||||
name: "${{ matrix.suite == 'reload' && 'functional-reload' || format('functional-test-SSR={0}', matrix.ssr) }}"
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-20.04-16core
|
||||
needs: [changes, build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Reload tests get their own leg instead of running after the browser
|
||||
# suite inside each SSR leg: the ~99s serial reload run is taken off the
|
||||
# browser legs' critical path. Reload doesn't depend on SSR mode (the
|
||||
# reload step never set GRADIO_SSR_MODE), so it runs once here rather
|
||||
# than redundantly in both legs.
|
||||
include:
|
||||
- { suite: browser, ssr: true }
|
||||
- { suite: browser, ssr: false }
|
||||
- { suite: reload }
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# `skip_build: true` skips the frontend build (we download it from the
|
||||
# `build` job instead). `skip_docs_gen: true` skips website JSON/CSS-var
|
||||
# doc generation (~80s, irrelevant to browser tests); it's a new input on
|
||||
# install-all-deps, so it only takes effect once this PR is merged and the
|
||||
# @main action carries it (the current @main ignores the unknown input).
|
||||
- name: install dependencies
|
||||
id: install_deps
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.10"
|
||||
test: true
|
||||
skip_build: true
|
||||
skip_docs_gen: true
|
||||
- name: download built frontend templates
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: gradio-templates
|
||||
path: gradio/templates
|
||||
- name: verify frontend templates present
|
||||
run: |
|
||||
test -f gradio/templates/frontend/index.html \
|
||||
|| { echo "::error::frontend templates missing after artifact download"; ls -laR gradio/templates | head -50; exit 1; }
|
||||
test -d gradio/templates/node/build \
|
||||
|| { echo "::error::SSR node build missing after artifact download"; ls -laR gradio/templates | head -50; exit 1; }
|
||||
- name: cache playwright browsers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
playwright-${{ runner.os }}-
|
||||
- name: install playwright
|
||||
timeout-minutes: 3
|
||||
run: pnpm exec playwright install chromium --only-shell
|
||||
- name: build essential packages
|
||||
run: pnpm --filter @gradio/utils --filter @gradio/theme package
|
||||
- name: run browser tests
|
||||
if: matrix.suite == 'browser'
|
||||
env:
|
||||
GRADIO_SSR_MODE: ${{ matrix.ssr }}
|
||||
# 16-core runner + largely wait-bound tests → parallelize beyond the
|
||||
# historical default of 4 workers (see .config/playwright.config.js).
|
||||
PW_BROWSER_WORKERS: 8
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
pnpm test:browser
|
||||
- name: upload screenshots
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always() && matrix.suite == 'browser'
|
||||
with:
|
||||
name: playwright-screenshots-SSR-${{ matrix.ssr }}
|
||||
path: |
|
||||
./test-results
|
||||
- name: run reload mode test
|
||||
if: matrix.suite == 'reload'
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
pnpm test:browser:reload
|
||||
- name: upload reload mode screenshots
|
||||
uses: actions/upload-artifact@v4
|
||||
if: always() && matrix.suite == 'reload'
|
||||
with:
|
||||
name: reload-mode-playwright-screenshots
|
||||
path: |
|
||||
./test-results
|
||||
@@ -0,0 +1,33 @@
|
||||
name: "hygiene"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 5.0-dev
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
test:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "hygiene-test"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Generate Skill
|
||||
run: |
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install -e client/python . && python scripts/generate_skill.py --check
|
||||
- name: Check for large files
|
||||
uses: actionsdesk/lfs-warning@4b98a8a5e6c429c23c34eee02d71553bca216425 # @v3.3
|
||||
with:
|
||||
filesizelimit: 5MB
|
||||
exclusionPatterns: ffmpeg-bin/*
|
||||
@@ -0,0 +1,161 @@
|
||||
name: "python"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
HF_TOKEN: ${{ vars.HF_TOKEN }}
|
||||
UV_EXCLUDE_NEWER: 7 days
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
pr_number: ${{ steps.changes.outputs.pr_number }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "gradio"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
build:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "build"
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
id: install_deps
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.10"
|
||||
os: "ubuntu-latest"
|
||||
test: true
|
||||
skip_docs_gen: true
|
||||
- name: Lint
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
./scripts/lint_backend.sh
|
||||
- name: Typecheck
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
./scripts/type_check_backend.sh
|
||||
- name: Build wheel
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
uv pip install build
|
||||
python -m build
|
||||
- name: Build gradio_client wheel
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
cd client/python
|
||||
python -m build
|
||||
- name: Upload gradio wheel
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gradio-wheel
|
||||
path: dist/*.whl
|
||||
- name: Upload gradio_client wheel
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: gradio-client-wheel
|
||||
path: client/python/dist/*.whl
|
||||
test:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "test-${{ matrix.os }}-${{ matrix.test-type == 'flaky' && 'flaky' || 'not-flaky'}}"
|
||||
needs: [changes, build]
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
strategy:
|
||||
matrix:
|
||||
os: ["ubuntu-latest", "windows-latest"]
|
||||
test-type: ["not flaky", "flaky"]
|
||||
exclude:
|
||||
- os: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'windows-tests') && 'dummy' || 'windows-latest' }}
|
||||
- test-type: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'flaky-tests') && 'dummy' || 'flaky' }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download gradio wheel
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: gradio-wheel
|
||||
path: dist/
|
||||
- name: Download gradio_client wheel
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: gradio-client-wheel
|
||||
path: client-dist/
|
||||
- name: install dependencies
|
||||
id: install_deps
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.10"
|
||||
os: ${{ matrix.os }}
|
||||
test: true
|
||||
skip_build: true
|
||||
skip_gradio_install: true
|
||||
skip_docs_gen: true
|
||||
- name: Install gradio_client wheel
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
uv pip install client-dist/*.whl
|
||||
- name: Install gradio wheel
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
uv pip install "$(ls dist/*.whl)[oauth,mcp]"
|
||||
- name: uv pip freeze
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
uv pip freeze
|
||||
- name: Generate .pyi files
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
python -c "import gradio"
|
||||
- name: Copy wheels for docker tests
|
||||
shell: bash
|
||||
run: |
|
||||
cp dist/*.whl test/test_docker/
|
||||
cp client-dist/*.whl test/test_docker/
|
||||
- name: Remove local gradio source to use installed wheel
|
||||
shell: bash
|
||||
run: |
|
||||
find gradio -name "__init__.py" -delete
|
||||
- name: Run parallel tests
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
python -m pytest -n auto -m "${{ matrix.test-type }} and not serial"
|
||||
- name: Run non-flaky serial tests
|
||||
if: matrix.test-type == 'not flaky'
|
||||
shell: bash
|
||||
run: |
|
||||
. ${{steps.install_deps.outputs.venv_activate}}
|
||||
python -m pytest -m "${{ matrix.test-type }} and serial"
|
||||
@@ -0,0 +1,72 @@
|
||||
name: "js"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 5.0-dev
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
pr_number: ${{ steps.changes.outputs.pr_number }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "js"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
test:
|
||||
permissions:
|
||||
contents: read
|
||||
name: js-test
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-frontend-deps@main"
|
||||
with:
|
||||
skip_build: true
|
||||
- name: cache playwright browsers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
playwright-${{ runner.os }}-
|
||||
- name: install playwright
|
||||
timeout-minutes: 3
|
||||
run: pnpm exec playwright install chromium --only-shell
|
||||
- name: format check
|
||||
run: pnpm format:check
|
||||
- name: lint
|
||||
run: pnpm lint
|
||||
- name: typecheck
|
||||
run: pnpm ts:check
|
||||
- name: unit tests
|
||||
run: pnpm test:run
|
||||
- name: client tests
|
||||
run: pnpm --filter @gradio/client test
|
||||
@@ -0,0 +1,17 @@
|
||||
name: trigger-changeset
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
|
||||
branches:
|
||||
- main
|
||||
issue_comment:
|
||||
types: [edited]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changeset:
|
||||
runs-on: ubuntu-22.04
|
||||
if: github.event.sender.login != 'gradio-pr-bot'
|
||||
steps:
|
||||
- run: echo "Requesting changeset"
|
||||
@@ -0,0 +1,29 @@
|
||||
name: trigger-semgrep
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- 5.0-dev
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
pr_number: ${{ steps.changes.outputs.pr_number }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
source_repo: ${{ steps.changes.outputs.source_repo }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "gradio"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,68 @@
|
||||
name: "update-checks"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["python", "js", "functional", "generate-changeset"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.id}}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
update-status:
|
||||
permissions:
|
||||
actions: read
|
||||
statuses: write
|
||||
contents: read
|
||||
environment: commit_status
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: ${{ needs.changes.outputs.should_run == 'false'}}
|
||||
steps:
|
||||
- name: set js check name
|
||||
if: github.event.workflow_run.name == 'js'
|
||||
run: echo "CHECK_NAME=js / js-test (pull_request)" >> $GITHUB_ENV
|
||||
- name: set python check name
|
||||
if: github.event.workflow_run.name == 'python'
|
||||
run: echo "CHECK_NAME=test-ubuntu-latest-not-flaky" >> $GITHUB_ENV
|
||||
- name: set functional check name
|
||||
if: github.event.workflow_run.name == 'functional'
|
||||
run: echo "CHECK_NAME=functional / functional-test (pull_request)" >> $GITHUB_ENV
|
||||
- name: set changeset approval status
|
||||
if: github.event.workflow_run.name == 'generate-changeset'
|
||||
run: echo "CHECK_NAME=changeset-approval (pull_request)" >> $GITHUB_ENV
|
||||
- name: update status
|
||||
uses: gradio-app/github/actions/set-commit-status@main
|
||||
with:
|
||||
sha: ${{ needs.changes.outputs.sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: ${{ env.CHECK_NAME }}
|
||||
run_id: ${{ needs.changes.outputs.run_id }}
|
||||
@@ -0,0 +1,103 @@
|
||||
name: "website-build"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["docs-deploy"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
path: output.json
|
||||
name: changes
|
||||
build:
|
||||
environment: build_website
|
||||
name: "website-build"
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || (endsWith(needs.changes.outputs.source_branch, 'main') && github.repository == 'gradio-app/gradio')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.changes.outputs.source_branch }}
|
||||
repository: ${{ needs.changes.outputs.source_repo }}
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
skip_build: true
|
||||
python_version: "3.10"
|
||||
- name: build client
|
||||
run: pnpm --filter @gradio/client build
|
||||
|
||||
- name: build packages
|
||||
run: pnpm package
|
||||
|
||||
- name: build website
|
||||
run: VERCEL=1 pnpm --filter website build
|
||||
|
||||
- name: find
|
||||
run: find . -type d
|
||||
|
||||
- name: Install Hub Client Library and docs.json Requirements
|
||||
run: |
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
pip install huggingface-hub==0.28.1 html2text beautifulsoup4
|
||||
|
||||
- name: Get docs.json Upload Script
|
||||
run: |
|
||||
mkdir -p scripts
|
||||
curl https://raw.githubusercontent.com/gradio-app/gradio/main/scripts/upload_docs_json.py -o scripts/upload_docs_json.py
|
||||
|
||||
- name: Upload docs.json to HF dataset
|
||||
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'refs/heads/main'
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_DOCS_TOKEN }}
|
||||
run: |
|
||||
. venv/bin/activate
|
||||
python scripts/upload_docs_json.py
|
||||
- name: upload website artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: website
|
||||
path: |
|
||||
js/_website/build
|
||||
js/_website/wrangler.jsonc
|
||||
js/_website/worker
|
||||
include-hidden-files: true
|
||||
- name: upload functions artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: functions
|
||||
path: js/_website/functions
|
||||
include-hidden-files: true
|
||||
@@ -0,0 +1,106 @@
|
||||
name: "website-deploy"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["website-build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
comment-deploy-start:
|
||||
needs: changes
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: website~pending~null
|
||||
deploy:
|
||||
environment: deploy_website
|
||||
name: "website-deploy"
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || (endsWith(needs.changes.outputs.source_branch, 'main') && github.repository == 'gradio-app/gradio')
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
cloudflare_url: ${{ steps.cloudflare-preview.outputs.deployment-url }}
|
||||
steps:
|
||||
- name: download website artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: website
|
||||
path: js/_website
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# preview
|
||||
- name: Deploy Preview Worker to Cloudflare
|
||||
if: needs.changes.outputs.pr_number != 'false'
|
||||
id: cloudflare-preview
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
workingDirectory: js/_website
|
||||
wranglerVersion: "4"
|
||||
command: versions upload
|
||||
|
||||
# production
|
||||
- name: Deploy Production Worker to Cloudflare
|
||||
if: needs.changes.outputs.source_repo == 'gradio-app/gradio' && needs.changes.outputs.source_branch == 'refs/heads/main'
|
||||
id: cloudflare-production
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
workingDirectory: js/_website
|
||||
wranglerVersion: "4"
|
||||
command: deploy
|
||||
|
||||
comment-deploy-success:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: needs.deploy.result == 'success' && needs.changes.outputs.pr_number != 'false'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: website~success~${{needs.deploy.outputs.cloudflare_url}}
|
||||
comment-deploy-failure:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: always() && needs.deploy.result == 'failure' && needs.changes.outputs.pr_number != 'false'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
@@ -0,0 +1,82 @@
|
||||
name: "docs-build"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
CI: true
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
if: github.event_name == 'pull_request' || github.event_name == 'push'
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_run: ${{ steps.changes.outputs.should_run }}
|
||||
sha: ${{ steps.changes.outputs.sha }}
|
||||
gradio_version: ${{ steps.changes.outputs.gradio_version }}
|
||||
source_branch: ${{ steps.changes.outputs.source_branch }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
||||
id: changes
|
||||
with:
|
||||
filter: "website"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
build:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "docs-build"
|
||||
runs-on: ubuntu-22.04
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || (endsWith(needs.changes.outputs.source_branch, 'main') && github.repository == 'gradio-app/gradio')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install dependencies
|
||||
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
||||
with:
|
||||
python_version: "3.10"
|
||||
skip_build: true
|
||||
test: true
|
||||
|
||||
# generated when installing deps
|
||||
- name: upload website json artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: website-json
|
||||
path: js/_website/src/lib/json
|
||||
- name: upload website json templates
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: website-templates
|
||||
path: js/_website/src/lib/templates
|
||||
- name: build client
|
||||
run: pnpm --filter @gradio/client build
|
||||
- name: build packages
|
||||
run: pnpm package
|
||||
- name: build website
|
||||
run: VERCEL=1 pnpm --filter website build
|
||||
website-build:
|
||||
permissions:
|
||||
contents: read
|
||||
name: "website-build"
|
||||
runs-on: ubuntu-22.04
|
||||
needs: [changes, build]
|
||||
if: needs.changes.outputs.should_run == 'true' || (endsWith(needs.changes.outputs.source_branch, 'main') && github.repository == 'gradio-app/gradio')
|
||||
steps:
|
||||
- name: website build completed
|
||||
run: echo "Website build completed in the docs-build job."
|
||||
@@ -0,0 +1,93 @@
|
||||
name: "docs-deploy"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["docs-build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
if: github.event.workflow_run.conclusion == 'success'
|
||||
name: "changes"
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
outputs:
|
||||
should_run: ${{ steps.json.outputs.should_run }}
|
||||
sha: ${{ steps.json.outputs.sha }}
|
||||
pr_number: ${{ steps.json.outputs.pr_number }}
|
||||
source_branch: ${{ steps.json.outputs.source_branch }}
|
||||
source_repo: ${{ steps.json.outputs.source_repo }}
|
||||
labels: ${{ steps.json.outputs.labels }}
|
||||
run_id: ${{ steps.json.outputs.run_id }}
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: changes
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
- uses: gradio-app/github/actions/json-to-output@main
|
||||
id: json
|
||||
with:
|
||||
path: output.json
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
path: output.json
|
||||
name: changes
|
||||
comment-deploy-start:
|
||||
needs: changes
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
if: needs.changes.outputs.should_run == 'true'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: website~pending~null
|
||||
deploy:
|
||||
environment: deploy_website
|
||||
name: "docs-deploy"
|
||||
runs-on: ubuntu-latest
|
||||
needs: changes
|
||||
if: needs.changes.outputs.should_run == 'true' || github.event.workflow_run.event == 'push'
|
||||
permissions:
|
||||
actions: read
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: website-json
|
||||
path: js/_website/lib/json
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: website-templates
|
||||
path: js/_website/lib/templates
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: deploy json to aws
|
||||
if: startsWith(needs.changes.outputs.source_branch, 'changeset-release/') && needs.changes.outputs.source_repo == 'gradio-app/gradio'
|
||||
run: |
|
||||
export AWS_ACCESS_KEY_ID=${{ secrets.DOCS_JSON_AWS_S3_ACCESS_KEY }}
|
||||
export AWS_SECRET_ACCESS_KEY=${{ secrets.DOCS_JSON_AWS_S3_SECRET_ACCESS_KEY }}
|
||||
export AWS_DEFAULT_REGION=us-west-2
|
||||
version=$(jq -r .version js/_website/lib/json/version.json)
|
||||
aws s3 cp ./js/_website/lib/json/ s3://gradio-docs-json/$version/ --recursive
|
||||
aws s3 cp ./js/_website/lib/templates/ s3://gradio-docs-json/$version/templates/ --recursive
|
||||
comment-deploy-failure:
|
||||
uses: "./.github/workflows/comment-queue.yml"
|
||||
needs: [deploy, changes]
|
||||
if: always() && needs.deploy.result == 'failure' && needs.changes.outputs.pr_number != 'false'
|
||||
secrets:
|
||||
gh_token: ${{ secrets.COMMENT_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ needs.changes.outputs.pr_number }}
|
||||
message: website~failure~https://github.com/gradio-app/gradio/actions/runs/${{github.run_id}}/
|
||||
Reference in New Issue
Block a user