pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    when:
      event: pull_request
    restore: true
    mount:
      - ./pip-cache
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  test:
    image: registry.online.ntnu.no/dotkom/onlineweb4-testbase
    when:
      event: pull_request
    commands:
      - cp onlineweb4/settings/example-local.py onlineweb4/settings/local.py
      - npm install --depth=0 --quiet
      - pip install -r requirements.txt -r requirements-testing.txt --quiet --cache-dir pip-cache
      - npm run build:prod
      - npm run lint
      - isort -c -rc apps middleware scripts utils
      - flake8 apps middleware scripts utils
      - py.test --cov=apps
      - pip install codecov --quiet
      - codecov

  rebuild-cache:
    image: drillster/drone-volume-cache
    when:
      event: pull_request
    rebuild: true
    mount:
      - ./pip-cache
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  deploy:
    image: appleboy/drone-ssh
    secrets: [ssh_key]
    host: nansen.online.ntnu.no
    port: 22
    username: root
    key: ${SSH_KEY}
    when:
      event: push
      branch: develop
    script:
      - /srv/www/ow4dev/deploy.sh

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    when:
      event: pull_request
    restore: true
    mount:
      - ./pip-cache
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  test:
    image: registry.online.ntnu.no/dotkom/onlineweb4-testbase
    when:
      event: pull_request
    commands:
      - cp onlineweb4/settings/example-local.py onlineweb4/settings/local.py
      - npm install --depth=0 --quiet
      - pip install -r requirements.txt -r requirements-testing.txt --quiet --cache-dir pip-cache
      - npm run build:prod
      - npm run lint
      - isort -c -rc apps middleware scripts utils
      - flake8 apps middleware scripts utils
      - py.test --cov=apps
      - pip install codecov --quiet
      - codecov

  rebuild-cache:
    image: drillster/drone-volume-cache
    when:
      event: pull_request
    rebuild: true
    mount:
      - ./pip-cache
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

  deploy:
    image: appleboy/drone-ssh
    pull: true
    secrets: [ssh_key]
    host: nansen.online.ntnu.no
    port: 22
    username: root
    key: ${SSH_KEY}
    command_timeout: 600
    when:
      event: push
      branch: develop
    script:
      - /srv/www/ow4dev/deploy.sh

Increase command timeout to allow for webpack to build
Increase command timeout to allow for webpack to build
