gradio/.github/workflows/test-python.yml
Abubakar Abid 981731acb7
Fix flaky tests and tests on Windows (#9059)
* fixes

* fix external tests

* lint

* add changeset

* comment

* fix client

* add changeset

* run on pull request label changes

* lint

* file explorer

* format

* format

* fix windows

* changes

* test

* format backend

* fix

* fix test

* fix tests

* fix

* rate limit

* fix

* trigger

* fix flakiness

* test

* reruns

* reqs

* fix functional tests

* fix test

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-08-08 01:41:16 -07:00

79 lines
2.4 KiB
YAML

name: "python"
on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
push:
branches:
- main
- 5.0-dev
concurrency:
group: "${{ github.event.pull_request.number }}-${{ github.ref_name }}-${{ github.workflow }}"
cancel-in-progress: true
env:
NODE_OPTIONS: "--max-old-space-size=4096"
HF_TOKEN: ${{ vars.HF_TOKEN }}
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 }}
test:
permissions:
contents: read
name: "test-${{ matrix.os }}-${{ matrix.test-type == 'flaky' && 'flaky' || 'not-flaky'}}"
needs: changes
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: 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 }}"