-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Ingest code coverage #62336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ingest code coverage #62336
Changes from all commits
78b2778
3870be4
81ae5ea
8652b33
8b5b226
77998fe
3c00200
b7b07fa
0f973e7
f55afb6
2c75016
7f3b02b
de92e2d
26b80b0
54197ce
e306557
4b0947e
7004a54
c1d3268
c09f855
854d22b
ba5e684
2fddb10
fff8b10
2601b0d
2222f3a
379fd3f
2bd8e7e
80cc028
e9987aa
56f159b
110a0b4
3654a24
e9b68dc
7aa1139
0ca30b7
c28b4c4
3606645
1f13e88
7b61bd5
218642a
6c60481
5c1bb80
773074f
a6ddf2c
4584887
f094fff
4e31bed
682b5a5
1e712b1
7528bcd
0b99143
db7efb2
a2d3042
e0215eb
9559893
9ac93f3
db96d5d
835d5a1
5714195
d510d01
6cd6da4
f851f16
989f9bf
1f07592
87bd043
1305f99
a4050a3
94470c9
57aef87
b6b5b45
d1a8af4
e800438
5d69a42
aa211f6
79c25c2
8219916
8d08d50
9836a58
44ea5f2
8c931c6
b82f0ea
58eb7e5
209d362
3ce180d
4543880
01ec75c
2143de1
b106602
b1a3e3b
f245da0
e0b3644
79743c1
13051f1
0669dba
2a76484
4eb235b
282328d
ad6649f
742b3b1
3d11f02
0088a5b
8b4de43
00e7c8d
eac5b5d
94e2017
aba53f2
521633e
0755b8e
053a93d
5389b4a
d0cb160
26bd2c7
5d2609c
b72c74d
8ff2c55
fd8d993
218aaca
6fc88da
04a0246
c6e620d
a86e75f
288aac3
ec9d544
58fe8ea
774d050
d792610
3123b1d
05cceb0
5d293e1
e2a7573
b86069f
a54b970
740a992
db2276c
b27331d
5924322
61b9c04
781dcff
4015b4d
fa80c51
8f596af
bb7325b
96ccec5
4af8c31
6d71a14
69f0da2
67648d4
e83c266
5bf5ae0
46b717b
d7dc231
563c925
8d6c306
f1a7750
6a267f7
d9d1d86
0a86b11
fce6b29
4fbf7b6
27b62a3
86016e3
4f3c84e
b2633c5
434557e
1bb7250
f9e61a4
cc36098
5c1ced6
bea55da
f0ec92a
b790543
ac20051
c4d83e5
acfe1f0
247d8e4
72c4dcf
e52a6e9
0a98ea0
87dfc1d
d0b1d87
f07b34f
f229c24
873cf4d
44ac0d1
73c6468
98225aa
e8fc596
b2d369f
407d0de
90a3888
9819477
e72b59d
4f3181a
3e85686
0bcbf75
64a694c
afd335f
81a1843
1447719
5c41f25
29c91d2
e012720
1f028c2
565815d
e51050b
5838efb
53cc9f4
afacbc4
7970a3f
ddbd3bc
2d40b48
27431e6
f63f75f
672f2e7
49f9c65
f8299dc
9bc3509
a81f834
4c5f655
9ac9ba0
7306c97
6ae6c62
8883fcb
1116d4e
1e61814
0df811a
2fae19b
e635be1
f44b088
187ab5e
6b20ad4
e679a3a
e3a2f37
74c225c
59b8cc1
7da7ae8
e0bb7eb
93ca72f
0167f7c
29ebefa
0ecf880
e8d18ce
08787cf
7b440dd
bc487af
50fb22e
fbc8ea4
3dc8c31
bc123d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,89 +5,26 @@ kibanaLibrary.load() // load from the Jenkins instance | |
|
|
||
| kibanaPipeline(timeoutMinutes: 240) { | ||
| catchErrors { | ||
| def timestamp = new Date(currentBuild.startTimeInMillis).format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC")) | ||
| withEnv([ | ||
| 'CODE_COVERAGE=1', // Needed for multiple ci scripts, such as remote.ts, test/scripts/*.sh, schema.js, etc. | ||
| "TIME_STAMP=${timestamp}", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it two words?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. two words? Perhaps you mean the groovy to bash interpolation?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The environment variable you're setting is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make this change chief |
||
| 'CODE_COVERAGE=1', // Enables coverage. Needed for multiple ci scripts, such as remote.ts, test/scripts/*.sh, schema.js, etc. | ||
| ]) { | ||
wayneseymour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| parallel([ | ||
| 'kibana-intake-agent': workers.intake('kibana-intake', './test/scripts/jenkins_unit.sh'), | ||
| 'x-pack-intake-agent': { | ||
| withEnv([ | ||
| 'NODE_ENV=test' // Needed for jest tests only | ||
| ]) { | ||
| workers.intake('x-pack-intake', './test/scripts/jenkins_xpack.sh')() | ||
| } | ||
| }, | ||
| 'kibana-oss-agent': workers.functional('kibana-oss-tests', { kibanaPipeline.buildOss() }, [ | ||
| 'oss-ciGroup1': kibanaPipeline.ossCiGroupProcess(1), | ||
| 'oss-ciGroup2': kibanaPipeline.ossCiGroupProcess(2), | ||
| 'oss-ciGroup3': kibanaPipeline.ossCiGroupProcess(3), | ||
| 'oss-ciGroup4': kibanaPipeline.ossCiGroupProcess(4), | ||
| 'oss-ciGroup5': kibanaPipeline.ossCiGroupProcess(5), | ||
| 'oss-ciGroup6': kibanaPipeline.ossCiGroupProcess(6), | ||
| 'oss-ciGroup7': kibanaPipeline.ossCiGroupProcess(7), | ||
| 'oss-ciGroup8': kibanaPipeline.ossCiGroupProcess(8), | ||
| 'oss-ciGroup9': kibanaPipeline.ossCiGroupProcess(9), | ||
| 'oss-ciGroup10': kibanaPipeline.ossCiGroupProcess(10), | ||
| 'oss-ciGroup11': kibanaPipeline.ossCiGroupProcess(11), | ||
| 'oss-ciGroup12': kibanaPipeline.ossCiGroupProcess(12), | ||
| ]), | ||
| 'kibana-xpack-agent': workers.functional('kibana-xpack-tests', { kibanaPipeline.buildXpack() }, [ | ||
| 'xpack-ciGroup1': kibanaPipeline.xpackCiGroupProcess(1), | ||
| 'xpack-ciGroup2': kibanaPipeline.xpackCiGroupProcess(2), | ||
| 'xpack-ciGroup3': kibanaPipeline.xpackCiGroupProcess(3), | ||
| 'xpack-ciGroup4': kibanaPipeline.xpackCiGroupProcess(4), | ||
| 'xpack-ciGroup5': kibanaPipeline.xpackCiGroupProcess(5), | ||
| 'xpack-ciGroup6': kibanaPipeline.xpackCiGroupProcess(6), | ||
| 'xpack-ciGroup7': kibanaPipeline.xpackCiGroupProcess(7), | ||
| 'xpack-ciGroup8': kibanaPipeline.xpackCiGroupProcess(8), | ||
| 'xpack-ciGroup9': kibanaPipeline.xpackCiGroupProcess(9), | ||
| 'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10), | ||
| ]), | ||
| ]) | ||
| workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) { | ||
| kibanaPipeline.downloadCoverageArtifacts() | ||
| kibanaPipeline.bash( | ||
| ''' | ||
| # bootstrap from x-pack folder | ||
| source src/dev/ci_setup/setup_env.sh | ||
| cd x-pack | ||
| yarn kbn bootstrap --prefer-offline | ||
| cd .. | ||
| # extract archives | ||
| mkdir -p /tmp/extracted_coverage | ||
| echo extracting intakes | ||
| tar -xzf /tmp/downloaded_coverage/coverage/kibana-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage | ||
| tar -xzf /tmp/downloaded_coverage/coverage/x-pack-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage | ||
| echo extracting kibana-oss-tests | ||
| tar -xzf /tmp/downloaded_coverage/coverage/kibana-oss-tests/kibana-coverage.tar.gz -C /tmp/extracted_coverage | ||
| echo extracting kibana-xpack-tests | ||
| tar -xzf /tmp/downloaded_coverage/coverage/kibana-xpack-tests/kibana-coverage.tar.gz -C /tmp/extracted_coverage | ||
| # replace path in json files to have valid html report | ||
| pwd=$(pwd) | ||
| du -sh /tmp/extracted_coverage/target/kibana-coverage/ | ||
| echo replacing path in json files | ||
| for i in {1..9}; do | ||
| sed -i "s|/dev/shm/workspace/kibana|$pwd|g" /tmp/extracted_coverage/target/kibana-coverage/functional/${i}*.json & | ||
| done | ||
| wait | ||
| # merge oss & x-pack reports | ||
| echo merging coverage reports | ||
| yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/jest --report-dir target/kibana-coverage/jest-combined --reporter=html --reporter=json-summary | ||
| yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/functional --report-dir target/kibana-coverage/functional-combined --reporter=html --reporter=json-summary | ||
| echo copy mocha reports | ||
| mkdir -p target/kibana-coverage/mocha-combined | ||
| cp -r /tmp/extracted_coverage/target/kibana-coverage/mocha target/kibana-coverage/mocha-combined | ||
| ''', | ||
| "run `yarn kbn bootstrap && merge coverage`" | ||
| ) | ||
| sh 'tar -czf kibana-jest-coverage.tar.gz target/kibana-coverage/jest-combined/*' | ||
| kibanaPipeline.uploadCoverageArtifacts("coverage/jest-combined", 'kibana-jest-coverage.tar.gz') | ||
| sh 'tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional-combined/*' | ||
| kibanaPipeline.uploadCoverageArtifacts("coverage/functional-combined", 'kibana-functional-coverage.tar.gz') | ||
| sh 'tar -czf kibana-mocha-coverage.tar.gz target/kibana-coverage/mocha-combined/*' | ||
| kibanaPipeline.uploadCoverageArtifacts("coverage/mocha-combined", 'kibana-mocha-coverage.tar.gz') | ||
| kibanaCoverage.runTests() | ||
| handleIngestion(TIME_STAMP) | ||
| } | ||
| } | ||
| kibanaPipeline.sendMail() | ||
| } | ||
| kibanaPipeline.sendMail() | ||
| } | ||
|
|
||
| def handleIngestion(timestamp) { | ||
| kibanaPipeline.downloadCoverageArtifacts() | ||
| kibanaCoverage.prokLinks("### Process HTML Links") | ||
| kibanaCoverage.collectVcsInfo("### Collect VCS Info") | ||
| kibanaCoverage.ingest(timestamp, '### Injest && Upload') | ||
| kibanaCoverage.uploadCoverageStaticSite(timestamp) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| require('../src/setup_node_env'); | ||
| require('../src/dev/code_coverage/ingest_coverage').runCoverageIngestionCli(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * 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 { ciRunUrl } from '../transforms'; | ||
|
|
||
| describe(`Transform fn`, () => { | ||
| describe(`ciRunUrl`, () => { | ||
| it(`should add the url when present in the environment`, () => { | ||
| process.env.CI_RUN_URL = 'blah'; | ||
| expect(ciRunUrl()).to.have.property('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.to.have.property('ciRunUrl'); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export const STATIC_SITE_URL_PROP_NAME = 'staticSiteUrl'; | ||
| export const COVERAGE_INDEX = process.env.COVERAGE_INDEX || 'kibana_code_coverage'; | ||
| export const TOTALS_INDEX = process.env.TOTALS_INDEX || `kibana_total_code_coverage`; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| /* eslint new-cap: 0 */ | ||
| /* eslint no-unused-vars: 0 */ | ||
|
|
||
| export const Right = x => ({ | ||
wayneseymour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| chain: f => f(x), | ||
| map: f => Right(f(x)), | ||
| fold: (f, g) => g(x), | ||
| inspect: () => `Right(${x})`, | ||
| }); | ||
|
|
||
| Right.of = function of(x) { | ||
wayneseymour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return Right(x); | ||
| }; | ||
|
|
||
| export function right(x) { | ||
| return Right.of(x); | ||
| } | ||
|
|
||
| export const Left = x => ({ | ||
| chain: f => Left(x), | ||
| map: f => Left(x), | ||
| fold: (f, g) => f(x), | ||
| inspect: () => `Left(${x})`, | ||
| }); | ||
|
|
||
| Left.of = function of(x) { | ||
wayneseymour marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return Left(x); | ||
| }; | ||
|
|
||
| export function left(x) { | ||
| return Left.of(x); | ||
| } | ||
|
|
||
| export const fromNullable = x => | ||
| x !== null && x !== undefined && x !== false && x !== 'undefined' ? Right(x) : Left(null); | ||
|
|
||
| export const tryCatch = f => { | ||
| try { | ||
| return Right(f()); | ||
| } catch (e) { | ||
| return Left(e); | ||
| } | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * 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 { resolve } from 'path'; | ||
| import { prok } from './process'; | ||
| import { run, createFlagError } from '@kbn/dev-utils'; | ||
|
|
||
| const ROOT = resolve(__dirname, '../../../..'); | ||
| const flags = { | ||
| string: ['path', 'verbose', 'vcsInfoPath'], | ||
| help: ` | ||
| --path Required, path to the file to extract coverage data | ||
| --vcsInfoPath Required, path to the git info file (branch, sha, author, & commit msg) | ||
| `, | ||
| }; | ||
|
|
||
| export function runCoverageIngestionCli() { | ||
| run( | ||
| ({ flags, log }) => { | ||
| if (flags.path === '') throw createFlagError('please provide a single --path flag'); | ||
| if (flags.vcsInfoPath === '') | ||
| throw createFlagError('please provide a single --vcsInfoPath 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); | ||
| prok({ jsonSummaryPath, vcsInfoFilePath }, log); | ||
| }, | ||
| { | ||
| description: ` | ||
|
|
||
| Post code coverage in json-summary format to an ES index. | ||
| Note: You probably should create the index first. | ||
| Two indexes are needed, see README.md. | ||
|
|
||
| Examples: | ||
|
|
||
| See 'ingest_code_coverage_readme.md' | ||
|
|
||
| `, | ||
| flags, | ||
| } | ||
| ); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.