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

[CI] Remove unwanted console.log from pipeline.ts #204724

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .buildkite/pipeline-utils/buildkite/emitPipeline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export function emitPipeline(pipelineStr: string) {
console.log(pipelineStr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we convert to Set to remove duplicates here as well?

}
1 change: 1 addition & 0 deletions .buildkite/pipeline-utils/buildkite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from './client';
export * from './types';
export * from './emitPipeline';
23 changes: 18 additions & 5 deletions .buildkite/scripts/pipelines/pull_request/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

/* eslint "no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(warn|error)$/]",
"message": "Debug logging to stdout in this file will attempt to upload the log message as yaml to buildkite, which might result in pipeline syntax error. Use emitPipeline() to upload steps, or log to stderr."
}
] */

import fs from 'fs';
import prConfigs from '../../../pull_requests.json';
import { areChangesSkippable, doAnyChangesMatch, getAgentImageConfig } from '#pipeline-utils';
import {
areChangesSkippable,
doAnyChangesMatch,
getAgentImageConfig,
emitPipeline,
} from '#pipeline-utils';

const prConfig = prConfigs.jobs.find((job) => job.pipelineSlug === 'kibana-pull-request');
const emptyStep = `steps: []`;
Expand All @@ -35,7 +48,7 @@ const getPipeline = (filename: string, removeSteps = true) => {
const skippable = await areChangesSkippable(SKIPPABLE_PR_MATCHERS, REQUIRED_PATHS);

if (skippable) {
console.log(emptyStep);
emitPipeline(emptyStep);
return;
}

Expand All @@ -44,8 +57,8 @@ const getPipeline = (filename: string, removeSteps = true) => {
const onlyRunQuickChecks = await areChangesSkippable([/^renovate\.json$/], REQUIRED_PATHS);
if (onlyRunQuickChecks) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/renovate.yml', false));

console.log([...new Set(pipeline)].join('\n'));
console.warn('Isolated changes to renovate.json. Skipping main PR pipeline.');
emitPipeline([...new Set(pipeline)].join('\n'));
return;
}

Expand Down Expand Up @@ -399,7 +412,7 @@ const getPipeline = (filename: string, removeSteps = true) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml'));

// remove duplicated steps
console.log([...new Set(pipeline)].join('\n'));
emitPipeline([...new Set(pipeline)].join('\n'));
} catch (ex) {
console.error('Error while generating the pipeline steps: ' + ex.message, ex);
process.exit(1);
Expand Down