From 41d8ec50fa84907e0338b4442b71542a4e7f2822 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Thu, 2 Nov 2023 14:34:57 -0400 Subject: [PATCH] [ci] Migrate branch consistency and protection checks to Buildkite (#101646) (cherry picked from commit dee880a49bd51f6656ea67f8fe86628830cb684b) --- .buildkite/pipelines/intake.template.yml | 6 +++--- .buildkite/pipelines/periodic.template.yml | 14 ++++++++++++-- .buildkite/pipelines/periodic.yml | 10 ++++++++++ .buildkite/scripts/branch-protection.sh | 10 ++++++++++ .../elastic+elasticsearch+branch-consistency.yml | 8 ++++---- .../elastic+elasticsearch+branch-protection.yml | 6 +++--- .ci/scripts/run-gradle.sh | 5 +++++ 7 files changed, 47 insertions(+), 12 deletions(-) create mode 100755 .buildkite/scripts/branch-protection.sh diff --git a/.buildkite/pipelines/intake.template.yml b/.buildkite/pipelines/intake.template.yml index 8a9c153da4e0d..32b0a12f06a0e 100644 --- a/.buildkite/pipelines/intake.template.yml +++ b/.buildkite/pipelines/intake.template.yml @@ -14,7 +14,7 @@ steps: agents: provider: gcp image: family/elasticsearch-ubuntu-2004 - machineType: custom-32-98304 + machineType: n1-standard-32 buildDirectory: /dev/shm/bk - label: part2 command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-task-input-files checkPart2 @@ -22,7 +22,7 @@ steps: agents: provider: gcp image: family/elasticsearch-ubuntu-2004 - machineType: custom-32-98304 + machineType: n1-standard-32 buildDirectory: /dev/shm/bk - label: part3 command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-task-input-files checkPart3 @@ -30,7 +30,7 @@ steps: agents: provider: gcp image: family/elasticsearch-ubuntu-2004 - machineType: custom-32-98304 + machineType: n1-standard-32 buildDirectory: /dev/shm/bk - group: bwc-snapshots steps: diff --git a/.buildkite/pipelines/periodic.template.yml b/.buildkite/pipelines/periodic.template.yml index 08ba9529eb882..afb183409c3cd 100644 --- a/.buildkite/pipelines/periodic.template.yml +++ b/.buildkite/pipelines/periodic.template.yml @@ -54,7 +54,7 @@ steps: agents: provider: gcp image: family/elasticsearch-ubuntu-2004 - machineType: custom-32-98304 + machineType: n1-standard-32 buildDirectory: /dev/shm/bk env: ES_RUNTIME_JAVA: "{{matrix.ES_RUNTIME_JAVA}}" @@ -82,7 +82,7 @@ steps: agents: provider: gcp image: family/elasticsearch-ubuntu-2004 - machineType: custom-32-98304 + machineType: n1-standard-32 buildDirectory: /dev/shm/bk env: ES_RUNTIME_JAVA: "{{matrix.ES_RUNTIME_JAVA}}" @@ -180,3 +180,13 @@ steps: image: family/elasticsearch-ubuntu-2004 machineType: n2-standard-8 buildDirectory: /dev/shm/bk + - label: Check branch consistency + command: .ci/scripts/run-gradle.sh branchConsistency + timeout_in_minutes: 15 + agents: + provider: gcp + image: family/elasticsearch-ubuntu-2004 + machineType: n2-standard-2 + - label: Check branch protection rules + command: .buildkite/scripts/branch-protection.sh + timeout_in_minutes: 5 diff --git a/.buildkite/pipelines/periodic.yml b/.buildkite/pipelines/periodic.yml index 5afec657ae32b..fadc37e3d8de1 100644 --- a/.buildkite/pipelines/periodic.yml +++ b/.buildkite/pipelines/periodic.yml @@ -1221,3 +1221,13 @@ steps: image: family/elasticsearch-ubuntu-2004 machineType: n2-standard-8 buildDirectory: /dev/shm/bk + - label: Check branch consistency + command: .ci/scripts/run-gradle.sh branchConsistency + timeout_in_minutes: 15 + agents: + provider: gcp + image: family/elasticsearch-ubuntu-2004 + machineType: n2-standard-2 + - label: Check branch protection rules + command: .buildkite/scripts/branch-protection.sh + timeout_in_minutes: 5 diff --git a/.buildkite/scripts/branch-protection.sh b/.buildkite/scripts/branch-protection.sh new file mode 100755 index 0000000000000..6c1c46ed8f09e --- /dev/null +++ b/.buildkite/scripts/branch-protection.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + +STATUS=$(curl -s "https://api.github.com/repos/elastic/elasticsearch/branches/$BUILDKITE_BRANCH" | jq '.protected') +echo "Branch $BUILDKITE_BRANCH protection status is: $STATUS" +if [[ "$STATUS" == "false" ]]; then + echo "Development branch $BUILDKITE_BRANCH is not set as protected in GitHub but should be." + exit 1 +fi diff --git a/.ci/jobs.t/elastic+elasticsearch+branch-consistency.yml b/.ci/jobs.t/elastic+elasticsearch+branch-consistency.yml index bb96970010358..5a35727b3df65 100644 --- a/.ci/jobs.t/elastic+elasticsearch+branch-consistency.yml +++ b/.ci/jobs.t/elastic+elasticsearch+branch-consistency.yml @@ -2,12 +2,12 @@ - job: name: elastic+elasticsearch+%BRANCH%+branch-consistency display-name: "elastic / elasticsearch # %BRANCH% - branch consistency" - description: Testing of the Elasticsearch %BRANCH% branch version consistency. - triggers: - - timed: "H 7 * * *" + description: "This job has been migrated to Buildkite.\n" + disabled: true + triggers: [] builders: - inject: - properties-file: '.ci/java-versions.properties' + properties-file: ".ci/java-versions.properties" properties-content: | JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA - shell: | diff --git a/.ci/jobs.t/elastic+elasticsearch+branch-protection.yml b/.ci/jobs.t/elastic+elasticsearch+branch-protection.yml index 30e4c1c20dd43..3e6a88ac93596 100644 --- a/.ci/jobs.t/elastic+elasticsearch+branch-protection.yml +++ b/.ci/jobs.t/elastic+elasticsearch+branch-protection.yml @@ -2,10 +2,10 @@ - job: name: elastic+elasticsearch+%BRANCH%+branch-protection display-name: "elastic / elasticsearch # %BRANCH% - branch protection" - description: Elasticsearch %BRANCH% branch protection. + description: "This job has been migrated to Buildkite.\n" + disabled: true node: master - triggers: - - timed: "H 7 * * *" + triggers: [] scm: [] parameters: [] builders: diff --git a/.ci/scripts/run-gradle.sh b/.ci/scripts/run-gradle.sh index ea68ab7718579..af5db8a6b4063 100755 --- a/.ci/scripts/run-gradle.sh +++ b/.ci/scripts/run-gradle.sh @@ -31,5 +31,10 @@ if ! uname -a | grep -q MING; then export GLIBC_VERSION=$(ldd --version | grep '^ldd' | sed 's/.* \([1-9]\.[0-9]*\).*/\1/') fi +# Running on 2-core machines without ramdisk can make this value be 0 +if [[ "$MAX_WORKERS" == "0" ]]; then + MAX_WORKERS=1 +fi + set -e $GRADLEW -S --max-workers=$MAX_WORKERS $@