# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
default_docker: &default_docker
  docker:
  - image: gpii/exekube:0.9.3-google_gpii.0

version: 2
jobs:
  terraform-fmt-check:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: Terraform Format Check
          command: |
            echo "Running Terraform format check...";
            terraform fmt --check=true /workspace

  gcp-unit-tests:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: GCP Unit Tests
          # 'bundle install' must not use '--path. See Gemfile for more details.
          command: |
            echo "Running GCP unit tests...";
            cd /workspace/shared/rakefiles/tests;
            gem install bundler --no-ri --no-rdoc -v 2.0.1;
            bundle install;
            rake

  exekube-versions-check:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: Exekube Versions Check
          command: |
            echo "Running Exekube Versions Check...";
            cd /workspace && shared/rakefiles/scripts/check_exekube_versions.sh

workflows:
  version: 2
  main:
    jobs:
      - terraform-fmt-check
      - gcp-unit-tests

# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
default_docker: &default_docker
  docker:
  - image: gpii/exekube:0.9.3-google_gpii.0

version: 2
jobs:
  terraform-fmt-check:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: Terraform Format Check
          command: |
            echo "Running Terraform format check...";
            terraform fmt --check=true /workspace

  gcp-unit-tests:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: GCP Unit Tests
          # 'bundle install' must not use '--path. See Gemfile for more details.
          command: |
            echo "Running GCP unit tests...";
            cd /workspace/shared/rakefiles/tests;
            gem install bundler --no-ri --no-rdoc -v 2.0.1;
            bundle install;
            rake

  exekube-versions-check:
    <<: *default_docker
    working_directory: /workspace
    steps:
      - checkout
      - run:
          name: Exekube Versions Check
          command: |
            echo "Running Exekube Versions Check...";
            cd /workspace && shared/rakefiles/scripts/check_exekube_versions.sh

workflows:
  version: 2
  main:
    jobs:
      - terraform-fmt-check
      - gcp-unit-tests
      - exekube-versions-check

Add new job to workflows
Add new job to workflows
