version: 2
jobs:
  lint:
    docker:
      - image: 'python:3.7'

    environment:
        KMK_TEST: 1
        PIPENV_VENV_IN_PROJECT: 1

    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-kmk-venv-{{ checksum "Pipfile.lock" }}

      - run: pip install pipenv==2018.7.1
      - run: make lint

      - save_cache:
          key: v1-kmk-venv-{{ checksum "Pipfile.lock" }}
          paths:
            - .venv

  test:
    docker:
      - image: 'python:3.7'

    environment:
        KMK_TEST: 1
        PIPENV_VENV_IN_PROJECT: 1

    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-kmk-venv-{{ checksum "Pipfile.lock" }}

      - run: pip install pipenv==2018.7.1
      - run: make test

  build_pyboard:
    docker:
      - image: 'python:3.7'

    environment:
        KMK_TEST: 1
        PIPENV_VENV_IN_PROJECT: 1

    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-kmk-venv-{{ checksum "Pipfile.lock" }}

      - run: pip install pipenv==2018.7.1
      - run: apt-get update && apt-get install -y gcc-arm-none-eabi gettext wget unzip

      - run: make SKIP_KEYMAP_VALIDATION=1 USER_KEYMAP=user_keymaps/noop.py build-pyboard

  build_teensy_31:
    docker:
      - image: 'python:3.7'

    environment:
        KMK_TEST: 1
        PIPENV_VENV_IN_PROJECT: 1

    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-kmk-venv-{{ checksum "Pipfile.lock" }}

      - run: pip install pipenv==2018.7.1
      - run: apt-get update && apt-get install -y gcc-arm-none-eabi gettext wget unzip

      - run: make USER_KEYMAP=user_keymaps/noop.py build-teensy-3.1

workflows:
  version: 2
  build-deploy:
    jobs:
      - lint:
          filters:
            branches:
              only: /.*/
            tags:
              only: /.*/
      - test:
          filters:
            branches:
              only: /.*/
            tags:
              only: /.*/
          requires:
            - lint
      - build_pyboard:
          filters:
            branches:
              only: /.*/
            tags:
              only: /.*/
          requires:
            - test
      - build_teensy_31:
          filters:
            branches:
              only: /.*/
            tags:
              only: /.*/
          requires:
            - test