name: Lint

on:
  push:
    paths:
      - "**.py"
      - "**.pyi"
      - ".github/workflows/lint.yml"
  pull_request:
    branches:
      - main

jobs:
  lint:
    runs-on: ubuntu-latest
    name: Lint Code

    steps:
      - name: Checkout ๐Ÿ›Ž๏ธ
        uses: actions/checkout@v3

      - name: Setup Python ๐Ÿ
        uses: actions/setup-python@v3.1.2
        with:
          python-version: 3.8.5

      - uses: Gr1N/setup-poetry@v7

      - uses: actions/cache@v3.0.2
        with:
          path: ~/.cache/pypoetry
          key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

      - name: Install Dependencies ๐Ÿ”ง
        env:
          POETRY_VIRTUALENVS_CREATE: "true"
        run: |
          poetry install
          python -m pip install --upgrade pip
          pip install black
          
      - name: Run Linters
        uses: wearerequired/lint-action@v2.0.0
        with:
          auto_fix: true
          black: true
          black_auto_fix: true
          commit_message: ":rotating_light: ่‡ชๅŠจ่ฟ›่กŒไปฃ็ ๆ ผๅผๅŒ–"
          git_email: noreply@github.com