Auto-commit from sys76 #48
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: CI | |
| on: | |
| push: | |
| branches: [main, testing] | |
| pull_request: | |
| branches: [main, testing] | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| name: Lint with Ruff | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Cache pip | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff | |
| - name: Run Ruff linter | |
| run: ruff check custom_components/ tests/ scripts/ | |
| - name: Run Ruff formatter check | |
| run: ruff format --check custom_components/ tests/ scripts/ | |
| type-check: | |
| name: Type Check with mypy | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Cache pip | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install mypy homeassistant | |
| - name: Run mypy | |
| run: mypy custom_components/ | |
| test: | |
| name: Test with pytest | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| strategy: | |
| matrix: | |
| python-version: ["3.13", "3.14"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-${{ matrix.python-version }}- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install homeassistant aiohttp voluptuous | |
| pip install pytest pytest-asyncio pytest-homeassistant-custom-component pytest-cov | |
| - name: Run tests with coverage | |
| run: | | |
| pytest tests/ \ | |
| --cov=custom_components \ | |
| --cov-report=xml \ | |
| --cov-report=term-missing \ | |
| -v | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| if: matrix.python-version == '3.13' | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| verify-environment: | |
| name: Verify Development Environment | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: Cache pip | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-verify-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip-verify- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install homeassistant aiohttp voluptuous | |
| pip install pytest pytest-asyncio pytest-homeassistant-custom-component pytest-cov | |
| pip install ruff mypy pre-commit | |
| - name: Run environment verification | |
| run: python scripts/verify_environment.py | |
| all-checks: | |
| name: All Checks Passed | |
| runs-on: ubuntu-latest | |
| needs: [lint, type-check, test, verify-environment] | |
| if: always() | |
| permissions: {} | |
| steps: | |
| - name: Check all job status | |
| run: | | |
| if [[ "${{ needs.lint.result }}" != "success" ]] || \ | |
| [[ "${{ needs.type-check.result }}" != "success" ]] || \ | |
| [[ "${{ needs.test.result }}" != "success" ]] || \ | |
| [[ "${{ needs.verify-environment.result }}" != "success" ]]; then | |
| echo "One or more checks failed" | |
| exit 1 | |
| fi | |
| echo "All checks passed successfully!" |