name: Code checker

on:
  push:
  pull_request:
  schedule:
    - cron: "0 4 * * *"

jobs:
  validate:
    runs-on: "ubuntu-latest"
    strategy:
      matrix:
        python-version:
          - "3.12"
          - "3.13"
    env:
      SRC_FOLDER: tibber
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'

      - name: Install dependency
        run: |
            pip install -r requirements.txt
            pip install mypy pre-commit pytest pytest-asyncio pytest-cov ruff
      - uses: actions/cache@v5
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
      - name: Run pre-commit
        run: pre-commit run --all-files --show-diff-on-failure --color=always
        shell: bash
      - name: pytest
        run: |
            pytest
