-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
# Backport This will backport the following commits from `main` to `8.x`: - [[Console] Automate console definitions (#200935)](#200935) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ignacio Rivas","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-21T16:18:00Z","message":"[Console] Automate console definitions (#200935)","sha":"0b34bbf47f7478c473cc8b8ad60945fd0aa46cc8","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","v9.0.0","backport:prev-minor"],"title":"[Console] Automate console definitions","number":200935,"url":"https://github.com/elastic/kibana/pull/200935","mergeCommit":{"message":"[Console] Automate console definitions (#200935)","sha":"0b34bbf47f7478c473cc8b8ad60945fd0aa46cc8"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200935","number":200935,"mergeCommit":{"message":"[Console] Automate console definitions (#200935)","sha":"0b34bbf47f7478c473cc8b8ad60945fd0aa46cc8"}}]}] BACKPORT--> Co-authored-by: Ignacio Rivas <[email protected]>
- Loading branch information
1 parent
7e258c1
commit 84a49c2
Showing
3 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Resource | ||
metadata: | ||
name: bk-kibana-console-definitions-sync | ||
description: Opens a PR if anything changes in the console definitions in elasticsearch-definitions | ||
links: | ||
- url: 'https://buildkite.com/elastic/kibana-console-definitions-sync' | ||
title: Pipeline link | ||
spec: | ||
type: buildkite-pipeline | ||
owner: 'group:kibana-management' | ||
system: buildkite | ||
implementation: | ||
apiVersion: buildkite.elastic.dev/v1 | ||
kind: Pipeline | ||
metadata: | ||
name: kibana / Console definitions sync | ||
description: Opens a PR if anything changes in the console definitions in elasticsearch-definitions | ||
spec: | ||
env: | ||
SLACK_NOTIFICATIONS_CHANNEL: '#kibana-management' | ||
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: 'true' | ||
allow_rebuilds: false | ||
branch_configuration: main | ||
default_branch: main | ||
repository: elastic/kibana | ||
pipeline_file: .buildkite/pipelines/console_definitions_sync.yml | ||
provider_settings: | ||
build_branches: false | ||
build_pull_requests: false | ||
publish_commit_status: false | ||
trigger_mode: none | ||
build_tags: false | ||
prefix_pull_request_fork_branch_names: false | ||
skip_pull_request_builds_for_existing_commits: true | ||
teams: | ||
kibana-management: | ||
access_level: MANAGE_BUILD_AND_READ | ||
kibana-operations: | ||
access_level: MANAGE_BUILD_AND_READ | ||
appex-qa: | ||
access_level: MANAGE_BUILD_AND_READ | ||
kibana-tech-leads: | ||
access_level: MANAGE_BUILD_AND_READ | ||
everyone: | ||
access_level: BUILD_AND_READ | ||
schedules: | ||
Weekly build: | ||
cronline: 0 0 * * 1 America/New_York | ||
message: Weekly build | ||
branch: main | ||
tags: | ||
- kibana |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
steps: | ||
- command: .buildkite/scripts/steps/console_definitions_sync.sh | ||
label: Console Definitions Sync | ||
timeout_in_minutes: 10 | ||
agents: | ||
image: family/kibana-ubuntu-2004 | ||
imageProject: elastic-images-prod | ||
provider: gcp | ||
machineType: n2-standard-2 | ||
preemptible: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
report_main_step () { | ||
echo "--- $1" | ||
} | ||
|
||
main () { | ||
cd "$PARENT_DIR" | ||
|
||
report_main_step "Cloning repositories" | ||
|
||
rm -rf elasticsearch-specification | ||
if ! git clone https://github.com/elastic/elasticsearch-specification --depth 1; then | ||
echo "Error: Failed to clone the elasticsearch-specification repository." | ||
exit 1 | ||
fi | ||
|
||
cd "$KIBANA_DIR" | ||
|
||
report_main_step "Generating console definitions" | ||
node scripts/generate_console_definitions.js --source "$PARENT_DIR/elasticsearch-specification" --emptyDest | ||
|
||
# Check if there are any differences | ||
set +e | ||
git diff --exit-code --quiet "$destination_file" | ||
if [ $? -eq 0 ]; then | ||
echo "No differences found. Exiting.." | ||
exit | ||
fi | ||
set -e | ||
|
||
report_main_step "Differences found. Checking for an existing pull request." | ||
|
||
KIBANA_MACHINE_USERNAME="kibanamachine" | ||
git config --global user.name "$KIBANA_MACHINE_USERNAME" | ||
git config --global user.email '[email protected]' | ||
|
||
PR_TITLE='[Console] Update console definitions' | ||
PR_BODY='This PR updates the console definitions to match the latest ones from the @elastic/elasticsearch-specification repo.' | ||
|
||
# Check if a PR already exists | ||
pr_search_result=$(gh pr list --search "$PR_TITLE" --state open --author "$KIBANA_MACHINE_USERNAME" --limit 1 --json title -q ".[].title") | ||
|
||
if [ "$pr_search_result" == "$PR_TITLE" ]; then | ||
echo "PR already exists. Exiting.." | ||
exit | ||
fi | ||
|
||
echo "No existing PR found. Proceeding.." | ||
|
||
# Commit diff | ||
BRANCH_NAME="console_definitions_sync_$(date +%s)" | ||
|
||
git checkout -b "$BRANCH_NAME" | ||
|
||
git add src/plugins/console/server/lib/spec_definitions/json/generated/* | ||
git commit -m "Update console definitions" | ||
|
||
report_main_step "Changes committed. Creating pull request." | ||
|
||
git push origin "$BRANCH_NAME" | ||
|
||
# Create PR | ||
gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "${BRANCH_NAME}" --label 'release_note:skip' --label 'Feature:Console' --label 'Team:Kibana Management' | ||
} | ||
|
||
main |