Skip to content

Commit

Permalink
[QA][Code Coverage] Teams Lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Sep 3, 2020
1 parent c3b5614 commit 9b735d4
Show file tree
Hide file tree
Showing 32 changed files with 15,058 additions and 474 deletions.
10 changes: 7 additions & 3 deletions .ci/Jenkinsfile_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ kibanaPipeline(timeoutMinutes: 240) {
]) {
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
catchError {
// kibanaTeamAssign.generateCodeOwners('.github/CODEOWNERS', "### Generate CODEOWNERS")
kibanaCoverage.runTests()
kibanaTeamAssign.load('team_assignment', "### Upload Team Assignment JSON")
handleIngestion(TIME_STAMP)
}
handleFail()
Expand All @@ -30,7 +30,7 @@ def handleIngestion(timestamp) {
kibanaCoverage.collectVcsInfo("### Collect VCS Info")
kibanaCoverage.generateReports("### Merge coverage reports")
kibanaCoverage.uploadCombinedReports()
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, '### Ingest && Upload')
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), '### Ingest && Upload')
kibanaCoverage.uploadCoverageStaticSite(timestamp)
}

Expand All @@ -42,11 +42,15 @@ def handlePreviousSha() {

def handleFail() {
def buildStatus = buildUtils.getBuildStatus()
if(params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
if (params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
slackNotifications.sendFailedBuild(
channel: '#kibana-qa',
username: 'Kibana QA'
)
}
}

def teamAssignmentsPath() {
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
}

581 changes: 317 additions & 264 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions packages/kbn-dev-utils/src/code_ownership/ownership_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export const rules: OwnershipRule[] = [
coverageOwner: 'kibana-alerting-services',
},
{
files: ['/x-pack/legacy/plugins/reporting', '/x-pack/plugins/reporting'],
files: ['x-pack/legacy/plugins/reporting', 'x-pack/plugins/reporting'],
excludeFiles: [],
codeOwner: '@elastic/kibana-reporting',
coverageOwner: 'kibana-reporting',
Expand All @@ -528,7 +528,7 @@ export const rules: OwnershipRule[] = [
coverageOwner: 'logstash',
},
{
files: ['/x-pack/plugins/enterprise_search/', '/x-pack/test/functional_enterprise_search/'],
files: ['x-pack/plugins/enterprise_search/', 'x-pack/test/functional_enterprise_search/'],
excludeFiles: [],
codeOwner: '@elastic/app-search-frontend',
coverageOwner: 'app-search-frontend',
Expand Down Expand Up @@ -641,43 +641,43 @@ export const rules: OwnershipRule[] = [
coverageOwner: 'kibana-design',
},
{
files: ['/packages/kbn-ui-framework/'],
files: ['packages/kbn-ui-framework/'],
excludeFiles: [],
coverageOwner: 'kibana-design',
},
{
files: [
'/src/plugins/dashboard/**/*.scss',
'/x-pack/plugins/canvas/**/*.scss',
'/src/legacy/core_plugins/kibana/public/home/**/*.scss',
'/x-pack/legacy/plugins/security/**/*.scss',
'/x-pack/legacy/plugins/spaces/**/*.scss',
'/x-pack/plugins/spaces/**/*.scss',
'/x-pack/plugins/security/**/*.scss',
'src/plugins/dashboard/**/*.scss',
'x-pack/plugins/canvas/**/*.scss',
'src/legacy/core_plugins/kibana/public/home/**/*.scss',
'x-pack/legacy/plugins/security/**/*.scss',
'x-pack/legacy/plugins/spaces/**/*.scss',
'x-pack/plugins/spaces/**/*.scss',
'x-pack/plugins/security/**/*.scss',
],
excludeFiles: [],
codeOwner: '@elastic/kibana-core-ui-designers',
coverageOwner: 'kibana-core-ui-designers',
},
{
files: [
'/x-pack/plugins/apm/**/*.scss',
'/x-pack/plugins/infra/**/*.scss',
'/x-pack/plugins/ingest_manager/**/*.scss',
'/x-pack/plugins/observability/**/*.scss',
'x-pack/plugins/apm/**/*.scss',
'x-pack/plugins/infra/**/*.scss',
'x-pack/plugins/ingest_manager/**/*.scss',
'x-pack/plugins/observability/**/*.scss',
],
excludeFiles: [],
codeOwner: '@elastic/observability-design',
coverageOwner: 'observability-design',
},
{
files: ['/x-pack/plugins/enterprise_search/**/*.scss'],
files: ['x-pack/plugins/enterprise_search/**/*.scss'],
excludeFiles: [],
codeOwner: '@elastic/ent-search-design',
coverageOwner: 'ent-search-design',
},
{
files: ['/x-pack/plugins/endpoint/**/*.scss', '/x-pack/plugins/security_solution/**/*.scss'],
files: ['x-pack/plugins/endpoint/**/*.scss', 'x-pack/plugins/security_solution/**/*.scss'],
excludeFiles: [],
codeOwner: '@elastic/security-design',
coverageOwner: 'security-design',
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ export * from './simple_kibana_platform_plugin_discovery';
export * from './streams';
export * from './babel';
export * from './parse_kibana_platform_plugin';
export { rules } from './code_ownership/ownership_config';
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
*/

require('../src/setup_node_env');
require('../src/dev/code_coverage/ingest_coverage/team_assignment').uploadTeamAssignmentJson();
require('../src/dev/code_coverage/ingest_coverage/team_assignment/').generateTeamAssignments();
16 changes: 15 additions & 1 deletion src/dev/code_coverage/ingest_coverage/__tests__/either.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe(`either datatype functions`, () => {
expect(sut.inspect()).to.be('Right(undefined)');
});
});
describe(`'fromNullable`, () => {
describe(`fromNullable`, () => {
it(`should continue processing if a truthy is calculated`, () => {
attempt({ detail: 'x' }).fold(
() => {},
Expand All @@ -64,4 +64,18 @@ describe(`either datatype functions`, () => {
attempt(false).fold(expectNull, () => {});
});
});
describe(`predicate fns`, () => {
it(`right.isRight() is true`, () => {
expect(Either.right('a').isRight()).to.be(true);
});
it(`right.isLeft() is false`, () => {
expect(Either.right('a').isLeft()).to.be(false);
});
it(`left.isLeft() is true`, () => {
expect(Either.left().isLeft()).to.be(true);
});
it(`left.isRight() is true`, () => {
expect(Either.left().isRight()).to.be(false);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
import { resolve } from 'path';
import { ToolingLog } from '@kbn/dev-utils';

const ROOT = resolve(__dirname, '../../../../..');
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout,
});

describe(`enumeratePatterns`, () => {
it(`should enumerate`, () => {
const res = enumeratePatterns(ROOT)(log)(patternsMap());
const actual = res[0][0];
expect(actual).to.eql(expected()[0][0]);
});
it(`should not throw an unhandled error on a file path that is a glob, that expands to nothing`, () => {
const absoluteRoot = '/Users/tre/development/projects/kibana';
expect(
enumeratePatterns(absoluteRoot)(log)(
new Map([
[
'src/legacy/core_plugins/kibana/public/home/*.ts',
{
coverageOwner: 'kibana-core-ui',
excludeFiles: [],
},
],
])
)
).to.eql('');
});
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.js to kibana-reporting`, () => {
const actual = enumeratePatterns(ROOT)(log)(
new Map([
[
'x-pack/plugins/reporting',
{
coverageOwner: 'kibana-reporting',
excludeFiles: [],
},
],
])
);

expect(
actual[0].includes(
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
)
).to.be(true);
});
});

function patternsMap() {
return new Map([
[
'src/dev/code_coverage',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
[
'vars/kibanaCoverage.groovy',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
[
'vars/kibanaTeamAssign.groovy',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
]);
}

function expected() {
return [
[
'src/dev/code_coverage/ingest_coverage/constants.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/either.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/index.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest-coverage_wallaby.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest_helpers.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/integration_tests/ingest_coverage.test.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/json_stream.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/matching.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/maybe.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/process.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/enumerate_patterns.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/enumeration_helpers.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/flush.ts kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_assignments.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_patterns.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/get_data.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/index.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/transforms.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/utils.js kibana-qa',
'src/dev/code_coverage/nyc_config/nyc.functional.config.js kibana-qa',
'src/dev/code_coverage/nyc_config/nyc.jest.config.js kibana-qa',
],
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { isExcluded, tryPath } from '../team_assignment/enumeration_helpers';

describe(`enumeration helper fns`, () => {
describe(`isExcluded`, () => {
it(`should exclude exclusions`, () => {
expect(
isExcluded('src/dev/code_coverage/nyc_config/nyc.jest.config.js', [
'src/dev/code_coverage/nyc_config',
])
).to.be(true);
});
});
describe(`tryPath`, () => {
describe(`w/o glob file paths`, () => {
it(`should return a right on an existing path`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/ingest.js';
const actual = tryPath(aPath);
expect(actual.isRight()).to.be(true);
});
it(`should return a left on a non existing path`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/does_not_exist.js';
const actual = tryPath(aPath);
expect(actual.isLeft()).to.be(true);
});
});
describe(`with glob file paths`, () => {
it(`should not error when the glob expands to nothing, but instead return a Left`, () => {
const aPath = 'src/legacy/core_plugins/kibana/public/home/*.ts';
const actual = tryPath(aPath);
expect(actual.isLeft()).to.be(true);
});
it(`should return a right on a glob that does indeed expand`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/*.js';
const actual = tryPath(aPath);
expect(actual.isRight()).to.be(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
*/

import expect from '@kbn/expect';
import { maybeTeamAssign, whichIndex } from '../ingest_helpers';
import {
TOTALS_INDEX,
RESEARCH_TOTALS_INDEX,
RESEARCH_COVERAGE_INDEX,
// COVERAGE_INDEX,
} from '../constants';
import { whichIndex } from '../ingest_helpers';
import { TOTALS_INDEX, RESEARCH_TOTALS_INDEX, RESEARCH_COVERAGE_INDEX } from '../constants';

describe(`Ingest Helper fns`, () => {
describe(`whichIndex`, () => {
Expand Down Expand Up @@ -56,20 +51,4 @@ describe(`Ingest Helper fns`, () => {
});
});
});
describe(`maybeTeamAssign`, () => {
describe(`against a coverage index`, () => {
it(`should have the pipeline prop`, () => {
const actual = maybeTeamAssign(true, { a: 'blah' });
expect(actual).to.have.property('pipeline');
});
});
describe(`against a totals index`, () => {
describe(`for "prod"`, () => {
it(`should not have the pipeline prop`, () => {
const actual = maybeTeamAssign(false, { b: 'blah' });
expect(actual).not.to.have.property('pipeline');
});
});
});
});
});
Loading

0 comments on commit 9b735d4

Please sign in to comment.