# Declare a Backstage Component that represents the Rally application.
---
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: rally
  description: Macrobenchmarking framework for Elasticsearch
  annotations:
    backstage.io/source-location: url:https://github.com/elastic/rally/
    github.com/project-slug: elastic/rally
    github.com/team-slug: elastic/es-perf
    buildkite.com/project-slug: elastic/rally
  tags:
    - elasticsearch
    - benchmark
    - python
    - performance
  links:
    - title: Rally docs
      url: https://esrally.readthedocs.io/en/stable/
spec:
  type: application
  owner: group:es-perf
  lifecycle: production
  dependsOn:
    - resource:rally-it-pipeline
    - resource:rally-it-serverless-pipeline
    - resource:rally-release-docker-pipeline
    - resource:rally-dev-docker-build-pipeline

# Declare Rally's Buildkite IT pipeline.
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: rally-it-pipeline
  description: Run Rally integration tests
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/rally-it

spec:
  type: buildkite-pipeline
  owner: group:es-perf
  system: buildkite

  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: Rally - IT
      description: Macrobenchmarking framework for Elasticsearch
    spec:
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#es-perf-build"
      pipeline_file: .buildkite/it/pipeline.yml
      repository: elastic/rally
      schedules:
        Daily:
          branch: master
          cronline: "0 14 * * *"
          message: periodic it
      teams:
        es-perf: {}
        everyone:
          access_level: READ_ONLY

# Declare Rally's Buildkite IT pipeline for serverless.
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: rally-it-serverless-pipeline
  description: Run Rally Serverless integration tests
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/rally-it-serverless

spec:
  type: buildkite-pipeline
  owner: group:es-perf
  system: buildkite

  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: Rally - IT Serverless
      description: Macrobenchmarking framework for Elasticsearch
    spec:
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#es-perf-build"
      pipeline_file: .buildkite/it/serverless-pipeline.yml
      repository: elastic/rally
      schedules:
        Daily:
          branch: master
          cronline: "0 14 * * *"
          message: periodic it serverless
      teams:
        es-perf: {}
        everyone:
          access_level: READ_ONLY

# Declare Rally Release Docker pipeline.
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: rally-release-docker-pipeline
  description: Release Docker Artifacts for Rally
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/rally-release-docker

spec:
  type: buildkite-pipeline
  owner: group:es-perf
  system: buildkite

  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: Rally - Release Docker
      description: Release Docker Artifacts for Rally
    spec:
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#es-perf-build"
      pipeline_file: .buildkite/release-docker/pipeline.yml
      provider_settings:
        trigger_mode: none
      repository: elastic/rally
      teams:
        es-perf: {}

# Declare Rally Dev Docker build pipeline.
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: rally-dev-docker-build-pipeline
  description: Build Docker Artifacts for Rally
  links:
    - title: Pipeline
      url: https://buildkite.com/elastic/rally-dev-docker-build
spec:
  type: buildkite-pipeline
  owner: group:es-perf
  system: buildkite

  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: Rally - Dev Docker Build
      description: Build Dev Docker Artifacts for Rally
    spec:
      env:
        ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
        SLACK_NOTIFICATIONS_CHANNEL: "#es-perf-build"
      pipeline_file: .buildkite/dev-docker/pipeline.yml
      provider_settings:
        trigger_mode: code
        filter_enabled: true
        filter_condition: 'build.branch == "master"'
        build_branches: true
        publish_commit_status: true
        build_pull_requests: false
      repository: elastic/rally
      schedules:
        Daily:
          branch: master
          # Allow terrazzo to set this to a psuedorandom cron expression to avoid collisions
          cronline: "@daily"
          message: daily dev-docker build
        # Push to the public docker registery as well as our internal registry
        Daily Public:
          branch: master
          # Allow terrazzo to set this to a psuedorandom cron expression to avoid collisions
          cronline: "@daily"
          message: daily public dev-docker build
          env:
            SHEDULED_PUBLIC_REPO: "true"
      teams:
        es-perf: {}
