gradio/.github/workflows/backend.yml

98 lines
2.7 KiB
YAML
Raw Normal View History

name: gradio-backend
on:
push:
branches:
- "main"
pull_request:
concurrency:
group: backend-${{ github.ref }}-${{ github.event_name == 'push' || github.event.inputs.fire != null }}
cancel-in-progress: false
env:
NODE_OPTIONS: "--max-old-space-size=4096"
jobs:
test:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
test-type: ["not flaky", "flaky"]
python-version: ["3.9", "3.7"]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.test-type == 'flaky' }}
steps:
- uses: actions/checkout@v3
- name: Cache python deps
id: cache-python
uses: actions/cache@v3
with:
path: ./venv
key: pythondeps-${{ matrix.python-version }}-${{ github.ref }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install pip
run: python -m pip install build requests virtualenv
- name: venv activate Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m virtualenv venv
source venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: venv activate Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m virtualenv venv
./venv/Scripts/Activate.ps1
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Gradio
shell: bash
run: |
bash scripts/install_gradio.sh
pip install --upgrade pip
- name: Install 3.9 Test Dependencies
shell: bash
if: ${{ matrix.python-version == '3.9' }}
run: |
pip install -r test/requirements.txt
- name: Install 3.7 Test Dependencies
shell: bash
if: ${{ matrix.python-version == '3.7' }}
run: |
pip install -r test/requirements-37.txt
- name: Lint
shell: bash
run: |
bash scripts/lint_backend.sh
- name: Typecheck
shell: bash
run: |
bash scripts/type_check_backend.sh
- name: Build frontend
shell: bash
run: |
pnpm i --frozen-lockfile
pnpm build
- name: Install ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Create coverage dir
run: mkdir test-reports
- name: Run tests
shell: bash
run: |
coverage run -m pytest -m "${{ matrix.test-type }}"
coverage xml
2023-03-08 10:04:58 +08:00