Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .buildkite/pipelines/renovate_helper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
agents:
provider: gcp
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
machineType: n2-standard-2
steps:
- group: 'Renovate PR opened or comment'
if: build.env('GITHUB_PR_USER') == 'elastic-renovate-prod[bot]' && ((build.env('GITHUB_PR_EVENT_TYPE') == 'pull_request' && build.env('GITHUB_PR_EVENT_ACTION') == 'opened') || (build.env('GITHUB_PR_EVENT_TYPE') == 'issue_comment' && build.env('GITHUB_PR_EVENT_ACTION') == 'created'))

steps:
- command: .buildkite/scripts/steps/renovate/renovate_helper.sh
label: 'Run Renovate helper'
key: renovate_helper
timeout_in_minutes: 20
retry:
automatic:
- exit_status: '*'
limit: 1

- wait: ~

- command: .buildkite/scripts/steps/renovate/trigger_pr.sh
label: 'Trigger Kibana PR pipeline'
key: trigger_pr_opened
timeout_in_minutes: 10
retry:
automatic:
- exit_status: '*'
limit: 1

- group: 'Renovate PR updated'
# GITHUB_PR_USER is the PR author and GITHUB_PR_TRIGGER_USER is the commit author
if: build.env('GITHUB_PR_USER') == 'elastic-renovate-prod[bot]' && build.env('GITHUB_PR_TRIGGER_USER') != 'elastic-renovate-prod[bot]' && build.env('GITHUB_PR_EVENT_TYPE') == 'pull_request' && build.env('GITHUB_PR_EVENT_ACTION') == 'synchronize'
steps:
- command: .buildkite/scripts/steps/renovate/trigger_pr.sh
label: 'Trigger Kibana PR pipeline'
key: trigger_pr_updated
timeout_in_minutes: 10
retry:
automatic:
- exit_status: '*'
limit: 1
75 changes: 63 additions & 12 deletions .buildkite/pull_requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"repoOwner": "elastic",
"repoName": "kibana",
"pipelineSlug": "kibana-pull-request",

"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["elastic-vault-github-plugin-prod[bot]"],
"allowed_repo_permissions": [
"admin",
"write"
],
"allowed_list": [
"elastic-vault-github-plugin-prod[bot]"
],
"set_commit_status": true,
"commit_status_context": "kibana-ci",
"build_on_commit": true,
Expand All @@ -17,8 +21,14 @@
"build_on_ready": true,
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^\\/ci$",
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^\\/ci$",
"skip_ci_labels": ["skip-ci"],
"skip_target_branches": ["6.8", "7.11", "7.12"],
"skip_ci_labels": [
"skip-ci"
],
"skip_target_branches": [
"6.8",
"7.11",
"7.12"
],
"enable_skippable_commits": true,
"skip_ci_on_only_changed": [
"^docs/",
Expand All @@ -38,7 +48,10 @@
],
"kibana_versions_check": true,
"kibana_build_reuse": true,
"kibana_build_reuse_pipeline_slugs": ["kibana-pull-request", "kibana-on-merge"],
"kibana_build_reuse_pipeline_slugs": [
"kibana-pull-request",
"kibana-on-merge"
],
"kibana_build_reuse_regexes": [
"^test/",
"^x-pack/platform/test/",
Expand All @@ -56,8 +69,13 @@
"skip_ci_labels": [],
"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["elastic-vault-github-plugin-prod[bot]"],
"allowed_repo_permissions": [
"admin",
"write"
],
"allowed_list": [
"elastic-vault-github-plugin-prod[bot]"
],
"set_commit_status": true,
"commit_status_context": "kibana-deploy-project-from-pr",
"build_on_commit": false,
Expand All @@ -66,7 +84,11 @@
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:deploy)\\W+(?:project))$",
"kibana_versions_check": true,
"kibana_build_reuse": true,
"kibana_build_reuse_pipeline_slugs": ["kibana-pull-request", "kibana-on-merge", "kibana-deploy-project-from-pr"],
"kibana_build_reuse_pipeline_slugs": [
"kibana-pull-request",
"kibana-on-merge",
"kibana-deploy-project-from-pr"
],
"kibana_build_reuse_regexes": [
"^test/",
"^x-pack/test/",
Expand All @@ -84,8 +106,13 @@
"skip_ci_labels": [],
"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["elastic-vault-github-plugin-prod[bot]"],
"allowed_repo_permissions": [
"admin",
"write"
],
"allowed_list": [
"elastic-vault-github-plugin-prod[bot]"
],
"set_commit_status": true,
"commit_status_context": "kibana-deploy-cloud-from-pr",
"build_on_commit": false,
Expand All @@ -94,7 +121,11 @@
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:deploy)\\W+(?:cloud))$",
"kibana_versions_check": true,
"kibana_build_reuse": true,
"kibana_build_reuse_pipeline_slugs": ["kibana-pull-request", "kibana-on-merge", "kibana-deploy-cloud-from-pr"],
"kibana_build_reuse_pipeline_slugs": [
"kibana-pull-request",
"kibana-on-merge",
"kibana-deploy-cloud-from-pr"
],
"kibana_build_reuse_regexes": [
"^test/",
"^x-pack/test/",
Expand All @@ -104,6 +135,26 @@
"/__snapshots__/",
"\\.test\\.(ts|tsx|js|jsx)"
]
},
{
"repoOwner": "elastic",
"repoName": "kibana",
"pipelineSlug": "kibana-renovate-helper",
"skip_ci_labels": [],
"enabled": true,
"allow_org_users": true,
"allowed_repo_permissions": [
"admin",
"write"
],
"allowed_list": [
"elastic-vault-github-plugin-prod[bot]"
],
"build_on_commit": true,
"build_on_comment": true,
"build_drafts": false,
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:run)\\W+(?:renovate)\\W+(?:helper))$",
"kibana_versions_check": true
}
]
}
18 changes: 18 additions & 0 deletions .buildkite/scripts/steps/renovate/renovate_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh
.buildkite/scripts/bootstrap.sh

echo --- Deduplicate yarn.lock
cmd="node scripts/yarn_deduplicate.js && yarn kbn bootstrap && node scripts/yarn_deduplicate.js"
eval "$cmd"
check_for_changed_files "$cmd" true

echo --- Additional helpers
# We only want the deploy label on the main branch instead of all branches in the Renovate group
if [ "$GITHUB_PR_BRANCH" = "renovate/main-chainguard" ] && ! is_pr_with_label "ci:cloud-deploy"; then
echo "Adding deploy label to main chainguard PR"
gh api "repos/elastic/kibana/issues/${GITHUB_PR_NUMBER}/labels" --method POST -f "labels[]=ci:cloud-deploy" >/dev/null
fi
14 changes: 14 additions & 0 deletions .buildkite/scripts/steps/renovate/trigger_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -euo pipefail

echo --- Triggering Kibana Pull Request Pipeline

# The Github env vars need to be passed along manually
# GITHUB_PR_* is used to avoid any sensitive vars being passed along
GITHUB_ENV_VARS=()
for var in $(env | grep ^GITHUB_PR_ | cut -d= -f1); do
GITHUB_ENV_VARS+=("$var=${!var}")
done

ts-node .buildkite/scripts/steps/trigger_pipeline.ts kibana-pull-request "$BUILDKITE_BRANCH" "$BUILDKITE_COMMIT" "" "${GITHUB_ENV_VARS[*]}"
7 changes: 7 additions & 0 deletions .buildkite/scripts/steps/trigger_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const pipelineSlug = process.argv[2];
const branch = process.argv[3] || 'main';
const commit = process.argv[4] || 'HEAD';
const kibanaBuildId = process.argv[5] || '';
// key=value pairs in space separated string
const extraEnvVariables = process.argv[6] || '';

(async () => {
try {
Expand All @@ -22,6 +24,11 @@ const kibanaBuildId = process.argv[5] || '';
branch,
env: {
...(kibanaBuildId && { KIBANA_BUILD_ID: kibanaBuildId }),
...extraEnvVariables.split(' ').reduce<Record<string, string>>((acc, varString) => {
const [key, value] = varString.split('=');
acc[key] = value;
return acc;
}, {}),
},
ignore_pipeline_branch_filters: true, // Required because of a Buildkite bug
});
Expand Down