# Please find the full example project here:
# https://gitlab.com/tobiaskoch/gitlab-ci-example-mono

# see https://hub.docker.com/_/mono/
image: mono:4.6.2.7

stages:
  - build
  - test
  - deploy

before_script:
    - . /opt/mono-4.6/mono-env
    - export GIT_SSL_NO_VERIFY=true 
    - curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh  | bash
    - DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh
    - cd src/OAuth.AspNet.Token && dnu restore --ignore-failed-sources
    - cd ../OAuth.AspNet.AuthServer && dnu restore --ignore-failed-sources
    - cd ../Yavsc.Abstract && dnu restore --ignore-failed-sources
    - cd ../Yavsc.Server && dnu restore --ignore-failed-sources
    - cd ../Yavsc && dnu restore --ignore-failed-sources
    - cd ../cli && dnu restore --ignore-failed-sources
    - cd ../../test/yavscTests && dnu restore --ignore-failed-sources
    - cd ../..

after_script:

debug:
  stage: build
  artifacts:
    paths:
      - test/yavscTests/bin
  script:
    - cd test/yavscTests
    - dnu build

non_reg:
  stage: test
  artifacts:
    paths:
      - test/yavscTests/test-results.xml
    when: always
  script:
    - cd test/yavscTests
    - cp $yavsc_client_secret_json yavsc-client-secret.json
    - ASPNET_ENV=Development dnx test -trait ategory=non_reg -maxthreads 1 -xml test-results.xml 

release:
  stage: deploy
  only:
    - vnext
  artifacts:
    paths:
      - binaries/Debug
  script:
    - make packages

deploy_staging:
  stage: deploy
  script:
    - echo "Deploy to staging server"
    - make strip_yavscd
    - make packages
    - isn push -s $ISNSOURCE -k $NUGETSOURCEAPIKEY src/Yavsc.Abstract/bin/*/*.nupkg
  environment:
    name: staging
    url: https://yavscpre.pschneider.fr
