Comprehensive WebUI #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WebUI Tests | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'simpletuner/simpletuner_sdk/server/**' | |
- 'templates/**' | |
- 'static/**' | |
- 'tests/test_webui_*.py' | |
- 'tests/pages/**' | |
- '.github/workflows/webui-tests.yaml' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'simpletuner/simpletuner_sdk/server/**' | |
- 'templates/**' | |
- 'static/**' | |
- 'tests/test_webui_*.py' | |
- 'tests/pages/**' | |
- '.github/workflows/webui-tests.yaml' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
browser: [chrome, firefox] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install Chrome | |
if: matrix.browser == 'chrome' | |
uses: browser-actions/setup-chrome@latest | |
- name: Install Firefox | |
if: matrix.browser == 'firefox' | |
uses: browser-actions/setup-firefox@latest | |
- name: Install ChromeDriver | |
if: matrix.browser == 'chrome' | |
uses: nanasess/setup-chromedriver@v2 | |
- name: Install GeckoDriver | |
if: matrix.browser == 'firefox' | |
uses: browser-actions/setup-geckodriver@latest | |
with: | |
token: ${{ github.token }} | |
- name: Cache pip packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e .[dev] | |
pip install pytest-xvfb # For headless display | |
- name: Run backend unit tests | |
run: | | |
pytest tests/test_webui_backend.py -v | |
- name: Run API tests | |
run: | | |
pytest tests/test_webui_api.py -v | |
- name: Run E2E tests - ${{ matrix.browser }} | |
env: | |
DISPLAY: ':99.0' | |
run: | | |
# Start Xvfb for headless display | |
Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 & | |
# Run E2E tests for specific browser | |
pytest tests/test_webui_e2e.py -v -m e2e -k ${{ matrix.browser }} | |
test-all-browsers: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: All browser tests completed | |
run: echo "All browser tests completed successfully" | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install linting dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install black flake8 isort | |
- name: Run Black | |
run: | | |
black --check simpletuner/simpletuner_sdk/server/ | |
black --check tests/test_webui_*.py | |
black --check tests/pages/ | |
- name: Run isort | |
run: | | |
isort --check-only simpletuner/simpletuner_sdk/server/ | |
isort --check-only tests/test_webui_*.py | |
isort --check-only tests/pages/ | |
- name: Run flake8 | |
run: | | |
flake8 simpletuner/simpletuner_sdk/server/ --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 tests/test_webui_*.py --count --select=E9,F63,F7,F82 --show-source --statistics | |
flake8 tests/pages/ --count --select=E9,F63,F7,F82 --show-source --statistics |