Skip to content

Commit

Permalink
[QA][Code Coverage] Coverage teams lookup - LESS UNKNOWNS
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Sep 16, 2020
1 parent 136ca61 commit 07107fc
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 39 deletions.
7 changes: 6 additions & 1 deletion .ci/Jenkinsfile_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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, teamAssignmentsPath(), '### Ingest && Upload')
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), unknownTeamsLogPath(), '### Generate Team Assignments && Ingest')
kibanaCoverage.uploadCoverageStaticSite(timestamp)
}

Expand All @@ -53,3 +53,8 @@ def teamAssignmentsPath() {
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
}

def unknownTeamsLogPath() {
return 'src/dev/code_coverage/ingest_coverage/team_assignment/unknown_team_paths.txt'
}


116 changes: 115 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Identify which groups will be pinged by changes to different parts of the codebase.
# For more info, see https://help.github.com/articles/about-codeowners/

# The #CC# prefix delineates Code Coverage,
# used for the 'team' designator within Kibana Stats

# App
/x-pack/plugins/dashboard_enhanced/ @elastic/kibana-app
/x-pack/plugins/discover_enhanced/ @elastic/kibana-app
Expand All @@ -22,6 +25,33 @@
/src/plugins/vis_type_vislib/ @elastic/kibana-app
/src/plugins/vis_type_xy/ @elastic/kibana-app
/src/plugins/visualize/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public/local_application_service/ @elastic/kibana-app
#CC# /src/plugins/vis_type @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/common/utils @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/migrations @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public/dashboard/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public/discover/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/kibana/public/local_application_service/ @elastic/kibana-app
#CC# /src/legacy/core_plugins/console_legacy @elastic/kibana-app
#CC# /src/legacy/core_plugins/input_control_vis @elastic/kibana-app
#CC# /src/legacy/core_plugins/timelion @elastic/kibana-app
#CC# /src/legacy/core_plugins/vis_type_tagcloud @elastic/kibana-app
#CC# /src/legacy/core_plugins/vis_type_vega @elastic/kibana-app
#CC# /src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app
#CC# /src/legacy/server/sample_data/ @elastic/kibana-app
#CC# /src/legacy/server/url_shortening/ @elastic/kibana-app
#CC# /src/legacy/ui/public/state_management @elastic/kibana-app
#CC# /src/plugins/charts/public/static/color_maps @elastic/kibana-app
#CC# /src/plugins/index_pattern_management/public @elastic/kibana-app
#CC# /src/plugins/input_control_vis/ @elastic/kibana-app
#CC# /src/plugins/kibana_legacy/ @elastic/kibana-app
#CC# /src/plugins/timelion @elastic/kibana-app
#CC# /x-pack/legacy/plugins/dashboard_mode/ @elastic/kibana-app
#CC# /x-pack/plugins/dashboard_mode @elastic/kibana-app
#CC# /x-pack/plugins/lens/ @elastic/kibana-app

# App Architecture
/examples/bfetch_explorer/ @elastic/kibana-app-arch
Expand Down Expand Up @@ -55,13 +85,38 @@
/x-pack/plugins/data_enhanced/ @elastic/kibana-app-arch
/x-pack/plugins/embeddable_enhanced/ @elastic/kibana-app-arch
/x-pack/plugins/ui_actions_enhanced/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/kibana/public/management/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/kibana/server/routes/api/management/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/embeddable_api/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/interpreter/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/kibana_react/ @elastic/kibana-app-arch
#CC# /src/legacy/core_plugins/status_page/public @elastic/kibana-app-arch
#CC# /src/legacy/server/index_patterns/ @elastic/kibana-app-arch
#CC# /src/legacy/ui/public/field_editor @elastic/kibana-app-arch
#CC# /src/legacy/ui/public/management @elastic/kibana-app-arch
#CC# /src/plugins/advanced_settings/ @elastic/kibana-app-arch
#CC# /src/plugins/bfetch/ @elastic/kibana-app-arch
#CC# /src/plugins/charts/ @elastic/kibana-app-arch
#CC# /src/plugins/index_pattern_management/public/service @elastic/kibana-app-arch
#CC# /src/plugins/inspector/ @elastic/kibana-app-arch
#CC# /src/plugins/saved_objects/ @elastic/kibana-app-arch
#CC# /src/plugins/share/ @elastic/kibana-app-arch
#CC# /src/plugins/vis_default_editor @elastic/kibana-app-arch
#CC# /x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch
#CC# /x-pack/plugins/drilldowns/ @elastic/kibana-app-arch
#CC# /packages/kbn-interpreter/ @elastic/kibana-app-arch

# APM
/x-pack/plugins/apm/ @elastic/apm-ui
/x-pack/test/functional/apps/apm/ @elastic/apm-ui
/src/legacy/core_plugins/apm_oss/ @elastic/apm-ui
/src/plugins/apm_oss/ @elastic/apm-ui
/src/apm.js @watson @vigneshshanmugam
#CC# /src/plugins/apm_oss/ @elastic/apm-ui
#CC# /src/legacy/core_plugins/apm_oss/ @elastic/apm-ui
#CC# /src/legacy/ui/public/apm @elastic/apm-ui
#CC# /x-pack/legacy/plugins/apm/ @elastic/apm-ui
#CC# /x-pack/plugins/observability/ @elastic/apm-ui

# Client Side Monitoring (lives in APM directories but owned by Uptime)
/x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm @elastic/uptime
Expand All @@ -70,13 +125,17 @@
/x-pack/plugins/apm/server/lib/rum_client @elastic/uptime
/x-pack/plugins/apm/server/routes/rum_client.ts @elastic/uptime
/x-pack/plugins/apm/server/projections/rum_overview.ts @elastic/uptime
#CC# /x-pack/legacy/plugins/uptime @elastic/uptime

# Beats
/x-pack/legacy/plugins/beats_management/ @elastic/beats
#CC# /x-pack/plugins/beats_management/ @elastic/beats

# Canvas
/x-pack/plugins/canvas/ @elastic/kibana-canvas
/x-pack/test/functional/apps/canvas/ @elastic/kibana-canvas
#CC# /src/plugins/kibana_react/public/code_editor/ @elastic/kibana-canvas
#CC# /x-pack/legacy/plugins/canvas/ @elastic/kibana-canvas

# Core UI
# Exclude tutorials folder for now because they are not owned by Kibana app and most will move out soon
Expand All @@ -87,6 +146,11 @@
/src/legacy/core_plugins/kibana/public/home/*.ts @elastic/kibana-core-ui
/src/legacy/core_plugins/kibana/public/home/np_ready/ @elastic/kibana-core-ui
/x-pack/plugins/global_search_bar/ @elastic/kibana-core-ui
#CC# /src/legacy/core_plugins/newsfeed @elastic/kibana-core-ui
#CC# /src/plugins/newsfeed @elastic/kibana-core-ui
#CC# /src/plugins/home/public @elastic/kibana-core-ui
#CC# /src/plugins/home/server/services/ @elastic/kibana-core-ui
#CC# /src/plugins/home/ @elastic/kibana-core-ui

# Observability UIs
/x-pack/legacy/plugins/infra/ @elastic/logs-metrics-ui
Expand Down Expand Up @@ -116,6 +180,12 @@
/x-pack/test/functional/apps/maps/ @elastic/kibana-gis
/x-pack/test/functional/es_archives/maps/ @elastic/kibana-gis
/x-pack/test/visual_regression/tests/maps/index.js @elastic/kibana-gis
#CC# /src/legacy/core_plugins/region_map @elastic/kibana-gis
#CC# /src/legacy/core_plugins/tile_map @elastic/kibana-gis
#CC# /src/plugins/maps_legacy/ @elastic/kibana-gis
#CC# /x-pack/plugins/file_upload @elastic/kibana-gis
#CC# /x-pack/plugins/maps_legacy_licensing @elastic/kibana-gis
#CC# /src/plugins/home/server/tutorials @elastic/kibana-gis

# Operations
/src/dev/ @elastic/kibana-operations
Expand All @@ -130,6 +200,7 @@
/packages/kbn-test/ @elastic/kibana-operations
/packages/kbn-ui-shared-deps/ @elastic/kibana-operations
/packages/kbn-es-archiver/ @elastic/kibana-operations
/packages/kbn-utils/ @elastic/kibana-operations
/src/legacy/server/keystore/ @elastic/kibana-operations
/src/legacy/server/pid/ @elastic/kibana-operations
/src/legacy/server/sass/ @elastic/kibana-operations
Expand Down Expand Up @@ -163,6 +234,30 @@
/src/plugins/status_page/ @elastic/kibana-platform
/src/plugins/saved_objects_management/ @elastic/kibana-platform
/src/dev/run_check_published_api_changes.ts @elastic/kibana-platform
#CC# /src/core/server/csp/ @elastic/kibana-platform
#CC# /src/legacy/core_plugins/kibana/server/lib @elastic/kibana-platform
#CC# /src/legacy/core_plugins/kibana/server/lib/management/saved_objects @elastic/kibana-platform
#CC# /src/legacy/core_plugins/kibana/server/routes/api/import/ @elastic/kibana-platform
#CC# /src/legacy/core_plugins/kibana/server/routes/api/export/ @elastic/kibana-platform
#CC# /src/legacy/core_plugins/elasticsearch @elastic/kibana-platform
#CC# /src/legacy/core_plugins/testbed @elastic/kibana-platform
#CC# /src/legacy/server/config/ @elastic/kibana-platform
#CC# /src/legacy/server/http/ @elastic/kibana-platform
#CC# /src/legacy/server/status/ @elastic/kibana-platform
#CC# /src/legacy/ui/public/new_platform @elastic/kibana-platform
#CC# /src/legacy/ui/public/plugin_discovery @elastic/kibana-platform
#CC# /src/legacy/ui/public/chrome @elastic/kibana-platform
#CC# /src/legacy/ui/public/notify @elastic/kibana-platform
#CC# /src/legacy/ui/public/documentation_links @elastic/kibana-platform
#CC# /src/legacy/ui/public/autoload @elastic/kibana-platform
#CC# /src/plugins/legacy_export/ @elastic/kibana-platform
#CC# /src/plugins/status_page/ @elastic/kibana-platform
#CC# /src/plugins/testbed/server/ @elastic/kibana-platform
#CC# /x-pack/legacy/plugins/xpack_main/server/ @elastic/kibana-platform
#CC# /x-pack/legacy/server/lib/ @elastic/kibana-platform
#CC# /x-pack/plugins/cloud/ @elastic/kibana-platform
#CC# /x-pack/plugins/features/ @elastic/kibana-platform
#CC# /x-pack/plugins/global_search @elastic/kibana-platform

# Security
/src/core/server/csp/ @elastic/kibana-security @elastic/kibana-platform
Expand All @@ -184,12 +279,16 @@
/x-pack/test/security_functional/ @elastic/kibana-security
/x-pack/test/spaces_api_integration/ @elastic/kibana-security
/x-pack/test/token_api_integration/ @elastic/kibana-security
#CC# /src/legacy/ui/public/capabilities @elastic/kibana-security
#CC# /x-pack/legacy/plugins/encrypted_saved_objects/ @elastic/kibana-security

# Kibana Localization
/src/dev/i18n/ @elastic/kibana-localization
/src/legacy/server/i18n/ @elastic/kibana-localization
/src/core/public/i18n/ @elastic/kibana-localization
/packages/kbn-i18n/ @elastic/kibana-localization
#CC# /src/legacy/server/i18n/ @elastic/kibana-localization
#CC# /x-pack/plugins/translations/ @elastic/kibana-localization

# Kibana Telemetry
/packages/kbn-analytics/ @elastic/kibana-telemetry
Expand Down Expand Up @@ -218,6 +317,11 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
/x-pack/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services
/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/ @elastic/kibana-alerting-services
/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/ @elastic/kibana-alerting-services
#CC# /x-pack/legacy/plugins/actions/ @elastic/kibana-alerting-services
#CC# /x-pack/legacy/plugins/alerting/ @elastic/kibana-alerting-services
#CC# /x-pack/legacy/plugins/task_manager @elastic/kibana-alerting-services
#CC# /x-pack/legacy/plugins/triggers_actions_ui/ @elastic/kibana-alerting-services
#CC# /x-pack/plugins/alerting_builtins @elastic/kibana-alerting-services

# Enterprise Search
# Shared
Expand Down Expand Up @@ -258,6 +362,12 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
/x-pack/plugins/upgrade_assistant/ @elastic/es-ui
/x-pack/plugins/watcher/ @elastic/es-ui
/x-pack/plugins/ingest_pipelines/ @elastic/es-ui
#CC# /x-pack/legacy/plugins/rollup/ @elastic/es-ui
#CC# /x-pack/legacy/server/lib/create_router/ @elastic/es-ui
#CC# /x-pack/legacy/server/lib/check_license/ @elastic/es-ui
#CC# /x-pack/plugins/console_extensions/ @elastic/es-ui
#CC# /x-pack/plugins/cross_cluster_replication/ @elastic/es-ui
#CC# /x-pack/plugins/es_ui_shared/ @elastic/es-ui

# Endpoint
/x-pack/plugins/endpoint/ @elastic/endpoint-app-team @elastic/siem
Expand All @@ -267,6 +377,9 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
/x-pack/test/functional/es_archives/endpoint/ @elastic/endpoint-app-team @elastic/siem
/x-pack/test/plugin_functional/plugins/resolver_test/ @elastic/endpoint-app-team @elastic/siem
/x-pack/test/plugin_functional/test_suites/resolver/ @elastic/endpoint-app-team @elastic/siem
#CC# /x-pack/legacy/plugins/siem/ @elastic/siem
#CC# /x-pack/plugins/siem/ @elastic/siem
#CC# /x-pack/plugins/security_solution/ @elastic/siem

# Security Solution
/x-pack/plugins/security_solution/ @elastic/siem @elastic/endpoint-app-team
Expand All @@ -281,6 +394,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib

# Design (at the bottom for specificity of SASS files)
**/*.scss @elastic/kibana-design
#CC# /packages/kbn-ui-framework/ @elastic/kibana-design

# Core design
/src/plugins/dashboard/**/*.scss @elastic/kibana-core-ui-designers
Expand All @@ -296,7 +410,7 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
/x-pack/plugins/infra/**/*.scss @elastic/observability-design
/x-pack/plugins/ingest_manager/**/*.scss @elastic/observability-design
/x-pack/plugins/observability/**/*.scss @elastic/observability-design
/x-pack/plugins/monitoring/**/*.scss @elastic/observability-design
/x-pack/plugins/monitoring/**/*.scss @elastic/observability-design

# Ent. Search design
/x-pack/plugins/enterprise_search/**/*.scss @elastic/ent-search-design
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
import expect from '@kbn/expect';
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import { resolve } from 'path';
import shell from 'shelljs';
import { tryCatch } from '../either';

const log = new ToolingLog({
level: 'info',
writeTo: process.stdout,
});
const notFoundLogPath =
'src/dev/code_coverage/ingest_coverage/team_assignment/not_found_team_assignments.txt';
const resolved = resolve(REPO_ROOT, notFoundLogPath);

describe(`enumeratePatterns`, () => {
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.js to kibana-reporting`, () => {
const actual = enumeratePatterns(REPO_ROOT)(log)(
it(`should resolve to kibana-reporting`, () => {
const actual = enumeratePatterns(resolved)(log)(
new Map([['x-pack/plugins/reporting', ['kibana-reporting']]])
);

Expand All @@ -37,5 +43,7 @@ describe(`enumeratePatterns`, () => {
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
)
).to.be(true);

tryCatch(() => shell.rm(resolved));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ describe(`Transform fn`, () => {
});
});
describe(`teamAssignment`, () => {
const unknownTeamsLogPath =
'src/dev/code_coverage/ingest_coverage/team_assignment/unknown_team_paths.txt';
const teamAssignmentsPathMOCK =
'src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt';
const coveredFilePath = 'x-pack/plugins/reporting/server/browsers/extract/unzip.js';
Expand All @@ -97,7 +99,7 @@ describe(`Transform fn`, () => {
describe(`with a coveredFilePath of ${coveredFilePath}`, () => {
const expected = 'kibana-reporting';
it(`should resolve to ${expected}`, async () => {
const actual = await teamAssignment(teamAssignmentsPathMOCK)(log)(obj);
const actual = await teamAssignment(teamAssignmentsPathMOCK)(unknownTeamsLogPath)(log)(obj);
const { team } = actual;
expect(team).to.eql(expected);
});
Expand Down
10 changes: 7 additions & 3 deletions src/dev/code_coverage/ingest_coverage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import { run, createFlagError } from '@kbn/dev-utils';

const ROOT = resolve(__dirname, '../../../..');
const flags = {
string: ['path', 'verbose', 'vcsInfoPath', 'teamAssignmentsPath'],
string: ['path', 'verbose', 'vcsInfoPath', 'teamAssignmentsPath', 'unknownTeamsLogPath'],
help: `
--path Required, path to the file to extract coverage data
--vcsInfoPath Required, path to the git info file (branch, sha, author, & commit msg)
--teamAssignmentsPath Required, path to the team assignments data file
--unknownTeamsLogPath Required, path to the unknown teams log file
`,
};

Expand All @@ -39,14 +40,17 @@ export function runCoverageIngestionCli() {
throw createFlagError('please provide a single --vcsInfoPath flag');
if (flags.teamAssignmentsPath === '')
throw createFlagError('please provide a single --teamAssignments flag');
if (flags.unknownTeamsLogPath === '')
throw createFlagError('please provide a single --unknownTeamsLogPath flag');

if (flags.verbose) log.verbose(`Verbose logging enabled`);

const resolveRoot = resolve.bind(null, ROOT);
const jsonSummaryPath = resolveRoot(flags.path);
const vcsInfoFilePath = resolveRoot(flags.vcsInfoPath);
const { teamAssignmentsPath } = flags;
const { teamAssignmentsPath, unknownTeamsLogPath } = flags;

prok({ jsonSummaryPath, vcsInfoFilePath, teamAssignmentsPath }, log);
prok({ jsonSummaryPath, vcsInfoFilePath, teamAssignmentsPath, unknownTeamsLogPath }, log);
},
{
description: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,46 @@ const env = {
describe('Ingesting coverage', () => {
const teamAssignmentsPath =
'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt';
const unknownTeamsLogPath =
'src/dev/code_coverage/ingest_coverage/team_assignment/unknown_team_paths.txt';

const verboseArgs = [
const ingestCoveragParams = [
'scripts/ingest_coverage.js',
'--verbose',
'--teamAssignmentsPath',
teamAssignmentsPath,
'--vcsInfoPath',
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO.txt',
'--unknownTeamsLogPath',
unknownTeamsLogPath,
'--path',
];

const summaryPath = 'jest-combined/coverage-summary-manual-mix.json';
const resolved = resolve(MOCKS_DIR, summaryPath);

beforeAll(async () => {
const params = [
const generateTeamAssignmentsParams = [
'scripts/generate_team_assignments.js',
'--src',
'.github/CODEOWNERS',
'--dest',
teamAssignmentsPath,
];
await execa(process.execPath, params, { cwd: ROOT_DIR, env });
await execa(process.execPath, generateTeamAssignmentsParams, { cwd: ROOT_DIR, env });
});

afterAll(() => {
shell.rm(teamAssignmentsPath);
shell.rm(unknownTeamsLogPath);
});

describe(`staticSiteUrl`, () => {
let actualUrl = '';
const siteUrlRegex = /"staticSiteUrl":\s*(.+,)/;

beforeAll(async () => {
const opts = [...verboseArgs, resolved];
const opts = [...ingestCoveragParams, resolved];
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env });
actualUrl = siteUrlRegex.exec(stdout)[1];
});
Expand Down
Loading

0 comments on commit 07107fc

Please sign in to comment.