version: 2
jobs:
  build:
    working_directory: /tmp/sectora
    docker:
      - image: rust:1.33.0-stretch
        environment:
          OPENSSL_STATIC: yes
          OPENSSL_LIB_DIR: /usr/lib/x86_64-linux-gnu/
          OPENSSL_INCLUDE_DIR: /usr/include
    steps:
      - checkout
      - run: cargo build --target=x86_64-unknown-linux-gnu --release
      - persist_to_workspace:
          root: .
          paths:
            - ansible
            - target
            - test

  build-arm:
    working_directory: /tmp/sectora
    docker:
      - image: yasuyuky/rust-arm:1.33.0
    steps:
      - checkout
      - run: cargo build --target=arm-unknown-linux-gnueabihf --release

  test:
    docker:
      - image: docker:stable
    steps:
      - attach_workspace:
          at: .
      - run: chmod 600 test/keys/*/id_rsa
      - setup_remote_docker
      - run: apk add py3-pip make
      - run: pip3 install docker-compose
      - run: cd test && make

workflows:
  version: 2
  build_and_test:
    jobs:
      - build
      - build-arm
      - test:
          requires:
            - build

version: 2
jobs:
  build:
    working_directory: /tmp/sectora
    docker:
      - image: rust:1.33.0-stretch
        environment:
          OPENSSL_STATIC: yes
          OPENSSL_LIB_DIR: /usr/lib/x86_64-linux-gnu/
          OPENSSL_INCLUDE_DIR: /usr/include
    steps:
      - checkout
      - run: cargo build --target=x86_64-unknown-linux-gnu --release
      - persist_to_workspace:
          root: .
          paths:
            - ansible
            - target
            - test

  build-arm:
    working_directory: /tmp/sectora
    docker:
      - image: yasuyuky/rust-arm:1.33.0
    steps:
      - checkout
      - run: cargo build --target=arm-unknown-linux-gnueabihf --release

  test:
    docker:
      - image: docker/compose:1.24.0
    steps:
      - attach_workspace:
          at: .
      - run: chmod 600 test/keys/*/id_rsa
      - setup_remote_docker
      - run: apk add make
      - run: cd test && make

workflows:
  version: 2
  build_and_test:
    jobs:
      - build
      - build-arm
      - test:
          requires:
            - build

Use docker/compose image for test
Use docker/compose image for test
