---

image: "hub.cc-asp.fraunhofer.de/iam-public/ansible-ci:latest"

stages:
  - test
  - build

test_library:
  script:
    - cd library
    - pip install -r test_requirements.txt
    - pytest
  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
  tags:
    - asprunner

build_collection:
  stage: build
  script:
    - cd collection
    - ansible-galaxy collection build
    - 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file *.tar.gz "https://gitlab.cc-asp.fraunhofer.de/api/v4/projects/${CI_PROJECT_ID}/packages/generic/collection/${CI_COMMIT_REF_NAME}/$(ls *.tar.gz)"'
  tags:
    - asprunner