Skip to content

Commit e7290e3

Browse files
authored
implementing github checks - second attempt (elastic#35757)
implement github checks in ci
1 parent 5550b3b commit e7290e3

File tree

9 files changed

+277
-64
lines changed

9 files changed

+277
-64
lines changed

Diff for: github_checks_reporter.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"appId": 26774,
3+
"envVars": {
4+
"appKey": "KIBANA_CI_REPORTER_KEY"
5+
}
6+
}

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
"@babel/parser": "^7.3.4",
262262
"@babel/types": "^7.3.4",
263263
"@elastic/eslint-config-kibana": "0.15.0",
264+
"@elastic/github-checks-reporter": "0.0.11",
264265
"@elastic/makelogs": "^4.4.0",
265266
"@kbn/es": "1.0.0",
266267
"@kbn/eslint-import-resolver-kibana": "2.0.0",

Diff for: src/dev/ci_setup/setup.sh

+25
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,28 @@ if [ "$GIT_CHANGES" ]; then
180180
echo -e "$GIT_CHANGES\n"
181181
exit 1
182182
fi
183+
184+
###
185+
### github-checks-reporter kill switch. Remove to disable
186+
###
187+
export CHECKS_REPORTER_ACTIVE=true
188+
189+
### only run on pr jobs
190+
if [[ "$JOB_NAME" != "elastic+kibana+pull-request"* ]] ; then
191+
export CHECKS_REPORTER_ACTIVE=false
192+
fi
193+
194+
###
195+
### Implements github-checks-reporter kill switch when scripts are called from the command line
196+
### $@ - all arguments
197+
###
198+
function checks-reporter-with-killswitch() {
199+
if [ "$CHECKS_REPORTER_ACTIVE" == "true" ] ; then
200+
yarn run github-checks-reporter "$@"
201+
else
202+
arguments=("$@");
203+
"${arguments[@]:1}";
204+
fi
205+
}
206+
207+
export -f checks-reporter-with-killswitch

Diff for: tasks/config/run.js

+90-50
Original file line numberDiff line numberDiff line change
@@ -62,79 +62,101 @@ module.exports = function (grunt) {
6262
'--server.port=5610',
6363
];
6464

65+
const NODE = 'node';
66+
const scriptWithGithubChecks = ({ title, options, cmd, args }) => (
67+
process.env.CHECKS_REPORTER_ACTIVE === 'true' ? {
68+
options,
69+
cmd: 'yarn',
70+
args: ['run', 'github-checks-reporter', title, cmd, ...args],
71+
} : { options, cmd, args });
72+
const gruntTaskWithGithubChecks = (title, task) =>
73+
scriptWithGithubChecks({
74+
title,
75+
cmd: 'yarn',
76+
args: ['run', 'grunt', task]
77+
});
78+
6579
return {
6680
// used by the test and jenkins:unit tasks
6781
// runs the eslint script to check for linting errors
68-
eslint: {
69-
cmd: process.execPath,
82+
eslint: scriptWithGithubChecks({
83+
title: 'eslint',
84+
cmd: NODE,
7085
args: [
71-
require.resolve('../../scripts/eslint'),
86+
'scripts/eslint',
7287
'--no-cache'
7388
]
74-
},
89+
}),
7590

76-
sasslint: {
77-
cmd: process.execPath,
91+
sasslint: scriptWithGithubChecks({
92+
title: 'sasslint',
93+
cmd: NODE,
7894
args: [
79-
require.resolve('../../scripts/sasslint')
95+
'scripts/sasslint'
8096
]
81-
},
97+
}),
8298

8399
// used by the test tasks
84100
// runs the check_file_casing script to ensure filenames use correct casing
85-
checkFileCasing: {
86-
cmd: process.execPath,
101+
checkFileCasing: scriptWithGithubChecks({
102+
title: 'Check file casing',
103+
cmd: NODE,
87104
args: [
88-
require.resolve('../../scripts/check_file_casing'),
105+
'scripts/check_file_casing',
89106
'--quiet' // only log errors, not warnings
90107
]
91-
},
108+
}),
92109

93110
// used by the test tasks
94111
// runs the check_core_api_changes script to ensure API changes are explictily accepted
95-
checkCoreApiChanges: {
96-
cmd: process.execPath,
112+
checkCoreApiChanges: scriptWithGithubChecks({
113+
title: 'Check core API changes',
114+
cmd: NODE,
97115
args: [
98-
require.resolve('../../scripts/check_core_api_changes')
116+
'scripts/check_core_api_changes'
99117
]
100-
},
118+
}),
101119

102120
// used by the test and jenkins:unit tasks
103121
// runs the typecheck script to check for Typescript type errors
104-
typeCheck: {
105-
cmd: process.execPath,
122+
typeCheck: scriptWithGithubChecks({
123+
title: 'Type check',
124+
cmd: NODE,
106125
args: [
107-
require.resolve('../../scripts/type_check')
126+
'scripts/type_check'
108127
]
109-
},
128+
}),
110129

111130
// used by the test and jenkins:unit tasks
112131
// ensures that all typescript files belong to a typescript project
113-
checkTsProjects: {
114-
cmd: process.execPath,
132+
checkTsProjects: scriptWithGithubChecks({
133+
title: 'TypeScript - all files belong to a TypeScript project',
134+
cmd: NODE,
115135
args: [
116-
require.resolve('../../scripts/check_ts_projects')
136+
'scripts/check_ts_projects'
117137
]
118-
},
138+
}),
119139

120140
// used by the test and jenkins:unit tasks
121141
// runs the i18n_check script to check i18n engine usage
122-
i18nCheck: {
123-
cmd: process.execPath,
142+
i18nCheck: scriptWithGithubChecks({
143+
title: 'Internationalization check',
144+
cmd: NODE,
124145
args: [
125-
require.resolve('../../scripts/i18n_check'),
146+
'scripts/i18n_check',
126147
'--ignore-missing',
127148
]
128-
},
149+
}),
129150

130151
// used by the test:server task
131152
// runs all node.js/server mocha tests
132-
mocha: {
133-
cmd: process.execPath,
153+
mocha: scriptWithGithubChecks({
154+
title: 'Mocha tests',
155+
cmd: NODE,
134156
args: [
135-
require.resolve('../../scripts/mocha')
157+
'scripts/mocha'
136158
]
137-
},
159+
}),
138160

139161
// used by the test:browser task
140162
// runs the kibana server to serve the browser test bundle
@@ -175,29 +197,32 @@ module.exports = function (grunt) {
175197
]
176198
}),
177199

178-
verifyNotice: {
200+
verifyNotice: scriptWithGithubChecks({
201+
title: 'Verify NOTICE.txt',
179202
options: {
180203
wait: true,
181204
},
182-
cmd: process.execPath,
205+
cmd: NODE,
183206
args: [
184207
'scripts/notice',
185208
'--validate'
186209
]
187-
},
210+
}),
188211

189-
apiIntegrationTests: {
190-
cmd: process.execPath,
212+
apiIntegrationTests: scriptWithGithubChecks({
213+
title: 'API integration tests',
214+
cmd: NODE,
191215
args: [
192216
'scripts/functional_tests',
193217
'--config', 'test/api_integration/config.js',
194218
'--bail',
195219
'--debug',
196220
],
197-
},
221+
}),
198222

199-
serverIntegrationTests: {
200-
cmd: process.execPath,
223+
serverIntegrationTests: scriptWithGithubChecks({
224+
title: 'Server integration tests',
225+
cmd: NODE,
201226
args: [
202227
'scripts/functional_tests',
203228
'--config', 'test/server_integration/http/ssl/config.js',
@@ -206,39 +231,54 @@ module.exports = function (grunt) {
206231
'--debug',
207232
'--kibana-install-dir', KIBANA_INSTALL_DIR,
208233
],
209-
},
234+
}),
210235

211-
interpreterFunctionalTestsRelease: {
212-
cmd: process.execPath,
236+
interpreterFunctionalTestsRelease: scriptWithGithubChecks({
237+
title: 'Interpreter functional tests',
238+
cmd: NODE,
213239
args: [
214240
'scripts/functional_tests',
215241
'--config', 'test/interpreter_functional/config.js',
216242
'--bail',
217243
'--debug',
218244
'--kibana-install-dir', KIBANA_INSTALL_DIR,
219245
],
220-
},
246+
}),
221247

222-
pluginFunctionalTestsRelease: {
223-
cmd: process.execPath,
248+
pluginFunctionalTestsRelease: scriptWithGithubChecks({
249+
title: 'Plugin functional tests',
250+
cmd: NODE,
224251
args: [
225252
'scripts/functional_tests',
226253
'--config', 'test/plugin_functional/config.js',
227254
'--bail',
228255
'--debug',
229256
'--kibana-install-dir', KIBANA_INSTALL_DIR,
230257
],
231-
},
258+
}),
232259

233-
functionalTests: {
234-
cmd: process.execPath,
260+
functionalTests: scriptWithGithubChecks({
261+
title: 'Functional tests',
262+
cmd: NODE,
235263
args: [
236264
'scripts/functional_tests',
237265
'--config', 'test/functional/config.js',
238266
'--bail',
239267
'--debug',
240268
],
241-
},
269+
}),
270+
271+
licenses: gruntTaskWithGithubChecks('Licenses', 'licenses'),
272+
verifyDependencyVersions:
273+
gruntTaskWithGithubChecks('Verify dependency versions', 'verifyDependencyVersions'),
274+
test_server:
275+
gruntTaskWithGithubChecks('Server tests', 'test:server'),
276+
test_jest: gruntTaskWithGithubChecks('Jest tests', 'test:jest'),
277+
test_jest_integration:
278+
gruntTaskWithGithubChecks('Jest integration tests', 'test:jest_integration'),
279+
test_projects: gruntTaskWithGithubChecks('Project tests', 'test:projects'),
280+
test_browser_ci:
281+
gruntTaskWithGithubChecks('Browser tests', 'test:browser-ci'),
242282

243283
...getFunctionalTestGroupRunConfigs({
244284
kibanaInstallDir: KIBANA_INSTALL_DIR

Diff for: tasks/jenkins.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ module.exports = function (grunt) {
3030
'run:typeCheck',
3131
'run:i18nCheck',
3232
'run:checkFileCasing',
33-
'licenses',
34-
'verifyDependencyVersions',
33+
'run:licenses',
34+
'run:verifyDependencyVersions',
3535
'run:verifyNotice',
36-
'test:server',
37-
'test:jest',
38-
'test:jest_integration',
39-
'test:projects',
40-
'test:browser-ci',
36+
'run:test_server',
37+
'run:test_jest',
38+
'run:test_jest_integration',
39+
'run:test_projects',
40+
'run:test_browser_ci',
4141
'run:apiIntegrationTests',
4242
]);
4343
};

Diff for: test/scripts/jenkins_ci_group.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ node scripts/build --debug --oss;
1919

2020
export TEST_BROWSER_HEADLESS=1
2121

22-
"$(FORCE_COLOR=0 yarn bin)/grunt" "run:functionalTests_ciGroup${CI_GROUP}";
22+
checks-reporter-with-killswitch "Functional tests / Group ${CI_GROUP}" yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}";
2323

2424
if [ "$CI_GROUP" == "1" ]; then
2525
# build kbn_tp_sample_panel_action
2626
cd test/plugin_functional/plugins/kbn_tp_sample_panel_action;
27-
yarn build;
27+
checks-reporter-with-killswitch "Build kbn_tp_sample_panel_action" yarn build;
2828
cd -;
29-
"$(FORCE_COLOR=0 yarn bin)/grunt" run:pluginFunctionalTestsRelease --from=source;
30-
"$(FORCE_COLOR=0 yarn bin)/grunt" run:interpreterFunctionalTestsRelease;
29+
yarn run grunt run:pluginFunctionalTestsRelease --from=source;
30+
yarn run grunt run:interpreterFunctionalTestsRelease;
3131
fi

Diff for: test/scripts/jenkins_xpack.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export TEST_BROWSER_HEADLESS=1
1717

1818
echo " -> Running mocha tests"
1919
cd "$XPACK_DIR"
20-
yarn test
20+
checks-reporter-with-killswitch "X-Pack Mocha" yarn test
2121
echo ""
2222
echo ""
2323

2424
echo " -> Running jest tests"
2525
cd "$XPACK_DIR"
26-
node scripts/jest --ci --no-cache --verbose
26+
checks-reporter-with-killswitch "X-Pack Jest" node scripts/jest --ci --no-cache --verbose
2727
echo ""
2828
echo ""
2929

Diff for: test/scripts/jenkins_xpack_ci_group.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ tar -xzf "$linuxBuild" -C "$installDir" --strip=1
3636

3737
echo " -> Running functional and api tests"
3838
cd "$XPACK_DIR"
39-
node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir" --include-tag "ciGroup$CI_GROUP"
39+
checks-reporter-with-killswitch "X-Pack Functional tests / Group ${CI_GROUP}" node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir" --include-tag "ciGroup$CI_GROUP"
4040
echo ""
4141
echo ""

0 commit comments

Comments
 (0)