2024-02-01 08:46:55 +08:00
|
|
|
name: "test / python"
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["trigger"]
|
|
|
|
types:
|
|
|
|
- requested
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
statuses: write
|
|
|
|
|
|
|
|
concurrency:
|
2024-02-01 18:24:15 +08:00
|
|
|
group: "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
|
2024-02-01 08:46:55 +08:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
env:
|
|
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
|
|
|
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
changes:
|
|
|
|
name: "changes"
|
|
|
|
runs-on: ubuntu-latest
|
2024-02-01 20:56:35 +08:00
|
|
|
continue-on-error: true
|
2024-02-01 08:46:55 +08:00
|
|
|
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 }}
|
|
|
|
merge_sha: ${{ steps.changes.outputs.merge_sha }}
|
2024-02-01 09:06:39 +08:00
|
|
|
labels: ${{ steps.changes.outputs.labels }}
|
2024-02-01 21:15:15 +08:00
|
|
|
mergeable: ${{ steps.changes.outputs.mergeable }}
|
2024-02-01 08:46:55 +08:00
|
|
|
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:
|
|
|
|
type: "gradio"
|
|
|
|
name: "test / python / linux"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
test-python:
|
|
|
|
needs: [changes]
|
|
|
|
if: needs.changes.outputs.should_run == 'true'
|
|
|
|
name: "test-python-${{ matrix.os }}-${{ matrix.test-type == 'flaky' && 'flaky' || 'not-flaky'}}"
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: ["ubuntu-latest", "windows-latest"]
|
|
|
|
test-type: ["not flaky", "flaky"]
|
|
|
|
exclude:
|
2024-02-01 09:06:39 +08:00
|
|
|
- os: ${{ github.event.workflow_run.event == 'pull_request' && contains( needs.changes.outputs.labels, 'windows-tests') && 'dummy' || 'windows-latest' }}
|
|
|
|
- test-type: ${{ github.event.workflow_run.event == 'pull_request' && contains( needs.changes.outputs.labels, 'flaky-tests') && 'dummy' || 'flaky' }}
|
2024-02-01 08:46:55 +08:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
continue-on-error: true
|
|
|
|
steps:
|
2024-02-02 02:14:41 +08:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
ref: ${{ needs.changes.outputs.merge_sha }}
|
2024-02-01 21:15:15 +08:00
|
|
|
repository: ${{ needs.changes.outputs.mergeable == 'true' && github.repository || needs.changes.outputs.source_repo }}
|
2024-02-01 08:46:55 +08:00
|
|
|
- name: install dependencies
|
|
|
|
id: install_deps
|
2024-02-01 18:34:22 +08:00
|
|
|
uses: "gradio-app/gradio/.github/actions/install-all-deps@main"
|
2024-02-01 08:46:55 +08:00
|
|
|
with:
|
|
|
|
python_version: "3.8"
|
|
|
|
os: ${{ matrix.os }}
|
|
|
|
test: true
|
|
|
|
- name: Lint
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
bash scripts/lint_backend.sh
|
|
|
|
- name: Typecheck
|
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
|
|
|
. venv/bin/activate
|
|
|
|
bash scripts/type_check_backend.sh
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
. ${{steps.install_deps.outputs.venv_activate}}
|
|
|
|
python -m pytest -m "${{ matrix.test-type }}"
|
|
|
|
- name: do check
|
|
|
|
if: always()
|
|
|
|
uses: "gradio-app/github/actions/commit-status@main"
|
|
|
|
with:
|
|
|
|
type: "gradio"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
pr: ${{ needs.changes.outputs.pr_number }}
|
|
|
|
sha: ${{ needs.changes.outputs.sha }}
|
|
|
|
name: "test / python / ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'windows'}}"
|
|
|
|
result: ${{ job.status }}
|
|
|
|
job_id: "test-python-${{ matrix.os }}-${{ matrix.test-type == 'flaky' && 'flaky' || 'not-flaky'}}"
|
|
|
|
|