# This file is meant to be edited by EUI core contributors and Elastic
# employees only. We *won't* accept any changes from external contributors
# and will close any pull requests that modify this file,
# even if the changes seem safe.

# EUI Catalog info for Backstage
# Docs: https://backstage.io/docs/features/software-catalog/descriptor-format/
# DO NOT MODIFY THIS FILE UNLESS YOU KNOW WHAT YOU'RE DOING!

---
##
# EUI component
##

# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: eui
  description: Elastic design system library
  links: [
    {
      url: "https://eui.elastic.co/",
      title: "EUI documentation",
    }
  ]
  tags: ["eui", "kibana", "typescript"]

spec:
  type: library
  owner: group:eui-team
  lifecycle: production

---
##
# buildkite-pipeline-eui-pull-request-test
# Pull request - run all unit and functional tests
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-pull-request-test
  description: EUI pipeline to run unit and functional tests on pull request
  links: [
    {
      title: "EUI - pull-request-test",
      url: "https://buildkite.com/elastic/eui-pull-request-test",
    }
  ]

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-pull-request-test
    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/pipeline_pull_request_test.yml"
      default_branch: main
      cancel_intermediate_builds: true
      # Job runs as a step in pull request combined job
      provider_settings:
        build_branches: false
        build_tags: false
        build_pull_requests: false
      teams:
        eui-team:
         access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
##
# buildkite-pipeline-eui-pull-request-test-and-deploy
# Pull request - run tests and deploy docs website PR preview
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-pull-request-test-and-deploy
  description: EUI pipeline to run tests and deploy docs to cloud on branch pull request
  links: [
    {
      title: "EUI - pull-request-test-and-deploy",
      url: "https://buildkite.com/elastic/eui-pull-request-test-and-deploy",
    }
  ]

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-pull-request-test-and-deploy
    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/pipeline_pull_request_test_and_deploy.yml"
      default_branch: main
      env:
        ELASTIC_PR_COMMENTS_ENABLED: 'true'
      cancel_intermediate_builds: true
      provider_settings:
        build_branches: false
        build_tags: false
        build_pull_requests: true
        filter_enabled: true
        filter_condition: |
          (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
      teams:
        eui-team:
         access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: BUILD_AND_READ

---
##
# buildkite-pipeline-eui-prune-staging-docs
# Run this pipeline manually in Buildkite's UI whenever we need to delete old PR staging servers
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-prune-staging-docs
  description: EUI pipeline to prune old PR staging docs
  links: [
    {
      title: "EUI - prune-staging-docs",
      url: "https://buildkite.com/elastic/eui-prune-staging-docs",
    }
  ]

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-prune-staging-docs
    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/pipeline_prune_staging_docs.yml"
      provider_settings:
        # Start Buildkite jobs using the web UI only
        build_branches: false
        build_tags: false
        build_pull_requests: false
      teams:
        eui-team:
         access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY

---
##
# buildkite-pipeline-eui-release
# EUI Release - handle (pre)release process on merge to main
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-release
  description: EUI pipeline to release the latest version of @elastic/eui
  links: [
    {
      title: "EUI - release",
      url: "https://buildkite.com/elastic/eui-release",
    }
  ]

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-release
    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/pipeline_release.yml"
      provider_settings:
        build_branches: true
        build_tags: false
        build_pull_requests: false
        filter_enabled: true
        # TODO: remove the test-automatic-releases condition when the pipeline is production-ready
        filter_condition: build.branch == "main" || build.branch == "build/test-automatic-releases"
        # Disable the pipeline for now
        trigger_mode: none
      teams:
        eui-team:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY

---
##
# buildkite-pipeline-eui-deploy-docs
# Pull request - run tests and deploy docs website PR preview
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-deploy-docs
  description: EUI pipeline to deploy the documentation website
  links: [
    {
      title: "EUI - deploy-docs",
      url: "https://buildkite.com/elastic/eui-deploy-docs",
    }
  ]

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-deploy-docs
    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/deploy_docs.yml"
      default_branch: main
      env:
        ELASTIC_PR_COMMENTS_ENABLED: 'true'
      cancel_intermediate_builds: true
      # Prevent cancelling builds from 'main' to avoid cancellations during file upload
      cancel_intermediate_builds_branch_filter: "!main"
      provider_settings:
        build_branches: true
        build_pull_requests: true
        build_tags: true
        filter_enabled: true
        # Allow PRs and 'main' branch updates
        filter_condition: (build.pull_request.id != null || build.branch == "main" || build.tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/)
      teams:
        eui-team:
         access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY

---
##
# buildkite-pipeline-eui-usage-analytics
# EUI Usage analytics - Gather EUI usage anayltics from Kibana
##

# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
  name: buildkite-pipeline-eui-usage-analytics
  description: EUI pipeline to gather EUI usage anayltics from Kibana

spec:
  type: buildkite-pipeline
  owner: group:eui-team
  system: buildkite
  implementation:
    apiVersion: buildkite.elastic.dev/v1
    kind: Pipeline
    metadata:
      name: eui-usage-analytics
      description: Gather EUI usage anayltics from Kibana
      tags: ["eui", "kibana"]

    spec:
      repository: elastic/eui
      pipeline_file: ".buildkite/pipelines/pipeline_eui_usage_analytics.yml"
      provider_settings:
        build_branches: false
        build_tags: false
        build_pull_requests: false
      teams:
        eui-team:
          access_level: MANAGE_BUILD_AND_READ
        everyone:
          access_level: READ_ONLY
