mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
[buildkite] Add more logging and debug information to PR pipeline generation (#100709)
This commit is contained in:
parent
731c253058
commit
81a441e636
4 changed files with 182 additions and 149 deletions
|
@ -3,6 +3,8 @@
|
||||||
exports[`generatePipelines should generate correct pipelines with a non-docs change 1`] = `
|
exports[`generatePipelines should generate correct pipelines with a non-docs change 1`] = `
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"name": "bwc-snapshots",
|
||||||
|
"pipeline": {
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"group": "bwc-snapshots",
|
"group": "bwc-snapshots",
|
||||||
|
@ -34,7 +36,10 @@ exports[`generatePipelines should generate correct pipelines with a non-docs cha
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
|
"name": "using-defaults",
|
||||||
|
"pipeline": {
|
||||||
"env": {
|
"env": {
|
||||||
"CUSTOM_ENV_VAR": "value",
|
"CUSTOM_ENV_VAR": "value",
|
||||||
},
|
},
|
||||||
|
@ -45,12 +50,15 @@ exports[`generatePipelines should generate correct pipelines with a non-docs cha
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generatePipelines should generate correct pipelines with only docs changes 1`] = `
|
exports[`generatePipelines should generate correct pipelines with only docs changes 1`] = `
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"name": "docs-check",
|
||||||
|
"pipeline": {
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"agents": {
|
"agents": {
|
||||||
|
@ -65,12 +73,15 @@ exports[`generatePipelines should generate correct pipelines with only docs chan
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generatePipelines should generate correct pipelines with full BWC expansion 1`] = `
|
exports[`generatePipelines should generate correct pipelines with full BWC expansion 1`] = `
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"name": "full-bwc",
|
||||||
|
"pipeline": {
|
||||||
"steps": [
|
"steps": [
|
||||||
{
|
{
|
||||||
"group": "bwc",
|
"group": "bwc",
|
||||||
|
@ -154,7 +165,10 @@ exports[`generatePipelines should generate correct pipelines with full BWC expan
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
|
"name": "using-defaults",
|
||||||
|
"pipeline": {
|
||||||
"env": {
|
"env": {
|
||||||
"CUSTOM_ENV_VAR": "value",
|
"CUSTOM_ENV_VAR": "value",
|
||||||
},
|
},
|
||||||
|
@ -165,12 +179,15 @@ exports[`generatePipelines should generate correct pipelines with full BWC expan
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`generatePipelines should generate correct pipeline when using a trigger comment for it 1`] = `
|
exports[`generatePipelines should generate correct pipeline when using a trigger comment for it 1`] = `
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"name": "using-defaults",
|
||||||
|
"pipeline": {
|
||||||
"env": {
|
"env": {
|
||||||
"CUSTOM_ENV_VAR": "value",
|
"CUSTOM_ENV_VAR": "value",
|
||||||
},
|
},
|
||||||
|
@ -181,5 +198,6 @@ exports[`generatePipelines should generate correct pipeline when using a trigger
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -6,13 +6,19 @@ import { generatePipelines } from "./pipeline";
|
||||||
const pipelines = generatePipelines();
|
const pipelines = generatePipelines();
|
||||||
|
|
||||||
for (const pipeline of pipelines) {
|
for (const pipeline of pipelines) {
|
||||||
if (!process.env.CI) {
|
const yaml = stringify(pipeline.pipeline);
|
||||||
// Just for local debugging purposes
|
|
||||||
|
console.log(`--- Generated pipeline: ${pipeline.name}`);
|
||||||
|
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("");
|
console.log("");
|
||||||
console.log(stringify(pipeline));
|
console.log("Uploading pipeline...");
|
||||||
} else {
|
|
||||||
execSync(`buildkite-agent pipeline upload`, {
|
execSync(`buildkite-agent pipeline upload`, {
|
||||||
input: stringify(pipeline),
|
input: yaml,
|
||||||
stdio: ["pipe", "inherit", "inherit"],
|
stdio: ["pipe", "inherit", "inherit"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,8 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo --- Installing bun
|
||||||
npm install -g bun
|
npm install -g bun
|
||||||
|
|
||||||
|
echo --- Generating pipeline
|
||||||
bun .buildkite/scripts/pull-request/pipeline.generate.ts
|
bun .buildkite/scripts/pull-request/pipeline.generate.ts
|
||||||
|
|
|
@ -116,6 +116,7 @@ export const generatePipelines = (
|
||||||
.filter((x) => x);
|
.filter((x) => x);
|
||||||
|
|
||||||
if (!changedFiles?.length) {
|
if (!changedFiles?.length) {
|
||||||
|
console.log("Doing git fetch and getting merge-base");
|
||||||
const mergeBase = execSync(
|
const mergeBase = execSync(
|
||||||
`git fetch origin ${process.env["GITHUB_PR_TARGET_BRANCH"]}; git merge-base origin/${process.env["GITHUB_PR_TARGET_BRANCH"]} HEAD`,
|
`git fetch origin ${process.env["GITHUB_PR_TARGET_BRANCH"]}; git merge-base origin/${process.env["GITHUB_PR_TARGET_BRANCH"]} HEAD`,
|
||||||
{ cwd: PROJECT_ROOT }
|
{ cwd: PROJECT_ROOT }
|
||||||
|
@ -123,12 +124,17 @@ export const generatePipelines = (
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
|
console.log(`Merge base: ${mergeBase}`);
|
||||||
|
|
||||||
const changedFilesOutput = execSync(`git diff --name-only ${mergeBase}`, { cwd: PROJECT_ROOT }).toString().trim();
|
const changedFilesOutput = execSync(`git diff --name-only ${mergeBase}`, { cwd: PROJECT_ROOT }).toString().trim();
|
||||||
|
|
||||||
changedFiles = changedFilesOutput
|
changedFiles = changedFilesOutput
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((x) => x.trim())
|
.map((x) => x.trim())
|
||||||
.filter((x) => x);
|
.filter((x) => x);
|
||||||
|
|
||||||
|
console.log("Changed files (first 50):");
|
||||||
|
console.log(changedFiles.slice(0, 50).join("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let filters: ((pipeline: EsPipeline) => boolean)[] = [
|
let filters: ((pipeline: EsPipeline) => boolean)[] = [
|
||||||
|
@ -154,9 +160,9 @@ export const generatePipelines = (
|
||||||
pipelines.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
pipelines.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
||||||
|
|
||||||
const finalPipelines = pipelines.map((pipeline) => {
|
const finalPipelines = pipelines.map((pipeline) => {
|
||||||
const finalPipeline = { ...pipeline };
|
const finalPipeline = { name: pipeline.name, pipeline: { ...pipeline } };
|
||||||
delete finalPipeline.config;
|
delete finalPipeline.pipeline.config;
|
||||||
delete finalPipeline.name;
|
delete finalPipeline.pipeline.name;
|
||||||
|
|
||||||
return finalPipeline;
|
return finalPipeline;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue