Skip to content

Commit 9b735d4

Browse files
committed
[QA][Code Coverage] Teams Lookup
1 parent c3b5614 commit 9b735d4

32 files changed

+15058
-474
lines changed

.ci/Jenkinsfile_coverage

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ kibanaPipeline(timeoutMinutes: 240) {
1212
]) {
1313
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
1414
catchError {
15+
// kibanaTeamAssign.generateCodeOwners('.github/CODEOWNERS', "### Generate CODEOWNERS")
1516
kibanaCoverage.runTests()
16-
kibanaTeamAssign.load('team_assignment', "### Upload Team Assignment JSON")
1717
handleIngestion(TIME_STAMP)
1818
}
1919
handleFail()
@@ -30,7 +30,7 @@ def handleIngestion(timestamp) {
3030
kibanaCoverage.collectVcsInfo("### Collect VCS Info")
3131
kibanaCoverage.generateReports("### Merge coverage reports")
3232
kibanaCoverage.uploadCombinedReports()
33-
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, '### Ingest && Upload')
33+
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), '### Ingest && Upload')
3434
kibanaCoverage.uploadCoverageStaticSite(timestamp)
3535
}
3636

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

4343
def handleFail() {
4444
def buildStatus = buildUtils.getBuildStatus()
45-
if(params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
45+
if (params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
4646
slackNotifications.sendFailedBuild(
4747
channel: '#kibana-qa',
4848
username: 'Kibana QA'
4949
)
5050
}
5151
}
5252

53+
def teamAssignmentsPath() {
54+
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
55+
}
56+

.github/CODEOWNERS

Lines changed: 317 additions & 264 deletions
Large diffs are not rendered by default.

packages/kbn-dev-utils/src/code_ownership/ownership_config.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export const rules: OwnershipRule[] = [
510510
coverageOwner: 'kibana-alerting-services',
511511
},
512512
{
513-
files: ['/x-pack/legacy/plugins/reporting', '/x-pack/plugins/reporting'],
513+
files: ['x-pack/legacy/plugins/reporting', 'x-pack/plugins/reporting'],
514514
excludeFiles: [],
515515
codeOwner: '@elastic/kibana-reporting',
516516
coverageOwner: 'kibana-reporting',
@@ -528,7 +528,7 @@ export const rules: OwnershipRule[] = [
528528
coverageOwner: 'logstash',
529529
},
530530
{
531-
files: ['/x-pack/plugins/enterprise_search/', '/x-pack/test/functional_enterprise_search/'],
531+
files: ['x-pack/plugins/enterprise_search/', 'x-pack/test/functional_enterprise_search/'],
532532
excludeFiles: [],
533533
codeOwner: '@elastic/app-search-frontend',
534534
coverageOwner: 'app-search-frontend',
@@ -641,43 +641,43 @@ export const rules: OwnershipRule[] = [
641641
coverageOwner: 'kibana-design',
642642
},
643643
{
644-
files: ['/packages/kbn-ui-framework/'],
644+
files: ['packages/kbn-ui-framework/'],
645645
excludeFiles: [],
646646
coverageOwner: 'kibana-design',
647647
},
648648
{
649649
files: [
650-
'/src/plugins/dashboard/**/*.scss',
651-
'/x-pack/plugins/canvas/**/*.scss',
652-
'/src/legacy/core_plugins/kibana/public/home/**/*.scss',
653-
'/x-pack/legacy/plugins/security/**/*.scss',
654-
'/x-pack/legacy/plugins/spaces/**/*.scss',
655-
'/x-pack/plugins/spaces/**/*.scss',
656-
'/x-pack/plugins/security/**/*.scss',
650+
'src/plugins/dashboard/**/*.scss',
651+
'x-pack/plugins/canvas/**/*.scss',
652+
'src/legacy/core_plugins/kibana/public/home/**/*.scss',
653+
'x-pack/legacy/plugins/security/**/*.scss',
654+
'x-pack/legacy/plugins/spaces/**/*.scss',
655+
'x-pack/plugins/spaces/**/*.scss',
656+
'x-pack/plugins/security/**/*.scss',
657657
],
658658
excludeFiles: [],
659659
codeOwner: '@elastic/kibana-core-ui-designers',
660660
coverageOwner: 'kibana-core-ui-designers',
661661
},
662662
{
663663
files: [
664-
'/x-pack/plugins/apm/**/*.scss',
665-
'/x-pack/plugins/infra/**/*.scss',
666-
'/x-pack/plugins/ingest_manager/**/*.scss',
667-
'/x-pack/plugins/observability/**/*.scss',
664+
'x-pack/plugins/apm/**/*.scss',
665+
'x-pack/plugins/infra/**/*.scss',
666+
'x-pack/plugins/ingest_manager/**/*.scss',
667+
'x-pack/plugins/observability/**/*.scss',
668668
],
669669
excludeFiles: [],
670670
codeOwner: '@elastic/observability-design',
671671
coverageOwner: 'observability-design',
672672
},
673673
{
674-
files: ['/x-pack/plugins/enterprise_search/**/*.scss'],
674+
files: ['x-pack/plugins/enterprise_search/**/*.scss'],
675675
excludeFiles: [],
676676
codeOwner: '@elastic/ent-search-design',
677677
coverageOwner: 'ent-search-design',
678678
},
679679
{
680-
files: ['/x-pack/plugins/endpoint/**/*.scss', '/x-pack/plugins/security_solution/**/*.scss'],
680+
files: ['x-pack/plugins/endpoint/**/*.scss', 'x-pack/plugins/security_solution/**/*.scss'],
681681
excludeFiles: [],
682682
codeOwner: '@elastic/security-design',
683683
coverageOwner: 'security-design',

packages/kbn-dev-utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ export * from './simple_kibana_platform_plugin_discovery';
4444
export * from './streams';
4545
export * from './babel';
4646
export * from './parse_kibana_platform_plugin';
47+
export { rules } from './code_ownership/ownership_config';

scripts/load_team_assignment.js renamed to scripts/generate_team_assignments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
*/
1919

2020
require('../src/setup_node_env');
21-
require('../src/dev/code_coverage/ingest_coverage/team_assignment').uploadTeamAssignmentJson();
21+
require('../src/dev/code_coverage/ingest_coverage/team_assignment/').generateTeamAssignments();

src/dev/code_coverage/ingest_coverage/__tests__/either.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe(`either datatype functions`, () => {
5353
expect(sut.inspect()).to.be('Right(undefined)');
5454
});
5555
});
56-
describe(`'fromNullable`, () => {
56+
describe(`fromNullable`, () => {
5757
it(`should continue processing if a truthy is calculated`, () => {
5858
attempt({ detail: 'x' }).fold(
5959
() => {},
@@ -64,4 +64,18 @@ describe(`either datatype functions`, () => {
6464
attempt(false).fold(expectNull, () => {});
6565
});
6666
});
67+
describe(`predicate fns`, () => {
68+
it(`right.isRight() is true`, () => {
69+
expect(Either.right('a').isRight()).to.be(true);
70+
});
71+
it(`right.isLeft() is false`, () => {
72+
expect(Either.right('a').isLeft()).to.be(false);
73+
});
74+
it(`left.isLeft() is true`, () => {
75+
expect(Either.left().isLeft()).to.be(true);
76+
});
77+
it(`left.isRight() is true`, () => {
78+
expect(Either.left().isRight()).to.be(false);
79+
});
80+
});
6781
});
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
22+
import { resolve } from 'path';
23+
import { ToolingLog } from '@kbn/dev-utils';
24+
25+
const ROOT = resolve(__dirname, '../../../../..');
26+
const log = new ToolingLog({
27+
level: 'info',
28+
writeTo: process.stdout,
29+
});
30+
31+
describe(`enumeratePatterns`, () => {
32+
it(`should enumerate`, () => {
33+
const res = enumeratePatterns(ROOT)(log)(patternsMap());
34+
const actual = res[0][0];
35+
expect(actual).to.eql(expected()[0][0]);
36+
});
37+
it(`should not throw an unhandled error on a file path that is a glob, that expands to nothing`, () => {
38+
const absoluteRoot = '/Users/tre/development/projects/kibana';
39+
expect(
40+
enumeratePatterns(absoluteRoot)(log)(
41+
new Map([
42+
[
43+
'src/legacy/core_plugins/kibana/public/home/*.ts',
44+
{
45+
coverageOwner: 'kibana-core-ui',
46+
excludeFiles: [],
47+
},
48+
],
49+
])
50+
)
51+
).to.eql('');
52+
});
53+
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.js to kibana-reporting`, () => {
54+
const actual = enumeratePatterns(ROOT)(log)(
55+
new Map([
56+
[
57+
'x-pack/plugins/reporting',
58+
{
59+
coverageOwner: 'kibana-reporting',
60+
excludeFiles: [],
61+
},
62+
],
63+
])
64+
);
65+
66+
expect(
67+
actual[0].includes(
68+
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
69+
)
70+
).to.be(true);
71+
});
72+
});
73+
74+
function patternsMap() {
75+
return new Map([
76+
[
77+
'src/dev/code_coverage',
78+
{
79+
coverageOwner: 'kibana-qa',
80+
excludeFiles: [],
81+
},
82+
],
83+
[
84+
'vars/kibanaCoverage.groovy',
85+
{
86+
coverageOwner: 'kibana-qa',
87+
excludeFiles: [],
88+
},
89+
],
90+
[
91+
'vars/kibanaTeamAssign.groovy',
92+
{
93+
coverageOwner: 'kibana-qa',
94+
excludeFiles: [],
95+
},
96+
],
97+
]);
98+
}
99+
100+
function expected() {
101+
return [
102+
[
103+
'src/dev/code_coverage/ingest_coverage/constants.js kibana-qa',
104+
'src/dev/code_coverage/ingest_coverage/either.js kibana-qa',
105+
'src/dev/code_coverage/ingest_coverage/index.js kibana-qa',
106+
'src/dev/code_coverage/ingest_coverage/ingest-coverage_wallaby.js kibana-qa',
107+
'src/dev/code_coverage/ingest_coverage/ingest.js kibana-qa',
108+
'src/dev/code_coverage/ingest_coverage/ingest_helpers.js kibana-qa',
109+
'src/dev/code_coverage/ingest_coverage/integration_tests/ingest_coverage.test.js kibana-qa',
110+
'src/dev/code_coverage/ingest_coverage/json_stream.js kibana-qa',
111+
'src/dev/code_coverage/ingest_coverage/matching.js kibana-qa',
112+
'src/dev/code_coverage/ingest_coverage/maybe.js kibana-qa',
113+
'src/dev/code_coverage/ingest_coverage/process.js kibana-qa',
114+
'src/dev/code_coverage/ingest_coverage/team_assignment/enumerate_patterns.js kibana-qa',
115+
'src/dev/code_coverage/ingest_coverage/team_assignment/enumeration_helpers.js kibana-qa',
116+
'src/dev/code_coverage/ingest_coverage/team_assignment/flush.ts kibana-qa',
117+
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_assignments.js kibana-qa',
118+
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_patterns.js kibana-qa',
119+
'src/dev/code_coverage/ingest_coverage/team_assignment/get_data.js kibana-qa',
120+
'src/dev/code_coverage/ingest_coverage/team_assignment/index.js kibana-qa',
121+
'src/dev/code_coverage/ingest_coverage/transforms.js kibana-qa',
122+
'src/dev/code_coverage/ingest_coverage/utils.js kibana-qa',
123+
'src/dev/code_coverage/nyc_config/nyc.functional.config.js kibana-qa',
124+
'src/dev/code_coverage/nyc_config/nyc.jest.config.js kibana-qa',
125+
],
126+
];
127+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { isExcluded, tryPath } from '../team_assignment/enumeration_helpers';
22+
23+
describe(`enumeration helper fns`, () => {
24+
describe(`isExcluded`, () => {
25+
it(`should exclude exclusions`, () => {
26+
expect(
27+
isExcluded('src/dev/code_coverage/nyc_config/nyc.jest.config.js', [
28+
'src/dev/code_coverage/nyc_config',
29+
])
30+
).to.be(true);
31+
});
32+
});
33+
describe(`tryPath`, () => {
34+
describe(`w/o glob file paths`, () => {
35+
it(`should return a right on an existing path`, () => {
36+
const aPath = 'src/dev/code_coverage/ingest_coverage/ingest.js';
37+
const actual = tryPath(aPath);
38+
expect(actual.isRight()).to.be(true);
39+
});
40+
it(`should return a left on a non existing path`, () => {
41+
const aPath = 'src/dev/code_coverage/ingest_coverage/does_not_exist.js';
42+
const actual = tryPath(aPath);
43+
expect(actual.isLeft()).to.be(true);
44+
});
45+
});
46+
describe(`with glob file paths`, () => {
47+
it(`should not error when the glob expands to nothing, but instead return a Left`, () => {
48+
const aPath = 'src/legacy/core_plugins/kibana/public/home/*.ts';
49+
const actual = tryPath(aPath);
50+
expect(actual.isLeft()).to.be(true);
51+
});
52+
it(`should return a right on a glob that does indeed expand`, () => {
53+
const aPath = 'src/dev/code_coverage/ingest_coverage/*.js';
54+
const actual = tryPath(aPath);
55+
expect(actual.isRight()).to.be(true);
56+
});
57+
});
58+
});
59+
});

src/dev/code_coverage/ingest_coverage/__tests__/ingest_helpers.test.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
*/
1919

2020
import expect from '@kbn/expect';
21-
import { maybeTeamAssign, whichIndex } from '../ingest_helpers';
22-
import {
23-
TOTALS_INDEX,
24-
RESEARCH_TOTALS_INDEX,
25-
RESEARCH_COVERAGE_INDEX,
26-
// COVERAGE_INDEX,
27-
} from '../constants';
21+
import { whichIndex } from '../ingest_helpers';
22+
import { TOTALS_INDEX, RESEARCH_TOTALS_INDEX, RESEARCH_COVERAGE_INDEX } from '../constants';
2823

2924
describe(`Ingest Helper fns`, () => {
3025
describe(`whichIndex`, () => {
@@ -56,20 +51,4 @@ describe(`Ingest Helper fns`, () => {
5651
});
5752
});
5853
});
59-
describe(`maybeTeamAssign`, () => {
60-
describe(`against a coverage index`, () => {
61-
it(`should have the pipeline prop`, () => {
62-
const actual = maybeTeamAssign(true, { a: 'blah' });
63-
expect(actual).to.have.property('pipeline');
64-
});
65-
});
66-
describe(`against a totals index`, () => {
67-
describe(`for "prod"`, () => {
68-
it(`should not have the pipeline prop`, () => {
69-
const actual = maybeTeamAssign(false, { b: 'blah' });
70-
expect(actual).not.to.have.property('pipeline');
71-
});
72-
});
73-
});
74-
});
7554
});

0 commit comments

Comments
 (0)