Skip to content

Commit

Permalink
[ES|QL] add docs step to sync pipeline (#186011)
Browse files Browse the repository at this point in the history
## Summary

#184689 added a script to gather
ES|QL function docs from Elasticsearch.

This PR adds it to our CI pipeline!

Close #173492
Close #173817

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
drewdaemon and kibanamachine authored Jun 13, 2024
1 parent 1c8fc1f commit ca98a8b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .buildkite/pipelines/esql_grammar_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ steps:
provider: gcp
machineType: n2-standard-2
preemptible: true
- command: .buildkite/scripts/steps/esql_generate_function_definitions.sh
label: Generate Function Definitions
timeout_in_minutes: 10
- command: .buildkite/scripts/steps/esql_generate_function_metadata.sh
label: Generate Function Metadata
timeout_in_minutes: 15
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

VALIDATION_PACKAGE_DIR="packages/kbn-esql-validation-autocomplete"
EDITOR_PACKAGE_DIR="packages/kbn-text-based-editor"
GIT_SCOPE="$VALIDATION_PACKAGE_DIR/**/* $EDITOR_PACKAGE_DIR/**/*"

report_main_step () {
echo "--- $1"
}
Expand All @@ -19,7 +23,7 @@ main () {

.buildkite/scripts/bootstrap.sh

cd "$KIBANA_DIR/packages/kbn-esql-validation-autocomplete"
cd "$KIBANA_DIR/$VALIDATION_PACKAGE_DIR"

report_main_step "Generate function definitions"

Expand All @@ -29,9 +33,21 @@ main () {

yarn make:tests

report_main_step "Generate inline function docs"

cd "$KIBANA_DIR/$EDITOR_PACKAGE_DIR"

yarn make:docs $PARENT_DIR/elasticsearch

report_main_step "Run i18n check"

cd "$KIBANA_DIR"

node scripts/i18n_check.js --fix

# Check for differences
set +e
git diff --exit-code --quiet .
git diff --exit-code --quiet $GIT_SCOPE
if [ $? -eq 0 ]; then
echo "No differences found. Our work is done here."
exit
Expand All @@ -44,8 +60,8 @@ main () {
git config --global user.name "$KIBANA_MACHINE_USERNAME"
git config --global user.email '[email protected]'

PR_TITLE='[ES|QL] Update function definitions'
PR_BODY='This PR updates the function definitions based on the latest metadata from Elasticsearch.'
PR_TITLE='[ES|QL] Update function metadata'
PR_BODY='This PR updates the function definitions and inline docs based on the latest metadata from 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")
Expand All @@ -58,12 +74,12 @@ main () {
echo "No existing PR found. Committing changes."

# Make a commit
BRANCH_NAME="esql_generate_function_definitions_$(date +%s)"
BRANCH_NAME="esql_generate_function_metadata_$(date +%s)"

git checkout -b "$BRANCH_NAME"

git add ./**/*
git commit -m "Update function definitions"
git add $GIT_SCOPE
git commit -m "Update function metadata"

report_main_step "Changes committed. Creating pull request."

Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ x-pack/test/observability_ai_assistant_functional @elastic/obs-ai-assistant
/WORKSPACE.bazel @elastic/kibana-operations
/.buildkite/ @elastic/kibana-operations
/.buildkite/scripts/steps/esql_grammar_sync.sh @elastic/kibana-esql
/.buildkite/scripts/steps/esql_generate_function_definitions.sh @elastic/kibana-esql
/.buildkite/scripts/steps/esql_generate_function_metadata.sh @elastic/kibana-esql
/.buildkite/pipelines/esql_grammar_sync.yml @elastic/kibana-esql
/kbn_pm/ @elastic/kibana-operations
/x-pack/dev-tools @elastic/kibana-operations
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-esql-validation-autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"make:tests": "ts-node --transpileOnly ./scripts/generate_function_validation_tests.ts",
"postmake:tests": "yarn run lint:fix",
"make:defs": "ts-node --transpileOnly ./scripts/generate_function_definitions.ts",
"postmake:defs": "yarn run lint:fix && yarn run i18n:fix",
"postmake:defs": "yarn run lint:fix",
"lint:fix": "cd ../.. && node ./scripts/eslint --fix ./packages/kbn-esql-validation-autocomplete/src/**/*.ts",
"i18n:fix": "cd ../.. && node ./scripts/i18n_check.js --fix",
"test:validation": "cd ../.. && yarn test:jest ./packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts"
}
}
5 changes: 2 additions & 3 deletions packages/kbn-text-based-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
],
"scripts": {
"make:docs": "ts-node --transpileOnly scripts/generate_esql_docs.ts",
"postmake:docs": "yarn run lint:fix && yarn run i18n:fix",
"lint:fix": "cd ../.. && node ./scripts/eslint --fix ./packages/kbn-text-based-editor/src/esql_documentation_sections.tsx",
"i18n:fix": "cd ../.. && node ./scripts/i18n_check.js --fix"
"postmake:docs": "yarn run lint:fix",
"lint:fix": "cd ../.. && node ./scripts/eslint --fix ./packages/kbn-text-based-editor/src/esql_documentation_sections.tsx"
}
}

0 comments on commit ca98a8b

Please sign in to comment.