From cec33f9124ade665b7e97aa235a5f0279241cf8f Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 10:52:05 +0100 Subject: [PATCH 1/8] Create pipeline definition and script --- .../pipelines/console_definitions_sync.yml | 10 ++ .../scripts/steps/console_definitions_sync.sh | 126 ++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 .buildkite/pipelines/console_definitions_sync.yml create mode 100755 .buildkite/scripts/steps/console_definitions_sync.sh diff --git a/.buildkite/pipelines/console_definitions_sync.yml b/.buildkite/pipelines/console_definitions_sync.yml new file mode 100644 index 0000000000000..22d91eacbdbdb --- /dev/null +++ b/.buildkite/pipelines/console_definitions_sync.yml @@ -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 diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh new file mode 100755 index 0000000000000..4c33beb26ec29 --- /dev/null +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +set -euo pipefail + +synchronize_lexer_grammar () { + license_header="$1" + source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4" + destination_file="./packages/kbn-esql-ast/src/antlr/esql_lexer.g4" + + # Copy the file + cp "$source_file" "$destination_file" + + # Insert the license header + temp_file=$(mktemp) + printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat $destination_file)" > "$temp_file" + mv "$temp_file" "$destination_file" + + # Replace the line containing "lexer grammar" with "lexer grammar esql_lexer;" + sed -i -e 's/lexer grammar.*$/lexer grammar esql_lexer;/' "$destination_file" + + # Replace the line containing "superClass" with "superClass=lexer_config;" + sed -i -e 's/superClass.*$/superClass=lexer_config;/' "$destination_file" + + echo "File copied and modified successfully." +} + +synchronize_parser_grammar () { + license_header="$1" + source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4" + destination_file="./packages/kbn-esql-ast/src/antlr/esql_parser.g4" + + # Copy the file + cp "$source_file" "$destination_file" + + # Insert the license header + temp_file=$(mktemp) + printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat ${destination_file})" > "$temp_file" + mv "$temp_file" "$destination_file" + + # Replace the line containing "parser grammar" with "parser grammar esql_parser;" + sed -i -e 's/parser grammar.*$/parser grammar esql_parser;/' "$destination_file" + + # Replace tokenVocab=EsqlBaseLexer; with tokenVocab=esql_lexer; + sed -i -e 's/tokenVocab=EsqlBaseLexer;/tokenVocab=esql_lexer;/' "$destination_file" + + # Replace the line containing "superClass" with "superClass=parser_config;" + sed -i -e 's/superClass.*$/superClass=parser_config;/' "$destination_file" + + echo "File copied and modified successfully." +} + +report_main_step () { + echo "--- $1" +} + +main () { + cd "$PARENT_DIR" + + report_main_step "Cloning repositories" + + rm -rf elasticsearch + git clone https://github.com/elastic/elasticsearch --depth 1 + + cd "$KIBANA_DIR" + + license_header=$(cat "$KIBANA_DIR/licenses/ELASTIC-LICENSE-2.0-HEADER.txt") + + report_main_step "Synchronizing lexer grammar..." + synchronize_lexer_grammar "$license_header" + + report_main_step "Synchronizing parser grammar..." + synchronize_parser_grammar "$license_header" + + # Check for differences + set +e + git diff --exit-code --quiet "$destination_file" + if [ $? -eq 0 ]; then + echo "No differences found. Our work is done here." + 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 '42973632+kibanamachine@users.noreply.github.com' + + PR_TITLE='[ES|QL] Update grammars' + PR_BODY='This PR updates the ES|QL grammars (lexer and parser) to match the latest version in Elasticsearch.' + + # 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." + + report_main_step "Building ANTLR artifacts." + + # Bootstrap Kibana + .buildkite/scripts/bootstrap.sh + + # Build ANTLR stuff + cd ./packages/kbn-esql-ast/src + yarn build:antlr4:esql + + # Make a commit + BRANCH_NAME="esql_grammar_sync_$(date +%s)" + + git checkout -b "$BRANCH_NAME" + + git add antlr/* + git commit -m "Update ES|QL grammars" + + report_main_step "Changes committed. Creating pull request." + + git push origin "$BRANCH_NAME" + + # Create a PR + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "${BRANCH_NAME}" --label 'release_note:skip' --label 'Team:ESQL' +} + +main From 1b638f79fc39b7d13792eb62ee87049499a286ef Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 10:52:23 +0100 Subject: [PATCH 2/8] Clean slate --- .../scripts/steps/console_definitions_sync.sh | 112 ------------------ 1 file changed, 112 deletions(-) diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh index 4c33beb26ec29..b27077dc6ac41 100755 --- a/.buildkite/scripts/steps/console_definitions_sync.sh +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -1,53 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -synchronize_lexer_grammar () { - license_header="$1" - source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4" - destination_file="./packages/kbn-esql-ast/src/antlr/esql_lexer.g4" - - # Copy the file - cp "$source_file" "$destination_file" - - # Insert the license header - temp_file=$(mktemp) - printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat $destination_file)" > "$temp_file" - mv "$temp_file" "$destination_file" - - # Replace the line containing "lexer grammar" with "lexer grammar esql_lexer;" - sed -i -e 's/lexer grammar.*$/lexer grammar esql_lexer;/' "$destination_file" - - # Replace the line containing "superClass" with "superClass=lexer_config;" - sed -i -e 's/superClass.*$/superClass=lexer_config;/' "$destination_file" - - echo "File copied and modified successfully." -} - -synchronize_parser_grammar () { - license_header="$1" - source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4" - destination_file="./packages/kbn-esql-ast/src/antlr/esql_parser.g4" - - # Copy the file - cp "$source_file" "$destination_file" - - # Insert the license header - temp_file=$(mktemp) - printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat ${destination_file})" > "$temp_file" - mv "$temp_file" "$destination_file" - - # Replace the line containing "parser grammar" with "parser grammar esql_parser;" - sed -i -e 's/parser grammar.*$/parser grammar esql_parser;/' "$destination_file" - - # Replace tokenVocab=EsqlBaseLexer; with tokenVocab=esql_lexer; - sed -i -e 's/tokenVocab=EsqlBaseLexer;/tokenVocab=esql_lexer;/' "$destination_file" - - # Replace the line containing "superClass" with "superClass=parser_config;" - sed -i -e 's/superClass.*$/superClass=parser_config;/' "$destination_file" - - echo "File copied and modified successfully." -} - report_main_step () { echo "--- $1" } @@ -56,71 +9,6 @@ main () { cd "$PARENT_DIR" report_main_step "Cloning repositories" - - rm -rf elasticsearch - git clone https://github.com/elastic/elasticsearch --depth 1 - - cd "$KIBANA_DIR" - - license_header=$(cat "$KIBANA_DIR/licenses/ELASTIC-LICENSE-2.0-HEADER.txt") - - report_main_step "Synchronizing lexer grammar..." - synchronize_lexer_grammar "$license_header" - - report_main_step "Synchronizing parser grammar..." - synchronize_parser_grammar "$license_header" - - # Check for differences - set +e - git diff --exit-code --quiet "$destination_file" - if [ $? -eq 0 ]; then - echo "No differences found. Our work is done here." - 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 '42973632+kibanamachine@users.noreply.github.com' - - PR_TITLE='[ES|QL] Update grammars' - PR_BODY='This PR updates the ES|QL grammars (lexer and parser) to match the latest version in Elasticsearch.' - - # 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." - - report_main_step "Building ANTLR artifacts." - - # Bootstrap Kibana - .buildkite/scripts/bootstrap.sh - - # Build ANTLR stuff - cd ./packages/kbn-esql-ast/src - yarn build:antlr4:esql - - # Make a commit - BRANCH_NAME="esql_grammar_sync_$(date +%s)" - - git checkout -b "$BRANCH_NAME" - - git add antlr/* - git commit -m "Update ES|QL grammars" - - report_main_step "Changes committed. Creating pull request." - - git push origin "$BRANCH_NAME" - - # Create a PR - gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "${BRANCH_NAME}" --label 'release_note:skip' --label 'Team:ESQL' } main From 43760fb62a9fc89e0967e891fb2a89acbb9a5b9c Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 10:52:43 +0100 Subject: [PATCH 3/8] commit with @elastic email --- .../scripts/steps/console_definitions_sync.sh | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh index b27077dc6ac41..4c33beb26ec29 100755 --- a/.buildkite/scripts/steps/console_definitions_sync.sh +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -1,6 +1,53 @@ #!/usr/bin/env bash set -euo pipefail +synchronize_lexer_grammar () { + license_header="$1" + source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4" + destination_file="./packages/kbn-esql-ast/src/antlr/esql_lexer.g4" + + # Copy the file + cp "$source_file" "$destination_file" + + # Insert the license header + temp_file=$(mktemp) + printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat $destination_file)" > "$temp_file" + mv "$temp_file" "$destination_file" + + # Replace the line containing "lexer grammar" with "lexer grammar esql_lexer;" + sed -i -e 's/lexer grammar.*$/lexer grammar esql_lexer;/' "$destination_file" + + # Replace the line containing "superClass" with "superClass=lexer_config;" + sed -i -e 's/superClass.*$/superClass=lexer_config;/' "$destination_file" + + echo "File copied and modified successfully." +} + +synchronize_parser_grammar () { + license_header="$1" + source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4" + destination_file="./packages/kbn-esql-ast/src/antlr/esql_parser.g4" + + # Copy the file + cp "$source_file" "$destination_file" + + # Insert the license header + temp_file=$(mktemp) + printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat ${destination_file})" > "$temp_file" + mv "$temp_file" "$destination_file" + + # Replace the line containing "parser grammar" with "parser grammar esql_parser;" + sed -i -e 's/parser grammar.*$/parser grammar esql_parser;/' "$destination_file" + + # Replace tokenVocab=EsqlBaseLexer; with tokenVocab=esql_lexer; + sed -i -e 's/tokenVocab=EsqlBaseLexer;/tokenVocab=esql_lexer;/' "$destination_file" + + # Replace the line containing "superClass" with "superClass=parser_config;" + sed -i -e 's/superClass.*$/superClass=parser_config;/' "$destination_file" + + echo "File copied and modified successfully." +} + report_main_step () { echo "--- $1" } @@ -9,6 +56,71 @@ main () { cd "$PARENT_DIR" report_main_step "Cloning repositories" + + rm -rf elasticsearch + git clone https://github.com/elastic/elasticsearch --depth 1 + + cd "$KIBANA_DIR" + + license_header=$(cat "$KIBANA_DIR/licenses/ELASTIC-LICENSE-2.0-HEADER.txt") + + report_main_step "Synchronizing lexer grammar..." + synchronize_lexer_grammar "$license_header" + + report_main_step "Synchronizing parser grammar..." + synchronize_parser_grammar "$license_header" + + # Check for differences + set +e + git diff --exit-code --quiet "$destination_file" + if [ $? -eq 0 ]; then + echo "No differences found. Our work is done here." + 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 '42973632+kibanamachine@users.noreply.github.com' + + PR_TITLE='[ES|QL] Update grammars' + PR_BODY='This PR updates the ES|QL grammars (lexer and parser) to match the latest version in Elasticsearch.' + + # 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." + + report_main_step "Building ANTLR artifacts." + + # Bootstrap Kibana + .buildkite/scripts/bootstrap.sh + + # Build ANTLR stuff + cd ./packages/kbn-esql-ast/src + yarn build:antlr4:esql + + # Make a commit + BRANCH_NAME="esql_grammar_sync_$(date +%s)" + + git checkout -b "$BRANCH_NAME" + + git add antlr/* + git commit -m "Update ES|QL grammars" + + report_main_step "Changes committed. Creating pull request." + + git push origin "$BRANCH_NAME" + + # Create a PR + gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "${BRANCH_NAME}" --label 'release_note:skip' --label 'Team:ESQL' } main From 0f2e45372580d6caa24dba47661e7253942f35c1 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 15:25:42 +0100 Subject: [PATCH 4/8] Fix script --- .../scripts/steps/console_definitions_sync.sh | 87 +++---------------- 1 file changed, 13 insertions(+), 74 deletions(-) diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh index 4c33beb26ec29..40d27bf07474c 100755 --- a/.buildkite/scripts/steps/console_definitions_sync.sh +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -1,53 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -synchronize_lexer_grammar () { - license_header="$1" - source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4" - destination_file="./packages/kbn-esql-ast/src/antlr/esql_lexer.g4" - - # Copy the file - cp "$source_file" "$destination_file" - - # Insert the license header - temp_file=$(mktemp) - printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat $destination_file)" > "$temp_file" - mv "$temp_file" "$destination_file" - - # Replace the line containing "lexer grammar" with "lexer grammar esql_lexer;" - sed -i -e 's/lexer grammar.*$/lexer grammar esql_lexer;/' "$destination_file" - - # Replace the line containing "superClass" with "superClass=lexer_config;" - sed -i -e 's/superClass.*$/superClass=lexer_config;/' "$destination_file" - - echo "File copied and modified successfully." -} - -synchronize_parser_grammar () { - license_header="$1" - source_file="$PARENT_DIR/elasticsearch/x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4" - destination_file="./packages/kbn-esql-ast/src/antlr/esql_parser.g4" - - # Copy the file - cp "$source_file" "$destination_file" - - # Insert the license header - temp_file=$(mktemp) - printf "// DO NOT MODIFY THIS FILE BY HAND. IT IS MANAGED BY A CI JOB.\n\n%s" "$(cat ${destination_file})" > "$temp_file" - mv "$temp_file" "$destination_file" - - # Replace the line containing "parser grammar" with "parser grammar esql_parser;" - sed -i -e 's/parser grammar.*$/parser grammar esql_parser;/' "$destination_file" - - # Replace tokenVocab=EsqlBaseLexer; with tokenVocab=esql_lexer; - sed -i -e 's/tokenVocab=EsqlBaseLexer;/tokenVocab=esql_lexer;/' "$destination_file" - - # Replace the line containing "superClass" with "superClass=parser_config;" - sed -i -e 's/superClass.*$/superClass=parser_config;/' "$destination_file" - - echo "File copied and modified successfully." -} - report_main_step () { echo "--- $1" } @@ -57,24 +10,19 @@ main () { report_main_step "Cloning repositories" - rm -rf elasticsearch - git clone https://github.com/elastic/elasticsearch --depth 1 + rm -rf elasticsearch-specification + git clone https://github.com/elastic/elasticsearch-specification --depth 1 cd "$KIBANA_DIR" - license_header=$(cat "$KIBANA_DIR/licenses/ELASTIC-LICENSE-2.0-HEADER.txt") - - report_main_step "Synchronizing lexer grammar..." - synchronize_lexer_grammar "$license_header" - - report_main_step "Synchronizing parser grammar..." - synchronize_parser_grammar "$license_header" + report_main_step "Generating console definitions" + node scripts/generate_console_definitions.js --source "$PARENT_DIR/elasticsearch-specification" --emptyDest # Check for differences set +e git diff --exit-code --quiet "$destination_file" if [ $? -eq 0 ]; then - echo "No differences found. Our work is done here." + echo "No differences found. Exiting.." exit fi set -e @@ -85,42 +33,33 @@ main () { git config --global user.name "$KIBANA_MACHINE_USERNAME" git config --global user.email '42973632+kibanamachine@users.noreply.github.com' - PR_TITLE='[ES|QL] Update grammars' - PR_BODY='This PR updates the ES|QL grammars (lexer and parser) to match the latest version in Elasticsearch.' + 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." + echo "PR already exists. Exiting.." exit fi - echo "No existing PR found. Proceeding." - - report_main_step "Building ANTLR artifacts." - - # Bootstrap Kibana - .buildkite/scripts/bootstrap.sh - - # Build ANTLR stuff - cd ./packages/kbn-esql-ast/src - yarn build:antlr4:esql + echo "No existing PR found. Proceeding.." # Make a commit - BRANCH_NAME="esql_grammar_sync_$(date +%s)" + BRANCH_NAME="console_definitions_sync_$(date +%s)" git checkout -b "$BRANCH_NAME" - git add antlr/* - git commit -m "Update ES|QL grammars" + 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 a PR - gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head "${BRANCH_NAME}" --label 'release_note:skip' --label 'Team:ESQL' + 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 From 69ee15ed4f9ef1ba372e2e60fdada15ff14b87cc Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 15:55:45 +0100 Subject: [PATCH 5/8] Add check for failed to clone --- .buildkite/scripts/steps/console_definitions_sync.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh index 40d27bf07474c..457e91f968196 100755 --- a/.buildkite/scripts/steps/console_definitions_sync.sh +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -11,7 +11,10 @@ main () { report_main_step "Cloning repositories" rm -rf elasticsearch-specification - git clone https://github.com/elastic/elasticsearch-specification --depth 1 + 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" From 351732b2841f66aa8ac3c0703435751d5ee01787 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 15:57:05 +0100 Subject: [PATCH 6/8] Add comments --- .buildkite/scripts/steps/console_definitions_sync.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/scripts/steps/console_definitions_sync.sh b/.buildkite/scripts/steps/console_definitions_sync.sh index 457e91f968196..55719292959e8 100755 --- a/.buildkite/scripts/steps/console_definitions_sync.sh +++ b/.buildkite/scripts/steps/console_definitions_sync.sh @@ -21,7 +21,7 @@ main () { report_main_step "Generating console definitions" node scripts/generate_console_definitions.js --source "$PARENT_DIR/elasticsearch-specification" --emptyDest - # Check for differences + # Check if there are any differences set +e git diff --exit-code --quiet "$destination_file" if [ $? -eq 0 ]; then @@ -49,7 +49,7 @@ main () { echo "No existing PR found. Proceeding.." - # Make a commit + # Commit diff BRANCH_NAME="console_definitions_sync_$(date +%s)" git checkout -b "$BRANCH_NAME" @@ -61,7 +61,7 @@ main () { git push origin "$BRANCH_NAME" - # Create a PR + # 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' } From 1591e8afd9696ebd889e40e42e4b2d59cd6ba489 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 16:35:05 +0100 Subject: [PATCH 7/8] Add pipeline resource definition --- .../kibana-console-definitions-sync.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml diff --git a/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml b/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml new file mode 100644 index 0000000000000..5c46d7ca6701f --- /dev/null +++ b/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml @@ -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-esql: + 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 From a203c8dca16c5f54af0fba68b21d77c741a0e111 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 20 Nov 2024 19:43:08 +0100 Subject: [PATCH 8/8] Set teams permissions --- .../kibana-console-definitions-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml b/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml index 5c46d7ca6701f..a228823202c01 100644 --- a/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml +++ b/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml @@ -35,7 +35,7 @@ spec: prefix_pull_request_fork_branch_names: false skip_pull_request_builds_for_existing_commits: true teams: - kibana-esql: + kibana-management: access_level: MANAGE_BUILD_AND_READ kibana-operations: access_level: MANAGE_BUILD_AND_READ