default:
    image: rboman/waves-py3:2022.0
    before_script:
        # Instal pip
        - wget -q https://bootstrap.pypa.io/get-pip.py
        - python3 get-pip.py
        # Install CoDiPack
        - git clone https://github.com/SciCompKL/CoDiPack
        - cd CoDiPack
        - git checkout tags/v2.1.0
        - INCLUDE=${INCLUDE}:${PWD}/include
        - cd ..
        # Install TACS
        # ...
        # Install SDPM
        # TODO change branch, enable CoDiPack
        - wget -q https://gitlab.uliege.be/am-dept/sdpm/-/archive/adri/sdpm-adri.tar.bz2
        - tar xf sdpm-adri.tar.bz2
        - rm sdpm-adri.tar.bz2
        - mv sdpm-adri sdpm
        - cd sdpm
        - mkdir build && cd build
        - cmake -DUSE_CODI=OFF ..
        - make install -j8
        - cd ../..
        # Install PyPK
        # TODO change branch
        - wget -q https://gitlab.uliege.be/am-dept/pypk/-/archive/adri/pypk-adri.tar.bz2
        - tar xf pypk-adri.tar.bz2
        - rm pypk-adri.tar.bz2
        - mv pypk-adri pypk
        - cd pypk
        - python3 -m pip install .
        - cd ..
        # Install OpenMDAO
        - python3 -m pip install 'openmdao<3.35'

.global_tag: &global_tag_def
    tags:
        - mn2l

variables:
    GIT_SUBMODULE_STRATEGY: recursive
    GIT_STRATEGY: clone # workaround full clone for each pipeline (https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26993)
    GIT_LFS_SKIP_SMUDGE: 1 # do not pull LFS

stages:
    - build
    - test

build:
    <<: *global_tag_def
    stage: build
    script:
        - python3 -m pip install .

test:
    <<: *global_tag_def
    stage: test
    script:
        - for f in examples/*.py; do python3 run.py "$f"; done
    dependencies:
        - build
