101 lines
2.4 KiB
YAML
101 lines
2.4 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
branches: [main, master]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python-version: ['3.13']
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
cache: 'pip'
|
|
cache-dependency-path: 'requirements_test.txt'
|
|
|
|
- name: Cache pip dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-${{ matrix.python-version }}-
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements_test.txt
|
|
|
|
- name: Run pytest
|
|
run: |
|
|
python -m pytest tests/ -v --tb=short --asyncio-mode=auto
|
|
|
|
- name: Validate manifest
|
|
run: |
|
|
python -c "import json; json.load(open('custom_components/adguard_control_hub/manifest.json'))"
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Cache pip dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-lint-${{ hashFiles('**/requirements*.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-lint-
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install black isort flake8 mypy
|
|
|
|
- name: Run black
|
|
run: |
|
|
black --check --diff custom_components/
|
|
|
|
- name: Run isort
|
|
run: |
|
|
isort --check-only --diff custom_components/
|
|
|
|
- name: Run flake8
|
|
run: |
|
|
flake8 custom_components/ --max-line-length=88 --extend-ignore=E203,W503
|
|
|
|
- name: Run mypy
|
|
run: |
|
|
mypy custom_components/ --ignore-missing-imports
|
|
continue-on-error: true
|
|
|
|
hacs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: HACS validation
|
|
uses: hacs/action@main
|
|
with:
|
|
category: integration |