version: 2
jobs:
  build:
    docker:
      - image: fmidev/rpmbuild:el7
        entrypoint: bash
        environment:
          RPM_BUILD_NCPUS: 2
    steps:
      - checkout
      - run:
          name: Create local repo
          command: createrepo /home/rpmbuild/rpmbuild/RPMS/x86_64
      - run:
          name: Install dependencies
          command: sudo yum-builddep --disableexcludes=smartmet-open -y *.spec 
      - run:
          name: make rpm
          command: make rpm
      - run:
          name: Move artifacts
          command: sudo cp -av /home/rpmbuild/rpmbuild/RPMS /
      - store_artifacts:
          path: /RPMS

version: 2
jobs:
  build:
    docker:
      - image: fmidev/smartmet-cibase:latest
    steps:
      - checkout
      - run:
          name: Install build dependencies
          command: ci-build deps
      - run:
          name: Build RPM
          command: ci-build rpm
      - persist_to_workspace:
          root: /dist
          paths: ./*.rpm
  test:
    docker:
      - image: fmidev/smartmet-cibase:latest
    steps:
      - checkout
      - attach_workspace:
          at: /dist
      - run:
          name: Installation test
          command: ci-build dummy ; sudo yum install -y /dist/*.rpm
      - run:
          name: Test prepare
          command: ci-build testprep
      - run:
          name: Test
          command: ci-build test
      - store_artifacts:
          path: /dist
          destination: dist/

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

Enable two-job build-test workflow, workaround for test install on FMI network
Enable two-job build-test workflow, workaround for test install on FMI network
