Skip to content

Commit

Permalink
Merge branch 'master' into feat/upgrade-ecs-8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 4, 2021
2 parents 9aa8e46 + abffa79 commit 03fb865
Show file tree
Hide file tree
Showing 833 changed files with 18,654 additions and 15,780 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipelines/es_snapshots/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution and Plugins
agents:
queue: c2-8
queue: c2-16
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/pipelines/hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:
- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution and Plugins
agents:
queue: c2-8
queue: c2-16
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"

Expand Down
11 changes: 11 additions & 0 deletions .buildkite/pipelines/pull_request/apm_cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/apm_cypress.sh
label: 'APM Cypress Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1
155 changes: 155 additions & 0 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
steps:
- command: .buildkite/scripts/lifecycle/pre_build.sh
label: Pre-Build

- wait

- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution and Plugins
agents:
queue: c2-16
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"

- command: .buildkite/scripts/steps/functional/xpack_cigroup.sh
label: 'Default CI Group'
parallelism: 13
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
key: default-cigroup
retry:
automatic:
- exit_status: '*'
limit: 1

- command: CI_GROUP=Docker .buildkite/scripts/steps/functional/xpack_cigroup.sh
label: 'Docker CI Group'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
key: default-cigroup-docker
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/oss_cigroup.sh
label: 'OSS CI Group'
parallelism: 11
agents:
queue: ci-group-4d
depends_on: build
timeout_in_minutes: 120
key: oss-cigroup
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/oss_accessibility.sh
label: 'OSS Accessibility Tests'
agents:
queue: ci-group-4d
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/xpack_accessibility.sh
label: 'Default Accessibility Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/oss_firefox.sh
label: 'OSS Firefox Tests'
agents:
queue: ci-group-4d
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/xpack_firefox.sh
label: 'Default Firefox Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/oss_misc.sh
label: 'OSS Misc Functional Tests'
agents:
queue: ci-group-4d
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/functional/xpack_saved_object_field_metrics.sh
label: 'Saved Object Field Metrics'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/test/jest_integration.sh
label: 'Jest Integration Tests'
agents:
queue: n2-4
timeout_in_minutes: 120
key: jest-integration

- command: .buildkite/scripts/steps/test/api_integration.sh
label: 'API Integration Tests'
agents:
queue: n2-2
timeout_in_minutes: 120
key: api-integration

- command: .buildkite/scripts/steps/test/jest.sh
label: 'Jest Tests'
agents:
queue: c2-16
timeout_in_minutes: 120
key: jest

- command: .buildkite/scripts/steps/lint.sh
label: 'Linting'
agents:
queue: n2-2
key: linting

- command: .buildkite/scripts/steps/checks.sh
label: 'Checks'
agents:
queue: c2-4
key: checks

- command: .buildkite/scripts/steps/storybooks/build_and_upload.sh
label: 'Build Storybooks'
agents:
queue: c2-4
key: storybooks
6 changes: 6 additions & 0 deletions .buildkite/pipelines/pull_request/post_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- wait: ~
continue_on_failure: true

- command: .buildkite/scripts/lifecycle/post_build.sh
label: Post-Build
11 changes: 11 additions & 0 deletions .buildkite/pipelines/pull_request/security_solution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/security_solution.sh
label: 'Security Solution Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1
10 changes: 9 additions & 1 deletion .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ if is_pr; then
export ghprbActualCommit="$BUILDKITE_COMMIT"
export BUILD_URL="$BUILDKITE_BUILD_URL"

# set_git_merge_base # TODO for PRs
set_git_merge_base

# For backwards compatibility
export PR_MERGE_BASE="$GITHUB_PR_MERGE_BASE"
export PR_TARGET_BRANCH="$GITHUB_PR_TARGET_BRANCH"
else
export ELASTIC_APM_ACTIVE=true
export CHECKS_REPORTER_ACTIVE=false
fi

# These are for backwards-compatibility
export GIT_COMMIT="${BUILDKITE_COMMIT:-}"
export GIT_BRANCH="${BUILDKITE_BRANCH:-}"

export FLEET_PACKAGE_REGISTRY_PORT=6104
export TEST_CORS_SERVER_PORT=6105

Expand Down
12 changes: 12 additions & 0 deletions .buildkite/scripts/common/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,15 @@ retry() {
fi
done
}

set_git_merge_base() {
GITHUB_PR_MERGE_BASE="$(buildkite-agent meta-data get merge-base --default '')"

if [[ ! "$GITHUB_PR_MERGE_BASE" ]]; then
git fetch origin "$GITHUB_PR_TARGET_BRANCH"
GITHUB_PR_MERGE_BASE="$(git merge-base HEAD FETCH_HEAD)"
buildkite-agent meta-data set merge-base "$GITHUB_PR_MERGE_BASE"
fi

export GITHUB_PR_MERGE_BASE
}
9 changes: 9 additions & 0 deletions .buildkite/scripts/lifecycle/post_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ export BUILD_SUCCESSFUL
"$(dirname "${0}")/commit_status_complete.sh"

node "$(dirname "${0}")/ci_stats_complete.js"

if [[ "${GITHUB_PR_NUMBER:-}" ]]; then
DOCS_CHANGES_URL="https://kibana_$GITHUB_PR_NUMBER}.docs-preview.app.elstc.co/diff"
DOCS_CHANGES=$(curl --connect-timeout 10 -m 10 -sf "$DOCS_CHANGES_URL" || echo '')

if [[ "$DOCS_CHANGES" && "$DOCS_CHANGES" != "There aren't any differences!" ]]; then
buildkite-agent meta-data set pr_comment:docs_changes:head "* [Documentation Changes](${DOCS_CHANGES_URL})"
fi
fi
1 change: 1 addition & 0 deletions .buildkite/scripts/packer_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -euo pipefail

source .buildkite/scripts/common/util.sh
source .buildkite/scripts/common/env.sh
source .buildkite/scripts/common/setup_node.sh

Expand Down
84 changes: 84 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const execSync = require('child_process').execSync;
const fs = require('fs');
const { areChangesSkippable, doAnyChangesMatch } = require('kibana-buildkite-library');

const SKIPPABLE_PATHS = [
/^docs\//,
/^rfcs\//,
/^.ci\/.+\.yml$/,
/^.ci\/es-snapshots\//,
/^.ci\/pipeline-library\//,
/^.ci\/Jenkinsfile_[^\/]+$/,
/^\.github\//,
/\.md$/,
/^\.backportrc\.json$/,
];

const REQUIRED_PATHS = [
// this file is auto-generated and changes to it need to be validated with CI
/^docs\/developer\/plugin-list.asciidoc$/,
// don't skip CI on prs with changes to plugin readme files /i is for case-insensitive matching
/\/plugins\/[^\/]+\/readme\.(md|asciidoc)$/i,
];

const getPipeline = (filename, removeSteps = true) => {
const str = fs.readFileSync(filename).toString();
return removeSteps ? str.replace(/^steps:/, '') : str;
};

const uploadPipeline = (pipelineContent) => {
const str =
typeof pipelineContent === 'string' ? pipelineContent : JSON.stringify(pipelineContent);

execSync('buildkite-agent pipeline upload', {
input: str,
stdio: ['pipe', 'inherit', 'inherit'],
});
};

(async () => {
try {
const skippable = await areChangesSkippable(SKIPPABLE_PATHS, 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);
}

const pipeline = [];

pipeline.push(getPipeline('.buildkite/pipelines/pull_request/base.yml', false));

if (
await doAnyChangesMatch([
/^x-pack\/plugins\/security_solution/,
/^x-pack\/test\/security_solution_cypress/,
/^x-pack\/plugins\/triggers_actions_ui\/public\/application\/sections\/action_connector_form/,
/^x-pack\/plugins\/triggers_actions_ui\/public\/application\/context\/actions_connectors_context\.tsx/,
])
) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/security_solution.yml'));
}

// Disabled for now, these are failing/disabled in Jenkins currently as well
// if (
// await doAnyChangesMatch([
// /^x-pack\/plugins\/apm/,
// ])
// ) {
// pipeline.push(getPipeline('.buildkite/pipelines/pull_request/apm_cypress.yml'));
// }

pipeline.push(getPipeline('.buildkite/pipelines/pull_request/post_build.yml'));

uploadPipeline(pipeline.join('\n'));
} catch (ex) {
console.error('PR pipeline generation error', ex.message);
process.exit(1);
}
})();
5 changes: 5 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -euo pipefail

node .buildkite/scripts/pipelines/pull_request/pipeline.js
14 changes: 14 additions & 0 deletions .buildkite/scripts/steps/functional/apm_cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/steps/functional/common.sh

export JOB=kibana-apm-cypress

echo "--- APM Cypress Tests"

cd "$XPACK_DIR"

checks-reporter-with-killswitch "APM Cypress Tests" \
node plugins/apm/scripts/test/e2e.js
17 changes: 17 additions & 0 deletions .buildkite/scripts/steps/functional/security_solution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/steps/functional/common.sh

export JOB=kibana-security-solution-chrome

echo "--- Security Solution tests (Chrome)"

cd "$XPACK_DIR"

checks-reporter-with-killswitch "Security Solution Cypress Tests (Chrome)" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config test/security_solution_cypress/cli_config.ts
Loading

0 comments on commit 03fb865

Please sign in to comment.