Move from circleci to gh actions for backend tests (#2927)

* Initial try

* Edit python version

* Do not update

* Trigger failure

* Trigger type check failure

* Undo

* Use cache

* Update cache

* Fix syntax

* Empty

* Activate venv

* indent

* Use python version

* gh action for ffmpeg

* Fix path

* Check fail

* fix failure

* revert fail

* remove cancel in progress
This commit is contained in:
Freddy Boulton 2023-01-18 18:19:39 +01:00 committed by GitHub
parent 625ccae34c
commit 0091b366af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 82 deletions

View File

@ -1,82 +0,0 @@
version: 2.1
orbs:
codecov: codecov/codecov@3.2.2
node: circleci/node@5.0.2
jobs:
test:
parameters:
test-type:
type: string
python-version:
type: string
environment:
NODE_OPTIONS: --max-old-space-size=4096
docker:
- image: cimg/python:<< parameters.python-version >>-browsers
steps:
- checkout
- run: mkdir test-reports
- restore_cache:
key: deps4-{{ .Branch }}-{{ checksum "requirements.txt" }}-<< parameters.python-version >>
- run:
name: Install ffmpeg
command: |
sudo apt update
sudo apt install ffmpeg -y
- run:
name: Upgrade virtual environment tools
command: |
python -m pip install --upgrade pip virtualenv
- run:
name: Install Python deps in a venv
command: |
python -m virtualenv venv
. venv/bin/activate
bash scripts/install_gradio.sh
bash scripts/install_test_requirements.sh
- save_cache:
key: deps4-{{ .Branch }}-{{ checksum "requirements.txt" }}-<< parameters.python-version >>
paths:
- "venv"
- node/install:
node-version: "16"
- run:
name: Build frontend
command: |
npm i pnpm@6 -g
cd ui
pnpm i --frozen-lockfile
pnpm build
- run:
command: |
mkdir screenshots
- run:
command: |
. venv/bin/activate
bash scripts/lint_backend.sh
- run:
command: |
. venv/bin/activate
bash scripts/type_check_backend.sh
- run:
command: |
. venv/bin/activate
coverage run -m pytest -m "<< parameters.test-type >>"
coverage xml
- codecov/upload:
file: "coverage.xml"
- store_artifacts:
path: /home/circleci/project/test/tmp
destination: screenshots
- store_test_results:
path: test-reports/
workflows:
backend:
jobs:
- test:
matrix:
parameters:
test-type: ["not flaky", "flaky"]
python-version: ["3.9.2", "3.7.13"]

82
.github/workflows/backend.yml vendored Normal file
View File

@ -0,0 +1,82 @@
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:
runs-on: ubuntu-latest
strategy:
matrix:
test-type: ["not flaky", "flaky"]
python-version: ["3.9", "3.7"]
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: ui/pnpm-lock.yaml
- name: Install pip
run: python -m pip install build requests virtualenv
- name: Install Gradio + Python Deps
run: |
python -m virtualenv venv
. venv/bin/activate
bash scripts/install_gradio.sh
bash scripts/install_test_requirements.sh
- name: Lint
run: |
. venv/bin/activate
bash scripts/lint_backend.sh
- name: Typecheck
run: |
. venv/bin/activate
bash scripts/type_check_backend.sh
- name: Build frontend
run: |
cd ui
pnpm i --frozen-lockfile
pnpm build
cd ..
- name: Install ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Create coverage dir
run: mkdir test-reports
- name: Run tests
run: |
. venv/bin/activate
coverage run -m pytest -m "${{ matrix.test-type }}"
coverage xml
- uses: codecov/codecov-action@v3
with:
#token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: coverage.xml # optional
#flags: unittests # optional
#name: codecov-umbrella # optional
#fail_ci_if_error: true # optional (default = false)
#verbose: true # optional (default = false)