image: python:3.10

stages:
  - dependencies
  - lint
  - test
  - deploy

download_dependencies:
  stage: dependencies
  before_script:
    - python -m venv .venv
    - source .venv/bin/activate
  script:
    - pip install -r requirements.txt
  artifacts:
    paths:
      - .venv

pylint:
  stage: lint
  dependencies:
    - download_dependencies
  needs:
    - download_dependencies
  before_script:
    - source .venv/bin/activate
    - pip install pylint
  script:
    - pylint calculator --fail-on=error

pytest:
  stage: test
  dependencies:
    - download_dependencies
  needs:
    - download_dependencies
  before_script:
    - source .venv/bin/activate
  script:
    - pytest calculator

# deploy:
#   stage: deploy
#   needs:
#     - pylint
#     - pytest
#   before_script:
#     - apt-get update
#     - apt-get install -y openssh-client sshpass
#   script:
#     - sshpass -p viazero ssh -o StrictHostKeyChecking=no viazero@<ip-de-ma-vm>
#       "cd /var/www/cicd && git pull && sudo systemctl restart calculator"
