version: 2.1
orbs:
  node: circleci/node@1.1.6
  codecov: codecov/codecov@1.0.2
  python: circleci/python@1.3.2
jobs:
  build-and-test:
    executor:
      name: node/default
    steps:
      - checkout
      - node/with-cache:
          steps:
            - run: npm ci
            - run: npm install jest --save-dev
            - run: npm run build
            - run: npm run test
      - codecov/upload:
          file: "./coverage/clover.xml"
          token: bc55e615-594b-40a3-bf51-3e408a8e5f85
  eslint:
    executor:
      name: node/default
    steps:
      - checkout
      - node/with-cache:
          steps:
            - run: npm ci
            - run: npm run eslint
  build-typescript:
    executor:
      name: node/default
    steps:
      - checkout
      - node/with-cache:
          steps:
            - run: npm ci
            - run: npm run build
  deploy-docs:
    docker:
      - image: cimg/python:3.9.1-node
    steps:
      - checkout
      - run: pip install mkdocs mkdocs-material
      - run: python --version
      - run: node --version
      - run: npm ci
      - run: git clone https://github.com/Visualizememe/bloxy site
      - run: cd site && git checkout gh-pages
      - run: npm run create-docs
      - run: git config --global user.name "Martin"
      - run: git config --global user.email "m@xnx.no"
      - run: echo "bloxy.js.org" >> site/CNAME
      - run: cd site && git init && git add . && git commit -m "Updates" && git pull origin gh-pages && git push origin gh-pages
workflows:
  build-and-test:
    jobs:
      - eslint
      - build-typescript
      - build-and-test
      - deploy-docs
