From 9e522699a5984bd98a5128c1acd7070fba0aa83f Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Mon, 28 Aug 2023 15:37:52 -0400 Subject: [PATCH 1/2] Migrate CI pipelines/workflows to Buildkite (cherry picked from commit 3fc7f40a71924801d98d2effd4657e9ed3080c71) # Conflicts: # catalog-info.yaml --- .buildkite/branches.sh | 4 ++ .buildkite/dra-build.ps1 | 18 +++++ .buildkite/dra-release.sh | 40 +++++++++++ .buildkite/dra-workflow.trigger.sh | 26 +++++++ .buildkite/hooks/pre-command | 12 ++++ .buildkite/hooks/pre-command.ps1 | 2 + .buildkite/pipeline.dra.yml | 18 +++++ .buildkite/pipeline.yml | 8 +++ .editorconfig | 2 +- catalog-info.yaml | 112 +++++++++++++++++++++++++++++ 10 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 .buildkite/branches.sh create mode 100644 .buildkite/dra-build.ps1 create mode 100644 .buildkite/dra-release.sh create mode 100755 .buildkite/dra-workflow.trigger.sh create mode 100644 .buildkite/hooks/pre-command create mode 100644 .buildkite/hooks/pre-command.ps1 create mode 100644 .buildkite/pipeline.dra.yml create mode 100644 .buildkite/pipeline.yml create mode 100644 catalog-info.yaml diff --git a/.buildkite/branches.sh b/.buildkite/branches.sh new file mode 100644 index 00000000..f21f7e99 --- /dev/null +++ b/.buildkite/branches.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# This determines which branches will have pipelines triggered periodically, for dra workflows. +BRANCHES=(main 8.10 8.9 7.17) diff --git a/.buildkite/dra-build.ps1 b/.buildkite/dra-build.ps1 new file mode 100644 index 00000000..e906602c --- /dev/null +++ b/.buildkite/dra-build.ps1 @@ -0,0 +1,18 @@ +New-Item C:/.cert -Type Directory -Force +[IO.File]::WriteAllText("C:/.cert/msi_certificate.p12", $Env:MSI_CERTIFICATE_SECRET) +[IO.File]::WriteAllText("C:/.cert/msi_password.txt", $Env:MSI_PASSWORD) + +Select-String -Pattern '^set\(DRV_VERSION (.*)\)$' -Path ".\CMakeLists.txt" | Select-Object -ExpandProperty Matches -First 1 -OutVariable Match +$VersionString=$Match.groups[1].Value + +if ($Env:DRA_WORKFLOW -eq "staging") { + cmd.exe /c 'build.bat setup proper' + cmd.exe /c 'build.bat setup 64 type:Release package sign:C:/.cert/msi_certificate.p12+C:/.cert/msi_password.txt' + cmd.exe /c 'build.bat setup 32 type:Release package sign:C:/.cert/msi_certificate.p12+C:/.cert/msi_password.txt' +} else { + cmd.exe /c 'build.bat setup proper' + cmd.exe /c 'build.bat setup 64 type:Release package:-SNAPSHOT sign:C:/.cert/msi_certificate.p12+C:/.cert/msi_password.txt' + cmd.exe /c 'build.bat setup 32 type:Release package:-SNAPSHOT sign:C:/.cert/msi_certificate.p12+C:/.cert/msi_password.txt' +} + +buildkite-agent artifact upload 'installer/build/out/*.msi' diff --git a/.buildkite/dra-release.sh b/.buildkite/dra-release.sh new file mode 100644 index 00000000..b52f4deb --- /dev/null +++ b/.buildkite/dra-release.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -euo pipefail + +DRA_WORKFLOW=${DRA_WORKFLOW:-snapshot} + +if [[ "$BUILDKITE_BRANCH" == "main" && "$DRA_WORKFLOW" == "staging" ]]; then + exit 0 +fi + +buildkite-agent artifact download '*.msi' . + +RM_BRANCH="$BUILDKITE_BRANCH" +if [[ "$BUILDKITE_BRANCH" == "main" ]]; then + RM_BRANCH=master +fi + +DRV_VERSION=$(grep 'set(DRV_VERSION' CMakeLists.txt | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+') +GIT_COMMIT=$(git rev-parse HEAD) + +# Allow other users access to read the artifacts so they are readable in the container +chmod a+r installer/build/out/* + +# Allow other users write access to create checksum files +chmod a+w installer/build/out + +docker run --rm \ + --name release-manager \ + -e VAULT_ADDR="$DRA_VAULT_ADDR" \ + -e VAULT_ROLE_ID="$DRA_VAULT_ROLE_ID_SECRET" \ + -e VAULT_SECRET_ID="$DRA_VAULT_SECRET_ID_SECRET" \ + --mount type=bind,readonly=false,src="$PWD",target=/artifacts \ + docker.elastic.co/infra/release-manager:latest \ + cli collect \ + --project elasticsearch-sql-odbc \ + --branch "$RM_BRANCH" \ + --commit "$GIT_COMMIT" \ + --workflow "$DRA_WORKFLOW" \ + --version "$DRV_VERSION" \ + --artifact-set main diff --git a/.buildkite/dra-workflow.trigger.sh b/.buildkite/dra-workflow.trigger.sh new file mode 100755 index 00000000..71593cad --- /dev/null +++ b/.buildkite/dra-workflow.trigger.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -euo pipefail + +echo "steps:" + +source .buildkite/branches.sh + +for BRANCH in "${BRANCHES[@]}"; do + cat < Date: Mon, 28 Aug 2023 16:18:49 -0400 Subject: [PATCH 2/2] PR feedback (cherry picked from commit 5b12d93756926242147acb8f46f2aeebab0b5f84) --- .buildkite/dra-workflow.trigger.sh | 6 ++++++ catalog-info.yaml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.buildkite/dra-workflow.trigger.sh b/.buildkite/dra-workflow.trigger.sh index 71593cad..ddc6890d 100755 --- a/.buildkite/dra-workflow.trigger.sh +++ b/.buildkite/dra-workflow.trigger.sh @@ -15,6 +15,11 @@ for BRANCH in "${BRANCHES[@]}"; do branch: $BRANCH env: DRA_WORKFLOW: snapshot +EOF + + # Don't trigger staging workflow for main branch + if [[ "$BRANCH" != "main" ]]; then + cat <