---
version: 2
executorType: machine
containerInfo:
  - image: node:4.5.0
stages:
  build:
    workDir: ~/node-nfsc
    steps:
      - type: checkout
      - type: shell
        name: dependencies
        command: |
          sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
          sudo apt-get update
          sudo apt-get install -y gcc-4.9 g++-4.9 \
                                  krb5-multidev libkrb5-dev \
                                  rpcbind flex
      - type: shell
        name: install NFSd
        command: |
          git clone git@github.com:nfs-ganesha/nfs-ganesha.git -b V2.4.3
          ( cd nfs-ganesha && git submodule update --init )
          mkdir nfs-ganesha/build
          ( cd nfs-ganesha/build && cmake  ../src )
          make -C nfs-ganesha/build -j 5
          sudo make -C nfs-ganesha/build install
      - type: shell
        name: spawn NFSd
        command: |
          sudo cp -f tests/ganesha.conf.ci /etc/ganesha/ganesha.conf
          sudo mkdir -p /artifacts /nfs /var/lib/nfs/ganesha/v4old/node0
          sudo chown $(id -un):$(id -gn) /nfs
          sudo ganesha.nfsd -N DEBUG -L /artifacts/ganesha.log
      - type: shell
        name: compile
        environment:
          CC: gcc-4.9
          CXX: g++-4.9
        command: |
          npm install
      - type: shell
        name: configure test
        command: |
          cp tests/config.json.ci tests/config.json
      - type: shell
        name: run tests
        command: |
          npm test
      - type: artifacts-store
        path: /artifacts
        destination: artifacts
