name: pylint

on:
  push:
    paths:
      - '.github/workflows/pylint.yaml'
      - '.github/build-requirements.txt'
      - 'pyproject.toml'
      - 'setup.cfg'
      - 'test/ref/**'
      - 'cmds/**'
      - '**.py'
      - '**.c'

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        python-version: ["3.9", "3.11", "3.12"]
        include:
          - python-version: "3.9"
            pylint_ver: "3.1.1"
          - python-version: "3.11"
            pylint_ver: "3.1.1"
          - python-version: "3.12"
            pylint_ver: "3.1.1"

    steps:
    - uses: actions/checkout@v4

    - name: Install Ubuntu package dependencies
      run: |
        sudo apt-get install libsecp256k1-dev

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
        cache: 'pip'
        cache-dependency-path: |
          .github/build-requirements.txt
          setup.cfg

    - name: Install Python dependencies
      run: |
        python3 -m pip install pip setuptools build wheel
        python3 -m pip install gmpy2 cryptography pynacl ecdsa aiohttp requests pexpect scrypt semantic-version
        python3 -m pip install pycryptodomex pysocks pycoin ipaddress varint pylint==${{ matrix.pylint_ver }}
        python3 -m pip install --no-deps py_ecc==1.6.0 mypy_extensions==0.4.1 monero
        python3 setup.py build_ext --inplace

    - name: Check the code with Pylint static code analyzer
      env:
        PYTHONPATH: .
      run: |
        pylint --errors-only --jobs=0 mmgen
        pylint --errors-only --jobs=0 test
        pylint --errors-only --jobs=0 examples
        pylint --errors-only --jobs=0 --disable=relative-beyond-top-level test/cmdtest_py_d