[CI] Validate pipeline resource definitions and location collection (#208398)

## Summary
This PR adds quick-checks regarding pipeline resource definitions. 
- Adds validation/correction for `locations.yml`
- Adds validation for definitions (through
`docker.elastic.co/ci-agent-images/pipelib rre validate`).
- Also fixes a missing pipeline entry in `locations.yml`

Example for when a YML error bounces on schema validation:
https://buildkite.com/elastic/kibana-pull-request/builds/270652#0194a8d5-48df-4f1b-8ec7-1f076851d138
Example for auto-fixing missing location:
b2170ac53a

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alex Szabo 2025-01-29 12:45:28 +01:00 committed by GitHub
parent 50c6cc0bbe
commit fbd871afda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 1 deletions

View file

@ -17,6 +17,7 @@ spec:
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-codeql.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-console-definitions-sync.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-coverage-daily.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-deploy-cloud.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-deploy-project.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-forward-testing-9-dot-0.yml
- https://github.com/elastic/kibana/blob/main/.buildkite/pipeline-resource-definitions/kibana-es-forward-testing.yml

View file

@ -15,7 +15,7 @@ ABSOLUTE_PATH=$(realpath "$TARGET_FILE")
FILE_NAME=$(basename "$ABSOLUTE_PATH")
FOLDER_NAME=$(dirname "$ABSOLUTE_PATH")
docker run -it \
docker run \
--mount type=bind,source="$FOLDER_NAME",target=/home/app/ \
docker.elastic.co/ci-agent-images/pipelib:0.8.0@sha256:641d7fc6cfe473900a1fbe49876762916d804b09fdf2945f74e9f803f3073779 \
rre validate --backstage-entity-aware "/home/app/$FILE_NAME"

View file

@ -20,3 +20,4 @@
.buildkite/scripts/steps/checks/test_files_missing_owner.sh
.buildkite/scripts/steps/checks/styled_components_mapping.sh
.buildkite/scripts/steps/checks/dependencies_missing_owner.sh
.buildkite/scripts/steps/checks/validate_pipelines.sh

View file

@ -0,0 +1,23 @@
set -euo pipefail
source .buildkite/scripts/common/util.sh
echo --- Check if all pipelines are in locations.yml
cmd="ts-node .buildkite/pipeline-resource-definitions/scripts/fix-location-collection.ts"
eval "$cmd"
check_for_changed_files "$cmd" true
if [[ "${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-}" != "" ]]; then
echo --- Check if all new pipelines are valid
AFFECTED_PIPELINES=$(git diff "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" --name-only | \
grep -E '^.buildkite/pipeline-resource-definitions/.*\.yml$' | \
grep -Ev '(/locations.yml|_templates)' || true)
echo "Pipelines affected by this PR: $AFFECTED_PIPELINES"
for pipeline in $AFFECTED_PIPELINES; do
.buildkite/pipeline-resource-definitions/scripts/validate-pipeline-definition.sh "$pipeline"
done
fi
exit 0