image: irmb/virtualfluids-python-deps

stages:
  - build
  - test
  - release

build:
  stage: build

  cache:
    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
    paths:
      - _skbuild

  artifacts:
    paths:
      - _skbuild/
      - Python/venv

  before_script:
    - python3 -m venv --system-site-packages Python/venv
    - source Python/venv/bin/activate

  script:
    - python3 setup.py install


virtual_fluids_basics_test:
  stage: test

  before_script:
    - export VF_UNITTESTS=$(find _skbuild -name basicsTests)

  script:
    - $VF_UNITTESTS


test_python_bindings:
  stage: test

  artifacts:
    when: on_failure
    paths:
      - output/mq/mq10000/

  before_script:
    - export PYTHONPATH="Python"
    - source Python/venv/bin/activate

  script:
    - python3 -m unittest discover -s Python -v


create_release:
  stage: release
  rules:
    - if: $CI_COMMIT_TAG

  script:
    - echo "Creating release with tag $CI_COMMIT_TAG"

  release:
    tag_name: $CI_COMMIT_TAG
    name: "VirtualFluids $CI_COMMIT_TAG"
    description: "VirtualFluids CFD Simulator"