Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 46511-alerting-poc
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Oct 2, 2019
2 parents f33df05 + bc840e6 commit 96ef0bd
Show file tree
Hide file tree
Showing 1,727 changed files with 43,943 additions and 30,600 deletions.
17 changes: 15 additions & 2 deletions .ci/jobs.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
JOB:
- intake
- firefoxSmoke
- kibana-intake
- x-pack-intake
- kibana-firefoxSmoke
- kibana-ciGroup1
- kibana-ciGroup2
- kibana-ciGroup3
- kibana-ciGroup4
- kibana-ciGroup5
- kibana-ciGroup6
- kibana-ciGroup7
- kibana-ciGroup8
- kibana-ciGroup9
- kibana-ciGroup10
- kibana-ciGroup11
- kibana-ciGroup12
# - kibana-visualRegression

# make sure all x-pack-ciGroups are listed in test/scripts/jenkins_xpack_ci_group.sh
- x-pack-firefoxSmoke
- x-pack-ciGroup1
- x-pack-ciGroup2
- x-pack-ciGroup3
- x-pack-ciGroup4
- x-pack-ciGroup5
- x-pack-ciGroup6
- x-pack-ciGroup7
- x-pack-ciGroup8
- x-pack-ciGroup9
- x-pack-ciGroup10
# - x-pack-visualRegression

# `~` is yaml for `null`
Expand Down
10 changes: 8 additions & 2 deletions .ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source src/dev/ci_setup/setup.sh
source src/dev/ci_setup/checkout_sibling_es.sh

case "$JOB" in
intake)
kibana-intake)
./test/scripts/jenkins_unit.sh
;;
kibana-ciGroup*)
Expand All @@ -21,16 +21,22 @@ kibana-ciGroup*)
kibana-visualRegression*)
./test/scripts/jenkins_visual_regression.sh
;;
firefoxSmoke*)
kibana-firefoxSmoke*)
./test/scripts/jenkins_firefox_smoke.sh
;;
x-pack-intake)
./test/scripts/jenkins_xpack.sh
;;
x-pack-ciGroup*)
export CI_GROUP="${JOB##x-pack-ciGroup}"
./test/scripts/jenkins_xpack_ci_group.sh
;;
x-pack-visualRegression*)
./test/scripts/jenkins_xpack_visual_regression.sh
;;
x-pack-firefoxSmoke*)
./test/scripts/jenkins_xpack_firefox_smoke.sh
;;
*)
echo "JOB '$JOB' is not implemented."
exit 1
Expand Down
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ module.exports = {
// typescript and javascript for front and back end
files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'],
plugins: ['eslint-plugin-node', 'react'],
env: {
mocha: true,
jest: true,
},
rules: {
'accessor-pairs': 'error',
'array-callback-return': 'error',
Expand Down Expand Up @@ -564,8 +568,7 @@ module.exports = {
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
// This will be turned on after bug fixes are mostly complete
// 'no-undef': 'warn',
'no-undef': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-useless-call': 'error',
Expand Down
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

# APM
/x-pack/legacy/plugins/apm/ @elastic/apm-ui
/x-pack/test/functional/apps/apm/ @elastic/apm-ui
/src/legacy/core_plugins/apm_oss/ @elastic/apm-ui

# Beats
/x-pack/legacy/plugins/beats_management/ @elastic/beats
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dashboardEmbeddableContainer": "src/legacy/core_plugins/dashboard_embeddable_container",
"kbn": "src/legacy/core_plugins/kibana",
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
"embeddableApi": "src/legacy/core_plugins/embeddable_api",
"embeddableApi": "src/plugins/embeddable",
"kbnVislibVisTypes": "src/legacy/core_plugins/kbn_vislib_vis_types",
"visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown",
"visTypeMetric": "src/legacy/core_plugins/vis_type_metric",
Expand Down
40 changes: 22 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
#!/bin/groovy

library 'kibana-pipeline-library'

stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a little bit
timeout(time: 180, unit: 'MINUTES') {
timestamps {
ansiColor('xterm') {
catchError {
parallel([
'intake-agent': legacyJobRunner('intake'),
'firefox-smoke-agent': legacyJobRunner('firefoxSmoke'),
'kibana-intake-agent': legacyJobRunner('kibana-intake'),
'x-pack-intake-agent': legacyJobRunner('x-pack-intake'),
'kibana-oss-agent': withWorkers('kibana-oss-tests', { buildOss() }, [
'oss-ciGroup1': getOssCiGroupWorker(1),
'oss-ciGroup2': getOssCiGroupWorker(2),
'oss-ciGroup3': getOssCiGroupWorker(3),
'oss-ciGroup4': getOssCiGroupWorker(4),
'oss-ciGroup5': getOssCiGroupWorker(5),
'oss-ciGroup6': getOssCiGroupWorker(6),
// 'oss-ciGroup7': getOssCiGroupWorker(7),
// 'oss-ciGroup8': getOssCiGroupWorker(8),
// 'oss-ciGroup9': getOssCiGroupWorker(9),
// 'oss-ciGroup10': getOssCiGroupWorker(10),
// 'oss-ciGroup11': getOssCiGroupWorker(11),
// 'oss-ciGroup12': getOssCiGroupWorker(12),
'oss-ciGroup7': getOssCiGroupWorker(7),
'oss-ciGroup8': getOssCiGroupWorker(8),
'oss-ciGroup9': getOssCiGroupWorker(9),
'oss-ciGroup10': getOssCiGroupWorker(10),
'oss-ciGroup11': getOssCiGroupWorker(11),
'oss-ciGroup12': getOssCiGroupWorker(12),
'oss-firefoxSmoke': getPostBuildWorker('firefoxSmoke', { runbld './test/scripts/jenkins_firefox_smoke.sh' }),
// 'oss-visualRegression': getPostBuildWorker('visualRegression', { runbld './test/scripts/jenkins_visual_regression.sh' }),
// 'oss-firefoxSmoke': getPostBuildWorker('firefoxSmoke', { runbld './test/scripts/jenkins_firefox_smoke.sh' }),
]),
'kibana-xpack-agent': withWorkers('kibana-xpack-tests', { buildXpack() }, [
'xpack-ciGroup1': getXpackCiGroupWorker(1),
'xpack-ciGroup2': getXpackCiGroupWorker(2),
'xpack-ciGroup3': getXpackCiGroupWorker(3),
'xpack-ciGroup4': getXpackCiGroupWorker(4),
'xpack-ciGroup5': getXpackCiGroupWorker(5),
// 'xpack-ciGroup6': getXpackCiGroupWorker(6),
// 'xpack-ciGroup7': getXpackCiGroupWorker(7),
// 'xpack-ciGroup8': getXpackCiGroupWorker(8),
// 'xpack-ciGroup9': getXpackCiGroupWorker(9),
// 'xpack-ciGroup10': getXpackCiGroupWorker(10),
// 'xpack-firefoxSmoke': getPostBuildWorker('xpack-firefoxSmoke', { runbld './test/scripts/jenkins_xpack_firefox_smoke.sh' }),
'xpack-ciGroup6': getXpackCiGroupWorker(6),
'xpack-ciGroup7': getXpackCiGroupWorker(7),
'xpack-ciGroup8': getXpackCiGroupWorker(8),
'xpack-ciGroup9': getXpackCiGroupWorker(9),
'xpack-ciGroup10': getXpackCiGroupWorker(10),
'xpack-firefoxSmoke': getPostBuildWorker('xpack-firefoxSmoke', { runbld './test/scripts/jenkins_xpack_firefox_smoke.sh' }),
// 'xpack-visualRegression': getPostBuildWorker('xpack-visualRegression', { runbld './test/scripts/jenkins_xpack_visual_regression.sh' }),
]),
])
Expand Down Expand Up @@ -109,6 +111,7 @@ def getPostBuildWorker(name, closure) {
"TEST_KIBANA_URL=http://elastic:changeme@localhost:${kibanaPort}",
"TEST_ES_URL=http://elastic:changeme@localhost:${esPort}",
"TEST_ES_TRANSPORT_PORT=${esTransportPort}",
"IS_PIPELINE_JOB=1",
]) {
closure()
}
Expand Down Expand Up @@ -171,7 +174,6 @@ def jobRunner(label, closure) {

withEnv([
"CI=true",
"IS_PIPELINE_JOB=1",
"HOME=${env.JENKINS_HOME}",
"PR_SOURCE_BRANCH=${env.ghprbSourceBranch ?: ''}",
"PR_TARGET_BRANCH=${env.ghprbTargetBranch ?: ''}",
Expand Down Expand Up @@ -246,10 +248,12 @@ def sendInfraMail() {

def sendKibanaMail() {
catchError {
if(params.NOTIFY_ON_FAILURE && currentBuild.result != 'SUCCESS' && currentBuild.result != 'ABORTED') {
def buildStatus = buildUtils.getBuildStatus()

if(params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED') {
emailext(
to: 'build-kibana@elastic.co',
subject: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - ${currentBuild.result}",
subject: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - ${buildStatus}",
body: '${SCRIPT,template="groovy-html.template"}',
mimeType: 'text/html',
)
Expand Down
165 changes: 3 additions & 162 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ Check out [TYPESCRIPT.md](TYPESCRIPT.md) for help with this process.
You should prefer modern language features in a lot of cases, e.g.:
* Prefer `class` over `prototype` inheritance
* Prefer arrow function over function expressions
* Prefer arrow function over storing `this` (no `const self = this;`)
* Prefer template strings over string concatenation
* Prefer the spread operator for copying arrays (`[...arr]`) over `arr.slice()`
### Avoid mutability and state
Expand Down Expand Up @@ -211,37 +214,6 @@ const first = arr[0];
const second = arr[1];
```
### Declare one variable per line, wherever it makes the most sense
This makes it easier to re-order the lines. However, declari variables
wherever it makes sense (not necessairly on the top of a function).
```js
// good
const keys = ['foo', 'bar'];
const values = [23, 42];

// bad
const keys = ['foo', 'bar'],
values = [23, 42];
```
### Prefix private class methods with an underscore `JS only`
Identifying private class methods makes it easier to differentiate a class's public and internal
APIs, and makes private methods easier to mark as `private` when the code is migrated to TypeScript.
```js
// good
class BankAccount {
addFunds() {}

_calculateInterest() {}
}
```
If using TypeScript you should use the `private` modifier instead.
### Magic numbers/strings
These are numbers (or other values) simply used in line in your code. *Do not
Expand Down Expand Up @@ -319,100 +291,6 @@ import inSibling from '../foo/child';
Don't do this. Everything should be wrapped in a module that can be depended on
by other modules. Even things as simple as a single value should be a module.
### Function definitions
Use function declarations over function expressions, so that their names will
show up in stack traces, making errors easier to debug.
Also, keep function definitions above other code instead of relying on function
hoisting.
```js
// good
function myFunc() {
...
}

// bad
const myFunc = function () {
...
};
```
### Arrow functions
If you must use a function expression, then use an arrow function:
```js
// good
[1, 2, 3].map((n) => {
const m = doSomething(n);
return m - n;
});

// bad
[1, 2, 3].map(function (n) {
const m = doSomething(n);
return m - n;
});
```
If your arrow function is only returning an object literal, then wrap the
object in parentheses rather than using an explicit return:
```js
// good
() => ({
foo: 'bar'
})

// bad
() => {
return {
foo: 'bar'
};
}
```
### Object / Array iterations, transformations and operations
Use native methods to iterate and transform arrays and objects where possible.
Avoid `for` and `while` loops as they introduce the possibility of infinite
loops and break out of our preferred convention of declarative programming.
Use descriptive variable names in the closures.
Use a utility library as needed and where it will make code more
comprehensible.
```js
// best
const userNames = users.map(user => user.name);

// ok
import { pluck } from 'lodash';
const userNames = pluck(users, 'name');

// bad
const userNames = [];
for (let i = 0; i < users.length; i++) {
userNames.push(users[i].name);
}
```
### Use the spread operator (`...`) for copying arrays
This helps with expressiveness and readability.
```js
const arr = [1, 2, 3];

// good
const arrCopy = [...arr];

// bad
const arrCopy = arr.slice();
```
### Only use ternary operators for small, simple code
Expand All @@ -428,18 +306,6 @@ const foo = (a === b) ? 1 : 2;
const foo = (a === b) ? 1 : (a === c) ? 2 : 3;
```
### Do not extend built-in prototypes
Do not extend the prototype of native JavaScript objects. Your future self will
be forever grateful.
```js
// bad
Array.prototype.empty = function () {
return !this.length;
}
```
### Use descriptive conditions
Any non-trivial conditions should be converted to functions or assigned to
Expand Down Expand Up @@ -624,31 +490,6 @@ if (isSessionValid) {
}
```

### Do not alias `this`

Try not to rely on `this` at all, but if you must, then use arrow functions
instead of aliasing it.

```js
// good
class Users {
add(user) {
return createUser(user)
.then(response => this.users.push(response.user));
}
}

// bad
class Users {
add(user) {
const self = this;
return createUser(user).then(function (response) {
self.users.push(response.user);
});
}
}
```

### Getters and Setters

Feel free to use getters that are free from [side effects][sideeffect], like
Expand Down
Loading

0 comments on commit 96ef0bd

Please sign in to comment.