name: ruff

on:
  push:
    paths:
      - '.github/workflows/ruff.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.11", "3.12", "3.13"]

    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 ruff
        python3 -m pip install lxml py-ecc monero eth-keys
        python3 setup.py build_ext --inplace

    - name: Check the code with Ruff static code analyzer
      env:
        PYTHONPATH: .
      run: |
        ruff check --output-format=github mmgen
        ruff check --output-format=github test
