Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[buildkite] Add more logging and debug information to PR pipeline generation #100709

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
300 changes: 159 additions & 141 deletions .buildkite/scripts/pull-request/__snapshots__/pipeline.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,183 +3,201 @@
exports[`generatePipelines should generate correct pipelines with a non-docs change 1`] = `
[
{
"steps": [
{
"group": "bwc-snapshots",
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dignore.tests.seed v{{matrix.BWC_VERSION}}#bwcTest",
"env": {
"BWC_VERSION": "{{matrix.BWC_VERSION}}",
},
"label": "{{matrix.BWC_VERSION}} / bwc-snapshots",
"matrix": {
"setup": {
"BWC_VERSION": [
"7.17.14",
"8.10.3",
"8.11.0",
],
"name": "bwc-snapshots",
"pipeline": {
"steps": [
{
"group": "bwc-snapshots",
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dignore.tests.seed v{{matrix.BWC_VERSION}}#bwcTest",
"env": {
"BWC_VERSION": "{{matrix.BWC_VERSION}}",
},
"label": "{{matrix.BWC_VERSION}} / bwc-snapshots",
"matrix": {
"setup": {
"BWC_VERSION": [
"7.17.14",
"8.10.3",
"8.11.0",
],
},
},
"timeout_in_minutes": 300,
},
"timeout_in_minutes": 300,
},
],
},
],
],
},
],
},
},
{
"env": {
"CUSTOM_ENV_VAR": "value",
},
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
"name": "using-defaults",
"pipeline": {
"env": {
"CUSTOM_ENV_VAR": "value",
},
],
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
},
],
},
},
]
`;

exports[`generatePipelines should generate correct pipelines with only docs changes 1`] = `
[
{
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
"name": "docs-check",
"pipeline": {
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dignore.tests.seed precommit :docs:check",
"label": "docs-check",
"timeout_in_minutes": 300,
},
"command": ".ci/scripts/run-gradle.sh -Dignore.tests.seed precommit :docs:check",
"label": "docs-check",
"timeout_in_minutes": 300,
},
],
],
},
},
]
`;

exports[`generatePipelines should generate correct pipelines with full BWC expansion 1`] = `
[
{
"steps": [
{
"group": "bwc",
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.0.0#bwcTest",
"env": {
"BWC_VERSION": "7.0.0",
},
"key": "full-bwc:7_0_0",
"label": "7.0.0 / bwc",
"timeout_in_minutes": 300,
},
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.0.1#bwcTest",
"env": {
"BWC_VERSION": "7.0.1",
},
"key": "full-bwc:7_0_1",
"label": "7.0.1 / bwc",
"timeout_in_minutes": 300,
},
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.1.0#bwcTest",
"env": {
"BWC_VERSION": "7.1.0",
"name": "full-bwc",
"pipeline": {
"steps": [
{
"group": "bwc",
"steps": [
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.0.0#bwcTest",
"env": {
"BWC_VERSION": "7.0.0",
},
"key": "full-bwc:7_0_0",
"label": "7.0.0 / bwc",
"timeout_in_minutes": 300,
},
"key": "full-bwc:7_1_0",
"label": "7.1.0 / bwc",
"timeout_in_minutes": 300,
},
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.0.1#bwcTest",
"env": {
"BWC_VERSION": "7.0.1",
},
"key": "full-bwc:7_0_1",
"label": "7.0.1 / bwc",
"timeout_in_minutes": 300,
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.10.0#bwcTest",
"env": {
"BWC_VERSION": "8.10.0",
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v7.1.0#bwcTest",
"env": {
"BWC_VERSION": "7.1.0",
},
"key": "full-bwc:7_1_0",
"label": "7.1.0 / bwc",
"timeout_in_minutes": 300,
},
"key": "full-bwc:8_10_0",
"label": "8.10.0 / bwc",
"timeout_in_minutes": 300,
},
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.10.0#bwcTest",
"env": {
"BWC_VERSION": "8.10.0",
},
"key": "full-bwc:8_10_0",
"label": "8.10.0 / bwc",
"timeout_in_minutes": 300,
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.11.0#bwcTest",
"env": {
"BWC_VERSION": "8.11.0",
{
"agents": {
"buildDirectory": "/dev/shm/bk",
"image": "family/elasticsearch-ubuntu-2004",
"machineType": "custom-32-98304",
"provider": "gcp",
},
"command": ".ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.11.0#bwcTest",
"env": {
"BWC_VERSION": "8.11.0",
},
"key": "full-bwc:8_11_0",
"label": "8.11.0 / bwc",
"timeout_in_minutes": 300,
},
"key": "full-bwc:8_11_0",
"label": "8.11.0 / bwc",
"timeout_in_minutes": 300,
},
],
},
],
],
},
],
},
},
{
"env": {
"CUSTOM_ENV_VAR": "value",
},
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
"name": "using-defaults",
"pipeline": {
"env": {
"CUSTOM_ENV_VAR": "value",
},
],
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
},
],
},
},
]
`;

exports[`generatePipelines should generate correct pipeline when using a trigger comment for it 1`] = `
[
{
"env": {
"CUSTOM_ENV_VAR": "value",
},
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
"name": "using-defaults",
"pipeline": {
"env": {
"CUSTOM_ENV_VAR": "value",
},
],
"steps": [
{
"command": "echo 'hello world'",
"label": "test-step",
},
],
},
},
]
`;
16 changes: 11 additions & 5 deletions .buildkite/scripts/pull-request/pipeline.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import { generatePipelines } from "./pipeline";
const pipelines = generatePipelines();

for (const pipeline of pipelines) {
if (!process.env.CI) {
// Just for local debugging purposes
const yaml = stringify(pipeline.pipeline);

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(stringify(pipeline));
} else {
console.log("Uploading pipeline...");

execSync(`buildkite-agent pipeline upload`, {
input: stringify(pipeline),
input: yaml,
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
Loading