name: CI

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]

jobs:
  test:
    name: Test on Python ${{ matrix.python-version }}
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

    steps:
      - name: Checkout code
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4

      - name: Setup Python ${{ matrix.python-version }}
        uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip "setuptools>=83.0.0"
          python -m pip install requests pylint isort pip-audit
          python -m pip install -e .

      - name: Lint with Pylint
        run: |
          pylint mercadopago
          pylint --rcfile=tests/.pylintrc tests

      - name: Lint with isort
        run: isort --check-only .

      - name: Run unit tests
        run: python -m unittest discover tests/

      - name: Dependency audit
        run: pip-audit

      - name: Dependency review
        if: github.event_name == 'pull_request'
        uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v4
        with:
          fail-on-severity: high
