image: gitlab.kwant-project.org:5005/qt/adaptive-paper

stages:
  - build-env
  - test

## Building Docker environments
## Only runs when docker specifications change

.build-env: &build-env
  stage: build-env
  only:
    changes:
      - Dockerfile
      - environment.yml
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  artifacts:
    untracked: true
    expire_in: 1 hour
  before_script:
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json

build-env:ubuntu: &build-docker
  <<: *build-env
  only:
    changes:
      - Dockerfile
      - environment.yml
  script:
    - /kaniko/executor
      --context $CI_PROJECT_DIR
      --dockerfile $CI_PROJECT_DIR/Dockerfile
      --destination $CI_REGISTRY_IMAGE


## Test Jobs

make:
  stage: test
  script:
    - source activate revtex-markdown-paper && make
  artifacts:
    paths:
      - paper.pdf
