Skip to content

Commit

Permalink
[buildkite] Add more logging and debug information to PR pipeline gen…
Browse files Browse the repository at this point in the history
…eration
  • Loading branch information
brianseeders committed Oct 11, 2023
1 parent 731c253 commit 08519aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .buildkite/scripts/pull-request/pipeline.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
3 changes: 3 additions & 0 deletions .buildkite/scripts/pull-request/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions .buildkite/scripts/pull-request/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,25 @@ 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 }
)
.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)[] = [
Expand Down

0 comments on commit 08519aa

Please sign in to comment.