[CI] Prevent skippable changes pr break (#188740)

## Summary
Closes: https://github.com/elastic/kibana-operations/issues/159
This commit is contained in:
Alex Szabo 2024-07-22 15:32:53 +02:00 committed by GitHub
parent a8091ab0ac
commit 03148d203f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,12 +6,12 @@
* Side Public License, v 1.
*/
import { execSync } from 'child_process';
import fs from 'fs';
import prConfigs from '../../../pull_requests.json';
import { areChangesSkippable, doAnyChangesMatch, getAgentImageConfig } from '#pipeline-utils';
const prConfig = prConfigs.jobs.find((job) => job.pipelineSlug === 'kibana-pull-request');
const emptyStep = `steps: []`;
if (!prConfig) {
console.error(`'kibana-pull-request' pipeline not found in .buildkite/pull_requests.json`);
@ -28,21 +28,16 @@ const getPipeline = (filename: string, removeSteps = true) => {
};
(async () => {
const pipeline: string[] = [];
try {
const skippable = await areChangesSkippable(SKIPPABLE_PR_MATCHERS, REQUIRED_PATHS);
if (skippable) {
console.log('All changes in PR are skippable. Skipping CI.');
// Since we skip everything, including post-build, we need to at least make sure the commit status gets set
execSync('BUILD_SUCCESSFUL=true .buildkite/scripts/lifecycle/commit_status_complete.sh', {
stdio: 'inherit',
});
process.exit(0);
console.log(emptyStep);
return;
}
const pipeline = [];
pipeline.push(getAgentImageConfig({ returnYaml: true }));
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/base.yml', false));