forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reporting] code cleanup for reporting browser build/install/setup ut…
…ilities (elastic#98799) * [Reporting] code cleanup for reporting browser setup utilities * fix target_cpu * Update README.md * Update README.md * add note about target_cpu * Update paths.ts * more cleanup * Update src/dev/chromium_version.ts Co-authored-by: Michael Dokolin <[email protected]> * remove bug Co-authored-by: Michael Dokolin <[email protected]> Co-authored-by: Kibana Machine <[email protected]> # Conflicts: # src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js # src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt # src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js
- Loading branch information
Showing
30 changed files
with
623 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/dev/code_coverage/ingest_coverage/__tests__/enumerate_patterns.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { enumeratePatterns } from '../team_assignment/enumerate_patterns'; | ||
import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; | ||
|
||
const log = new ToolingLog({ | ||
level: 'info', | ||
writeTo: process.stdout, | ||
}); | ||
|
||
describe(`enumeratePatterns`, () => { | ||
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.ts to kibana-reporting`, () => { | ||
const actual = enumeratePatterns(REPO_ROOT)(log)( | ||
new Map([['x-pack/plugins/reporting', ['kibana-reporting']]]) | ||
); | ||
|
||
expect( | ||
actual[0].includes( | ||
'x-pack/plugins/reporting/server/browsers/extract/unzip.ts kibana-reporting' | ||
) | ||
).toBe(true); | ||
}); | ||
it(`should resolve src/plugins/charts/public/static/color_maps/color_maps.ts to kibana-app`, () => { | ||
const actual = enumeratePatterns(REPO_ROOT)(log)( | ||
new Map([['src/plugins/charts/public/static/color_maps', ['kibana-app']]]) | ||
); | ||
|
||
expect(actual[0][0]).toBe( | ||
'src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app' | ||
); | ||
}); | ||
it(`should resolve x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/translations.ts to kibana-security`, () => { | ||
const short = 'x-pack/plugins/security_solution'; | ||
const actual = enumeratePatterns(REPO_ROOT)(log)(new Map([[short, ['kibana-security']]])); | ||
|
||
expect( | ||
actual[0].includes( | ||
`${short}/public/common/components/exceptions/edit_exception_modal/translations.ts kibana-security` | ||
) | ||
).toBe(true); | ||
}); | ||
}); |
194 changes: 194 additions & 0 deletions
194
src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt
Large diffs are not rendered by default.
Oops, something went wrong.
137 changes: 137 additions & 0 deletions
137
src/dev/code_coverage/ingest_coverage/__tests__/transforms.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { | ||
ciRunUrl, | ||
coveredFilePath, | ||
itemizeVcs, | ||
prokPrevious, | ||
teamAssignment, | ||
last, | ||
} from '../transforms'; | ||
import { ToolingLog } from '@kbn/dev-utils'; | ||
|
||
describe(`Transform fns`, () => { | ||
describe(`ciRunUrl`, () => { | ||
it(`should add the url when present in the environment`, () => { | ||
process.env.CI_RUN_URL = 'blah'; | ||
expect(ciRunUrl()).toHaveProperty('ciRunUrl', 'blah'); | ||
}); | ||
it(`should not include the url if not present in the environment`, () => { | ||
process.env.CI_RUN_URL = void 0; | ||
expect(ciRunUrl({ a: 'a' })).not.toHaveProperty('ciRunUrl'); | ||
}); | ||
}); | ||
describe(`coveredFilePath`, () => { | ||
describe(`in the code-coverage job`, () => { | ||
it(`should remove the jenkins workspace path`, () => { | ||
const obj = { | ||
staticSiteUrl: | ||
'/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/plugins/reporting/server/browsers/extract/unzip.ts', | ||
COVERAGE_INGESTION_KIBANA_ROOT: | ||
'/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana', | ||
}; | ||
expect(coveredFilePath(obj)).toHaveProperty( | ||
'coveredFilePath', | ||
'x-pack/plugins/reporting/server/browsers/extract/unzip.ts' | ||
); | ||
}); | ||
}); | ||
describe(`in the qa research job`, () => { | ||
it(`should remove the jenkins workspace path`, () => { | ||
const obj = { | ||
staticSiteUrl: | ||
'/var/lib/jenkins/workspace/elastic+kibana+qa-research/kibana/x-pack/plugins/reporting/server/browsers/extract/unzip.ts', | ||
COVERAGE_INGESTION_KIBANA_ROOT: | ||
'/var/lib/jenkins/workspace/elastic+kibana+qa-research/kibana', | ||
}; | ||
expect(coveredFilePath(obj)).toHaveProperty( | ||
'coveredFilePath', | ||
'x-pack/plugins/reporting/server/browsers/extract/unzip.ts' | ||
); | ||
}); | ||
}); | ||
}); | ||
describe(`prokPrevious`, () => { | ||
const comparePrefixF = () => 'https://github.com/elastic/kibana/compare'; | ||
process.env.FETCHED_PREVIOUS = 'A'; | ||
it(`should return a previous compare url`, () => { | ||
const actual = prokPrevious(comparePrefixF)('B'); | ||
expect(actual).toBe(`https://github.com/elastic/kibana/compare/A...B`); | ||
}); | ||
}); | ||
describe(`itemizeVcs`, () => { | ||
it(`should return a sha url`, () => { | ||
const vcsInfo = [ | ||
'origin/ingest-code-coverage', | ||
'f07b34f6206', | ||
`Tre' Seymour`, | ||
`Lorem :) ipsum Tre' λ dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`, | ||
]; | ||
expect(itemizeVcs(vcsInfo)({}).vcs).toHaveProperty( | ||
'vcsUrl', | ||
`https://github.com/elastic/kibana/commit/${vcsInfo[1]}` | ||
); | ||
}); | ||
}); | ||
describe(`teamAssignment`, () => { | ||
const teamAssignmentsPathMOCK = | ||
'src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.txt'; | ||
const coveredFilePath = 'x-pack/plugins/reporting/server/browsers/extract/unzip.ts'; | ||
const obj = { coveredFilePath }; | ||
const log = new ToolingLog({ | ||
level: 'info', | ||
writeTo: process.stdout, | ||
}); | ||
|
||
describe(`with a coveredFilePath of ${coveredFilePath}`, () => { | ||
const expected = 'kibana-reporting'; | ||
it(`should resolve to ${expected}`, async () => { | ||
const actual = await teamAssignment(teamAssignmentsPathMOCK)(log)(obj); | ||
const { team } = actual; | ||
expect(team).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe(`with a coveredFilePath of src/plugins/charts/public/static/color_maps/color_maps.ts`, () => { | ||
const expected = 'kibana-reporting'; | ||
it(`should resolve to ${expected}`, async () => { | ||
const actual = await teamAssignment(teamAssignmentsPathMOCK)(log)(obj); | ||
const { team } = actual; | ||
expect(team).toEqual(expected); | ||
}); | ||
}); | ||
|
||
describe(`last fn`, () => { | ||
describe(`applied to n results`, () => { | ||
it(`should pick the last one`, () => { | ||
const nteams = `src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app | ||
src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app-arch`; | ||
|
||
const actual = last(nteams); | ||
|
||
expect(actual).toBe( | ||
'src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app-arch' | ||
); | ||
}); | ||
}); | ||
describe(`applied to 1 result`, () => { | ||
it(`should pick that 1 result`, () => { | ||
const nteams = | ||
'src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app-arch'; | ||
|
||
const actual = last(nteams); | ||
|
||
expect(actual).toBe( | ||
'src/plugins/charts/public/static/color_maps/color_maps.ts kibana-app-arch' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.