name: Lint Code

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install ruff pre-commit-hooks

      - name: Run pre-commit hooks
        run: |
          pip install pre-commit
          pre-commit run --all-files trailing-whitespace
          pre-commit run --all-files end-of-file-fixer
          pre-commit run --all-files check-yaml

      - name: Run Ruff checks
        run: |
          ruff check tts/ --fix
          ruff format tts/
