jobs:
  build:
    working_directory: /go/src/github.com/observatorium/deployments
    docker:
      - image: quay.io/coreos/jsonnet-ci
    steps:
      - checkout
      - run: make vendor-jsonnet
      - run: make generate manifests
      - run: git diff --exit-code

  test:
    machine: true
    steps:
      - checkout
      - run:
          name: e2e tests with operator
          no_output_timeout: 30m
          command: |
            ./tests/e2e.sh kind
            ./tests/e2e.sh deploy-operator
            ./tests/e2e.sh test --tls
            ./tests/e2e.sh delete-cr
      - store_artifacts:
          path: /tmp/artifacts

  container-push:
    machine: true
    steps:
      - checkout
      - run: make vendor-jsonnet
      - run: |
          echo "$DOCKER_PASS" | docker login quay.io --username $DOCKER_USER --password-stdin
          make container-push

workflows:
  version: 2
  tagged-master:
    jobs:
      - container-push:
          filters:
            tags:
              only: /^v.*/
            branches:
              only:
                - master
  test-and-push:
    jobs:
      - build
      - test
      - container-push:
          requires:
            - build
          filters:
            branches:
              only:
                - master
