name: Actions

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: 📥 Checkout the repository
        uses: actions/checkout@v4.1.7

      - name: 🛠 Set up Python 3
        uses: actions/setup-python@v5
        id: python
        with:
          python-version: 3.x

      - name: 📦 Install dependencies
        run:  make requirements

      - name: 🖤 Lint with Black
        run:  make black-check

      - name: 🐍 Lint with mypy
        run: make mypy

      - name: ✨ Lint with pylint
        run: make pylint

      - name: 🔤 Lint with isort
        run: make isort-check

  test:
    name: Test with Python ${{ matrix.entry.version }}
    needs: lint
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        entry: 
          - version: "3.8"
          - version: "3.9"
          - version: "3.10"
          - version: "3.11"
          - version: "3.12"
            prereleases: true
    steps:
      - name: 📥 Checkout the repository
        uses: actions/checkout@v4.1.7

      - name: 🛠️ Set up Python ${{ matrix.entry.version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.entry.version }}
          allow-prereleases: ${{ matrix.entry.prereleases || false }}

      - name: 📦 Install dependencies
        run: make requirements

      - name: 🏃 Run tests
        run: make test

      - name: 🛠 Build
        run: make build

  coverage:
    name: Upload coverage to Codecov
    needs: test
    runs-on: ubuntu-latest
    steps:
      - name: 📥 Checkout the repository
        uses: actions/checkout@v4.1.7
        with:
          fetch-depth: 0

      - name: 🛠️ Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: 3.x

      - name: 📦 Install dependencies
        run:  make requirements

      - name: 📤 Upload coverage to Codecov
        run: |
          make coverage
          curl -sfSL https://codecov.io/bash | bash -