2024-08-05 22:27:26 +08:00
|
|
|
name: "python"
|
2024-02-01 08:46:55 +08:00
|
|
|
|
|
|
|
on:
|
2024-08-05 22:27:26 +08:00
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- 5.0-dev
|
2024-02-01 08:46:55 +08:00
|
|
|
|
|
|
|
concurrency:
|
2024-08-05 22:27:26 +08:00
|
|
|
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
|
2024-02-01 08:46:55 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
env:
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
2024-08-05 22:27:26 +08:00
|
|
|
HF_TOKEN: ${{ vars.HF_TOKEN }}
|
2024-02-01 08:46:55 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
changes:
|
|
|
|
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:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 18:34:22 +08:00
|
|
|
- uses: "gradio-app/gradio/.github/actions/changes@main"
|
2024-02-01 08:46:55 +08:00
|
|
|
id: changes
|
|
|
|
with:
|
2024-08-05 22:27:26 +08:00
|
|
|
filter: "gradio"
|
2024-02-01 08:46:55 +08:00
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-05 22:27:26 +08:00
|
|
|
test:
|
2024-02-01 08:46:55 +08:00
|
|
|
name: "test-python-${{ matrix.os }}-${{ matrix.test-type == 'flaky' && 'flaky' || 'not-flaky'}}"
|
2024-08-05 22:27:26 +08:00
|
|
|
needs: changes
|
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
2024-02-01 08:46:55 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: ["ubuntu-latest", "windows-latest"]
|
|
|
|
test-type: ["not flaky", "flaky"]
|
|
|
|
exclude:
|
2024-08-05 22:27:26 +08:00
|
|
|
- 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' }}
|
2024-02-01 08:46:55 +08:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
continue-on-error: true
|
|
|
|
steps:
|
2024-08-05 22:27:26 +08:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: install dependencies
|
|
|
|
id: install_deps
|
|
|
|
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
|
|
|
with:
|
|
|
|
python_version: "3.8"
|
|
|
|
os: ${{ matrix.os }}
|
|
|
|
test: true
|
|
|
|
- name: Lint
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
./scripts/lint_backend.sh
|
|
|
|
- name: Typecheck
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
./scripts/type_check_backend.sh
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
. ${{steps.install_deps.outputs.venv_activate}}
|
|
|
|
python -m pytest -m "${{ matrix.test-type }}"
|