# Maintainer: Oskari Pirhonen <xxc3ncoredxx@gmail.com>

image: ubuntu/jammy
shell: true
repositories:
  # For more versions than just the default python3
  deadsnakes: https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy main "BA6932366A755776"
environment:
  PYTHON_VERSIONS:
    - '3.9'
    - '3.10'
    - '3.11'
tasks:
  - setup-python: |
      portage/.builds/setup-python.sh "${PYTHON_VERSIONS[@]}"

  - setup-black: |
      .venv/bin/pip install black

  - setup-pylint: |
      for py in "${PYTHON_VERSIONS[@]}"; do
        ".venv-$py/bin/pip" install pylint pytest
      done

  - black: |
      source .venv/bin/activate
      cd portage
      STRAGGLERS="$(find bin -type f -not -name '*.py' -not -name '*.sh' | \
          xargs grep -l '#!/usr/bin/env python' | \
          tr '\n' ' ')"
      time black --check --diff --color . $STRAGGLERS
      deactivate

  - pylint: |
      for py in "${PYTHON_VERSIONS[@]}"; do
        source ".venv-$py/bin/activate"
        pushd portage
          time ./run-pylint
        popd
        deactivate
      done
