Skip to content

Commit

Permalink
[6.x] [ci] Use trap to generate report for non-PR build (elastic#26829)…
Browse files Browse the repository at this point in the history
… (elastic#28531)

* [ci] Use trap to generate report for non-PR build (elastic#26829)

Since this is no longer part of a reporting task in Jenkins, we no
longer need to re-run kbn bootstrap when generating a report.

We use the PR_SOURCE_BRANCH environment variable to prevent genererating
Github issues when we are on a PR.

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Fix report test failures done callback (elastic#28348)
  • Loading branch information
joshdover authored Jan 11, 2019
1 parent 078b54b commit 94c4eb2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 17 deletions.
22 changes: 22 additions & 0 deletions src/dev/failed_tests/cli.js
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.
*/


require('../../setup_node_env');
require('./report').reportFailedTests();
4 changes: 2 additions & 2 deletions src/dev/failed_tests/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const updateGithubIssues = (githubClient, issues) => {
/**
* Scans all junit XML files in ./target/junit/ and reports any found test failures to Github Issues.
*/
export async function reportFailedTests(done) {
export async function reportFailedTests() {
const githubClient = getGithubClient();
const issues = await paginate(githubClient, githubClient.issues.getForRepo({
owner: GITHUB_OWNER,
Expand All @@ -148,5 +148,5 @@ export async function reportFailedTests(done) {
.pipe(mapXml)
.pipe(filterFailures)
.pipe(updateGithubIssues(githubClient, issues))
.on('done', done);
.on('done', () => console.log(`Finished reporting test failures.`));
}
10 changes: 0 additions & 10 deletions tasks/jenkins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* under the License.
*/

import { reportFailedTests } from '../src/dev/failed_tests/report';

module.exports = function (grunt) {
grunt.registerTask('jenkins:docs', [
'docker:docs'
Expand All @@ -41,12 +39,4 @@ module.exports = function (grunt) {
'test:browser-ci',
'run:apiIntegrationTests',
]);

grunt.registerTask(
'jenkins:report',
'Reports failed tests found in junit xml files to Github issues',
function () {
reportFailedTests(this.async());
}
);
};
11 changes: 11 additions & 0 deletions test/scripts/jenkins_ci_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

set -e

function report {
if [[ -z "$PR_SOURCE_BRANCH" ]]; then
node src/dev/failed_tests/cli
else
echo "Failure issues not created on pull requests"

fi
}

trap report EXIT

source src/dev/ci_setup/checkout_sibling_es.sh

"$(FORCE_COLOR=0 yarn bin)/grunt" functionalTests:ensureAllTestsInCiGroup;
Expand Down
5 changes: 0 additions & 5 deletions test/scripts/jenkins_report_failed_tests.sh

This file was deleted.

11 changes: 11 additions & 0 deletions test/scripts/jenkins_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@

set -e

function report {
if [[ -z "$PR_SOURCE_BRANCH" ]]; then
node src/dev/failed_tests/cli
else
echo "Failure issues not created on pull requests"
fi
}

trap report EXIT

source src/dev/ci_setup/checkout_sibling_es.sh

export TEST_BROWSER_HEADLESS=1
export TEST_ES_FROM=${TEST_ES_FROM:-source}

"$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:unit --from=source --dev;
11 changes: 11 additions & 0 deletions test/scripts/jenkins_xpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

set -e

function report {
if [[ -z "$PR_SOURCE_BRANCH" ]]; then
cd "$KIBANA_DIR"
node src/dev/failed_tests/cli
else
echo "Failure issues not created on pull requests"
fi
}

trap report EXIT

source src/dev/ci_setup/checkout_sibling_es.sh

export TEST_BROWSER_HEADLESS=1
Expand Down
11 changes: 11 additions & 0 deletions test/scripts/jenkins_xpack_ci_group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

set -e

function report {
if [[ -z "$PR_SOURCE_BRANCH" ]]; then
cd "$KIBANA_DIR"
node src/dev/failed_tests/cli
else
echo "Failure issues not created on pull requests"
fi
}

trap report EXIT

source src/dev/ci_setup/checkout_sibling_es.sh

export TEST_BROWSER_HEADLESS=1
Expand Down

0 comments on commit 94c4eb2

Please sign in to comment.