kind: pipeline
type: kubernetes
name: test
global-variables:
  python_image: &python_image python:3.9-alpine
  environment: &default_environment
    ACTRL_DEBUG: 1
    ACTRL_API_EMAIL:
      from_secret: ACTRL_API_EMAIL
    ACTRL_API_TOKEN:
      from_secret: ACTRL_API_TOKEN
    ACTRL_ZENDESK_SUBDOMAIN:
      from_secret: ACTRL_ZENDESK_SUBDOMAIN
    ACTRL_SECRET_KEY:
      from_secret: ACTRL_SECRET_KEY
    BUF_GROUP:
      from_secret: BUF_GROUP
    EMPL_GROUP:
      from_secret: EMPL_GROUP
    ENG_CROLE_ID:
      from_secret: ENG_CROLE_ID
    LA_CROLE_ID:
      from_secret: LA_CROLE_ID
    LICENSE_NO:
      from_secret: LICENSE_NO
    SHIFTH:
      from_secret: SHIFTH
    ST_EMAIL:
      from_secret: ST_EMAIL

steps:
  - name: django_test
    image: *python_image
    environment:
      <<: *default_environment
    commands:
      - pip install -r requirements/dev.txt
      - python manage.py test
  - name: coverage
    image: *python_image
    environment:
      <<: *default_environment
    commands:
      - pip install -r requirements/dev.txt
      - coverage run
      - coverage report -m
      - coverage html -d public/coverage
  - name: upload_artifacts
    image: plugins/s3
    settings:
      source: public/**/*
      enpoint:
        from_secret: S3_ENDPOINT
      bucket: drone
      target: /target/location/${DRONE_BUILD_NUMBER}
      access_key:
        from_secret: S3_ACCESS_KEY
      secret_key:
        from_secret: S3_SECRET_KEY
