Skip to content

Commit

Permalink
[scripts/report_failed_tests] fix report_failed_tests integration on …
Browse files Browse the repository at this point in the history
…CI (#71131)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 13, 2020
1 parent 0ea414c commit ec43d45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/kbn-test/src/failed_tests_reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ A little CLI that runs in CI to find the failed tests in the JUnit reports, then
To fetch some JUnit reports from a recent build on CI, visit its `Google Cloud Storage Upload Report` and execute the following in the JS Console:

```js
copy(`wget "${Array.from($$('a[href$=".xml"]')).filter(a => a.innerText === 'Download').map(a => a.href.replace('https://storage.cloud.google.com/', 'https://storage.googleapis.com/')).join('" "')}"`)
copy(`wget -x -nH --cut-dirs 5 -P "target/downloaded_junit" "${Array.from($$('a[href$=".xml"]')).filter(a => a.innerText === 'Download').map(a => a.href.replace('https://storage.cloud.google.com/', 'https://storage.googleapis.com/')).join('" "')}"`)
```

This copies a script to download the reports, which you should execute in the `test/junit` directory.
This copies a script to download the reports, which you should execute in the root of the Kibana repository.

Next, run the CLI in `--no-github-update` mode so that it doesn't actually communicate with Github and `--no-report-update` to prevent the script from mutating the reports on disk and instead log the updated report.

```sh
node scripts/report_failed_tests.js --verbose --no-github-update --no-report-update
node scripts/report_failed_tests.js --verbose --no-github-update --no-report-update target/downloaded_junit/**/*.xml
```

Unless you specify the `GITHUB_TOKEN` environment variable requests to read existing issues will use anonymous access which is limited to 60 requests per hour.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import Path from 'path';

import { REPO_ROOT, run, createFailError, createFlagError } from '@kbn/dev-utils';
import globby from 'globby';

Expand All @@ -28,6 +30,8 @@ import { readTestReport } from './test_report';
import { addMessagesToReport } from './add_messages_to_report';
import { getReportMessageIter } from './report_metadata';

const DEFAULT_PATTERNS = [Path.resolve(REPO_ROOT, 'target/junit/**/*.xml')];

export function runFailedTestsReporterCli() {
run(
async ({ log, flags }) => {
Expand Down Expand Up @@ -67,11 +71,15 @@ export function runFailedTestsReporterCli() {
throw createFlagError('Missing --build-url or process.env.BUILD_URL');
}

const reportPaths = await globby(['target/junit/**/*.xml'], {
cwd: REPO_ROOT,
const patterns = flags._.length ? flags._ : DEFAULT_PATTERNS;
const reportPaths = await globby(patterns, {
absolute: true,
});

if (!reportPaths.length) {
throw createFailError(`Unable to find any junit reports with patterns [${patterns}]`);
}

const newlyCreatedIssues: Array<{
failure: TestFailure;
newIssue: GithubIssueMini;
Expand Down
2 changes: 1 addition & 1 deletion vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def runErrorReporter() {
bash(
"""
source src/dev/ci_setup/setup_env.sh
node scripts/report_failed_tests ${dryRun}
node scripts/report_failed_tests ${dryRun} target/junit/**/*.xml
""",
"Report failed tests, if necessary"
)
Expand Down

0 comments on commit ec43d45

Please sign in to comment.