version: 2
jobs:
  build:
    docker: # run the steps with Docker
      - image: circleci/node:10.15.0
    steps:
      - checkout
      - run:
          name: install-softhsm
          command: |
            # Installing SoftHSM dependencies
            sudo apt-get update -qq
            sudo apt-get install libssl-dev
            sudo apt-get install autoconf -y
            sudo apt-get install automake -y
            sudo apt-get install libtool -y
            
            # Installing SoftHSM
            git clone https://github.com/opendnssec/SoftHSMv2.git -b develop
            cd SoftHSMv2
            sh ./autogen.sh
            ./configure
            make
            sudo -E make install
            cd ..
            sudo ldconfig

            # initializing SoftHSM
            softhsm2-util --init-token --so-pin "12345" --pin "12345" --slot 0 --label "My slot 0"
      - run:
          name: update-npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache: # special step to restore the dependency cache 
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install-deps
          command: npm install
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: # run tests with code coverage
          name: test-code-coverage
          command: npm run coverage
      - run: # run coveralls report
          name: test-report-coveralls
          command: npm run coveralls

version: 2
jobs:
  build:
    docker: # run the steps with Docker
      - image: circleci/node:10.15.0
    steps:
      - checkout
      - run:
          name: install-softhsm
          command: |
            # Installing SoftHSM dependencies
            sudo apt-get update -qq
            sudo apt-get install libssl-dev
            sudo apt-get install autoconf -y
            sudo apt-get install automake -y
            sudo apt-get install libtool -y
            
            # Installing SoftHSM
            git clone https://github.com/opendnssec/SoftHSMv2.git -b master
            cd SoftHSMv2
            sh ./autogen.sh
            ./configure
            make
            sudo -E make install
            cd ..
            sudo ldconfig

            # initializing SoftHSM
            softhsm2-util --init-token --so-pin "12345" --pin "12345" --slot 0 --label "My slot 0"
      - run:
          name: update-npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache: # special step to restore the dependency cache 
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: install-deps
          command: npm install
      - save_cache: # special step to save the dependency cache
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: # run tests with code coverage
          name: test-code-coverage
          command: npm run coverage
      - run: # run coveralls report
          name: test-report-coveralls
          command: npm run coveralls

Use SoftHSM from master branch
ci: Use SoftHSM from master branch
