---
name: Run pylint

defaults:
  run:
    # To load bashrc
    shell: bash -ieo pipefail {0}

on:
  pull_request:
    branches: [master, dev]
    paths:
      - "**/*.py"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: Lint Code Base
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          # Full git history is needed to get a proper list of changed files within `super-linter`
          fetch-depth: 0

      - name: Set up Python 3.8
        uses: actions/setup-python@v5
        with:
          python-version: 3.8

      - name: Install dependencies
        run: |
          mkdir -p .github/linters
          cp pyproject.toml .github/linters

      - name: Register pylint problem matcher
        run: |
          echo "::add-matcher::.github/workflows/matchers/pylint.json"

      - name: Pylint
        uses: super-linter/super-linter/slim@v6.1.1
        if: always()
        env:
          # Run linters only on new files for pylint to speed up the CI
          VALIDATE_ALL_CODEBASE: false
          # Compare against the base branch
          # This is only accessible on PR
          DEFAULT_BRANCH: ${{ github.base_ref }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Run only pylint
          VALIDATE_PYTHON: true
          VALIDATE_PYTHON_PYLINT: true
          PYTHON_PYLINT_CONFIG_FILE: pyproject.toml
          FILTER_REGEX_EXCLUDE: .*tests/.*.(json|zip|sol)