stages:
  - install
  - test
  - build
  - deploy

install-npm-packages:
  stage: install
  image: iqbberlin/ci-node-chromium:latest
  tags:
    - npm
  script:
    - npm ci --cache .npm  --prefer-offline
  cache:
    key: aspect-npm-packages
    paths:
      - .npm/

test-unit:
  stage: test
  needs:
    - install-npm-packages
  image: iqbberlin/ci-node-chromium:latest
  tags:
    - chromium
  before_script:
    - npm ci --cache .npm --prefer-offline
  script:
    - npm run test
  cache:
    key: aspect-npm-packages
    paths:
      - .npm/

build-packages:
  stage: build
  tags:
    - npm
  image: iqbberlin/ci-node-chromium:latest
  before_script:
    - npm ci --cache .npm --prefer-offline
  script:
    - npm run build-editor
    - npm run build-player
  artifacts:
    paths:
      - dist/verona-editor-aspect-nightly.html
      - dist/verona-player-aspect-nightly.html
    expire_in: 1 week

deploy:
  stage: deploy
  tags:
    - npm
  image: iqbberlin/ci-node-chromium:latest
  script:
    - ./scripts/deploy.sh $TESTSTUDIO_USERNAME $TESTSTUDIO_PASSWORD
  only:
    refs:
      - master
