From 08519aa8e0a7458783479ede24e352a75c686258 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 11 Oct 2023 13:56:41 -0400 Subject: [PATCH] [buildkite] Add more logging and debug information to PR pipeline generation --- .../scripts/pull-request/pipeline.generate.ts | 15 ++++++++++----- .buildkite/scripts/pull-request/pipeline.sh | 3 +++ .buildkite/scripts/pull-request/pipeline.ts | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.buildkite/scripts/pull-request/pipeline.generate.ts b/.buildkite/scripts/pull-request/pipeline.generate.ts index 69caff990dcfe..6a61e87eff9f4 100644 --- a/.buildkite/scripts/pull-request/pipeline.generate.ts +++ b/.buildkite/scripts/pull-request/pipeline.generate.ts @@ -6,11 +6,16 @@ import { generatePipelines } from "./pipeline"; const pipelines = generatePipelines(); for (const pipeline of pipelines) { - if (!process.env.CI) { - // Just for local debugging purposes - console.log(""); - console.log(stringify(pipeline)); - } else { + const yaml = stringify(pipeline); + + console.log("--- Generated pipeline"); + console.log(yaml); + + // Only do the pipeline upload if we're actually in CI + // This lets us run the tool locally and see the output + if (process.env.CI) { + console.log("--- Uploading pipeline"); + execSync(`buildkite-agent pipeline upload`, { input: stringify(pipeline), stdio: ["pipe", "inherit", "inherit"], diff --git a/.buildkite/scripts/pull-request/pipeline.sh b/.buildkite/scripts/pull-request/pipeline.sh index 77bbc1e115430..3012308fbcace 100755 --- a/.buildkite/scripts/pull-request/pipeline.sh +++ b/.buildkite/scripts/pull-request/pipeline.sh @@ -2,5 +2,8 @@ set -euo pipefail +echo --- Installing bun npm install -g bun + +echo --- Generating pipeline bun .buildkite/scripts/pull-request/pipeline.generate.ts diff --git a/.buildkite/scripts/pull-request/pipeline.ts b/.buildkite/scripts/pull-request/pipeline.ts index a6a3df6ff2aff..f5caf63356149 100644 --- a/.buildkite/scripts/pull-request/pipeline.ts +++ b/.buildkite/scripts/pull-request/pipeline.ts @@ -116,6 +116,7 @@ export const generatePipelines = ( .filter((x) => x); if (!changedFiles?.length) { + console.log("Doing git fetch and getting merge-base"); const mergeBase = execSync( `git fetch origin ${process.env["GITHUB_PR_TARGET_BRANCH"]}; git merge-base origin/${process.env["GITHUB_PR_TARGET_BRANCH"]} HEAD`, { cwd: PROJECT_ROOT } @@ -123,12 +124,17 @@ export const generatePipelines = ( .toString() .trim(); + console.log(`Merge base: ${mergeBase}`); + const changedFilesOutput = execSync(`git diff --name-only ${mergeBase}`, { cwd: PROJECT_ROOT }).toString().trim(); changedFiles = changedFilesOutput .split("\n") .map((x) => x.trim()) .filter((x) => x); + + console.log("Changed files (first 50):"); + console.log(changedFiles.slice(0, 50).join("\n")); } let filters: ((pipeline: EsPipeline) => boolean)[] = [