mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
c9c1514c6e
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
243 lines
8.0 KiB
YAML
243 lines
8.0 KiB
YAML
name: gradio-backend
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, labeled, unlabeled]
|
|
|
|
concurrency:
|
|
group: backend-${{ github.ref }}-${{ github.event_name == 'push' || github.event.inputs.fire != null }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
python-client: ${{ steps.changes.outputs.python-client }}
|
|
gradio: ${{ steps.changes.outputs.gradio }}
|
|
test: ${{ steps.changes.outputs.test }}
|
|
workflows: ${{ steps.changes.outputs.workflows }}
|
|
scripts: ${{ steps.changes.outputs.scripts }}
|
|
client-scripts: ${{ steps.changes.outputs.client-scripts }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: dorny/paths-filter@v2
|
|
id: changes
|
|
with:
|
|
filters: |
|
|
python-client:
|
|
- 'client/python/**'
|
|
- 'gradio/**'
|
|
- 'requirements.txt'
|
|
gradio:
|
|
- 'client/python/**'
|
|
- 'gradio/**'
|
|
- 'requirements.txt'
|
|
test:
|
|
- 'test/**'
|
|
workflows:
|
|
- '.github/**'
|
|
scripts:
|
|
- 'scripts/**'
|
|
client-test:
|
|
needs: [changes]
|
|
if: needs.changes.outputs.python-client == 'true' || needs.changes.outputs.workflows == 'true'
|
|
strategy:
|
|
matrix:
|
|
os: ["ubuntu-latest", "windows-latest"]
|
|
test-type: ["not flaky", "flaky"]
|
|
python-version: ["3.8"]
|
|
exclude:
|
|
- os: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'windows-tests') && 'dummy' || 'windows-latest' }}
|
|
runs-on: ${{ matrix.os }}
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: pip
|
|
cache-dependency-path: |
|
|
client/python/requirements.txt
|
|
requirements.txt
|
|
test/requirements.txt
|
|
- name: Create env
|
|
run: |
|
|
python -m pip install --upgrade virtualenv
|
|
python -m virtualenv venv
|
|
- uses: actions/cache@master
|
|
id: cache
|
|
with:
|
|
path: |
|
|
client/python/venv/*
|
|
key: python-client-${{ runner.os }}-pip-${{ hashFiles('client/python/requirements.txt') }}-${{ hashFiles('client/python/test/requirements.txt') }}
|
|
- uses: actions/cache@v3
|
|
id: frontend-cache
|
|
with:
|
|
path: |
|
|
gradio/templates/*
|
|
key: gradio-lib-front-end-${{ hashFiles('js/**', 'client/js/**')}}
|
|
- name: Install pnpm
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
- uses: actions/setup-node@v4
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
with:
|
|
node-version: 18
|
|
cache: pnpm
|
|
cache-dependency-path: pnpm-lock.yaml
|
|
- name: Build Frontend
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
pnpm i --frozen-lockfile --ignore-scripts
|
|
pnpm build
|
|
- name: Install Test Requirements (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
python -m pip install -r client/python/test/requirements.txt
|
|
- name: Install ffmpeg
|
|
uses: FedericoCarboni/setup-ffmpeg@v2
|
|
- name: Install Gradio and Client Libraries Locally (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
python -m pip install client/python
|
|
python -m pip install ".[oauth]"
|
|
- name: Lint (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
bash client/python/scripts/lint.sh
|
|
- name: Tests (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
python -m pytest -m "${{ matrix.test-type }}" client/python/
|
|
- name: Install Test Requirements (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
pip install -r client/python/test/requirements.txt
|
|
- name: Install Gradio and Client Libraries Locally (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
python -m pip install client/python
|
|
python -m pip install ".[oauth]"
|
|
- name: Tests (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
python -m pytest -m "${{ matrix.test-type }}" client/python/
|
|
test:
|
|
needs: [changes]
|
|
if: needs.changes.outputs.gradio == 'true' || needs.changes.outputs.workflows == 'true' || needs.changes.outputs.scripts == 'true' || needs.changes.outputs.test == 'true'
|
|
strategy:
|
|
matrix:
|
|
os: ["ubuntu-latest", "windows-latest"]
|
|
test-type: ["not flaky", "flaky"]
|
|
python-version: ["3.8"]
|
|
exclude:
|
|
- os: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'windows-tests') && 'dummy' || 'windows-latest' }}
|
|
runs-on: ${{ matrix.os }}
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Install Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: pip
|
|
cache-dependency-path: |
|
|
client/python/requirements.txt
|
|
requirements.txt
|
|
test/requirements.txt
|
|
- name: Create env
|
|
run: |
|
|
python -m pip install --upgrade virtualenv
|
|
python -m virtualenv venv
|
|
- uses: actions/cache@v3
|
|
id: cache
|
|
with:
|
|
path: |
|
|
venv/*
|
|
key: gradio-lib-${{ runner.os }}-pip-${{ hashFiles('client/python/requirements.txt') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}
|
|
- uses: actions/cache@v3
|
|
id: frontend-cache
|
|
with:
|
|
path: |
|
|
gradio/templates/*
|
|
gradio/node/*
|
|
key: gradio-lib-front-end-${{ hashFiles('js/**', 'client/js/**')}}
|
|
- name: Install pnpm
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
- uses: actions/setup-node@v4
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
with:
|
|
node-version: 18
|
|
cache: pnpm
|
|
cache-dependency-path: pnpm-lock.yaml
|
|
- name: Build frontend
|
|
if: steps.frontend-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
pnpm i --frozen-lockfile --ignore-scripts
|
|
pnpm build
|
|
- name: Install Gradio and Client Libraries Locally (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
python -m pip install client/python
|
|
python -m pip install ".[oauth]"
|
|
- name: Install Test Dependencies (Linux)
|
|
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
bash scripts/install_test_requirements.sh
|
|
- name: Install ffmpeg
|
|
uses: FedericoCarboni/setup-ffmpeg@v2
|
|
- name: Lint (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
bash scripts/lint_backend.sh
|
|
- name: Typecheck (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
bash scripts/type_check_backend.sh
|
|
- name: Run tests (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
. venv/bin/activate
|
|
python -m pytest -m "${{ matrix.test-type }}" --ignore=client
|
|
- name: Install Gradio and Client Libraries Locally (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
python -m pip install client/python
|
|
python -m pip install ".[oauth]"
|
|
- name: Install Test Dependencies (Windows)
|
|
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
python -m pip install . -r test/requirements.txt
|
|
- name: Run tests (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
venv\Scripts\activate
|
|
python -m pytest -m "${{ matrix.test-type }}" --ignore=client
|
|
echo "The exit code for pytest was $LASTEXITCODE"
|