parameters:
  host: ''
  pool: ''
  sign: false

jobs:
- job: ${{ parameters.host }}
  pool: ${{ parameters.pool }}
  steps:
  - ${{ if eq(parameters.host, 'Windows') }}:
    - script: 'npm install -g esy@latest --unsafe-perm'
      displayName: 'Install esy'
  - ${{ if ne(parameters.host, 'Windows') }}:
    - script: 'sudo npm install -g esy@latest --unsafe-perm'
      displayName: 'Install esy'
  - script: esy install
    displayName: 'Running esy install and esy build'
  - bash: |
      PKG=~/foo/esy-ocaml
      APP=~/foo/test-app
      mkdir -p $PKG
      mkdir -p $APP
      cp -R * $PKG/
      cp -R test-app/* $APP/
  - ${{ if eq(parameters.sign, 'false') }}:
      - bash: |
          cd ~/foo/test-app/
          esy x hello
      
  - ${{ if eq(parameters.sign, 'true') }}:
      - bash: |
          cd ~/foo/test-app/
          C:/npm/prefix/node_modules/esy/_build/default/bin/esy.exe x hello
