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


build_singularity_image:
  stage: build

  artifacts:
    paths:
      - Containers/VirtualFluidsOpenMPI.sif

  script:
    - singularity build Containers/VirtualFluidsOpenMPI.sif Containers/VirtualFluidsOpenMPI.def


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:
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  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"
