mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 13:57:09 +01:00
Add option of use-actions-summary
This commit is contained in:
parent
bd77050543
commit
3608ee03fd
17 changed files with 4236 additions and 402 deletions
|
|
@ -138,6 +138,10 @@ jobs:
|
|||
# Detailed listing of test suites and test cases will be skipped.
|
||||
only-summary: 'false'
|
||||
|
||||
# Allows you to generate reports for Actions Summary
|
||||
# https://github.com/orgs/github/teams/engineering/discussions/871
|
||||
use-actions-summary: 'true'
|
||||
|
||||
# Limits which test suites are listed:
|
||||
# all
|
||||
# failed
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[test/main_test.dart](#r0s0)|1:white_check_mark:|3:x:||74ms|
|
||||
|[test/second_test.dart](#r0s1)||1:x:|1:no_entry_sign:|51ms|
|
||||
|[test/second_test.dart](#r0s1)||1:x:|1:warning:|51ms|
|
||||
### :x: <a id="user-content-r0s0" href="#r0s0">test/main_test.dart</a>
|
||||
```
|
||||
Test 1
|
||||
|
|
@ -24,5 +24,5 @@ Test 2
|
|||
```
|
||||
:x: Timeout test
|
||||
TimeoutException after 0:00:00.000001: Test timed out after 0 seconds.
|
||||
:no_entry_sign: Skipped test
|
||||
:warning: Skipped test
|
||||
```
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
**11** tests were completed in **1s** with **5** passed, **5** failed and **1** skipped.
|
||||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[DotnetTests.XUnitTests.CalculatorTests](#r0s0)|5:white_check_mark:|5:x:|1:no_entry_sign:|118ms|
|
||||
|[DotnetTests.XUnitTests.CalculatorTests](#r0s0)|5:white_check_mark:|5:x:|1:warning:|118ms|
|
||||
### :x: <a id="user-content-r0s0" href="#r0s0">DotnetTests.XUnitTests.CalculatorTests</a>
|
||||
```
|
||||
:white_check_mark: Custom Name
|
||||
|
|
@ -26,6 +26,6 @@
|
|||
Assert.True() Failure
|
||||
Expected: True
|
||||
Actual: False
|
||||
:no_entry_sign: Skipped_Test
|
||||
:warning: Skipped_Test
|
||||
:white_check_mark: Timeout_Test
|
||||
```
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,7 @@
|
|||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[__tests__\main.test.js](#r0s0)|1:white_check_mark:|3:x:||486ms|
|
||||
|[__tests__\second.test.js](#r0s1)||1:x:|1:no_entry_sign:|82ms|
|
||||
|[__tests__\second.test.js](#r0s1)||1:x:|1:warning:|82ms|
|
||||
### :x: <a id="user-content-r0s0" href="#r0s0">__tests__\main.test.js</a>
|
||||
```
|
||||
Test 1
|
||||
|
|
@ -22,5 +22,5 @@ Test 2
|
|||
```
|
||||
:x: Timeout test
|
||||
: Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 1 ms timeout specified by jest.setTimeout.Error:
|
||||
:no_entry_sign: Skipped test
|
||||
:warning: Skipped test
|
||||
```
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
|e2e/__tests__/babelPluginJestHoist.test.ts|1:white_check_mark:|||6s|
|
||||
|e2e/__tests__/badSourceMap.test.ts|1:white_check_mark:|||858ms|
|
||||
|e2e/__tests__/beforeAllFiltered.ts|1:white_check_mark:|||958ms|
|
||||
|e2e/__tests__/beforeEachQueue.ts|1:white_check_mark:||1:no_entry_sign:|55ms|
|
||||
|e2e/__tests__/beforeEachQueue.ts|1:white_check_mark:||1:warning:|55ms|
|
||||
|e2e/__tests__/callDoneTwice.test.ts|1:white_check_mark:|||882ms|
|
||||
|e2e/__tests__/chaiAssertionLibrary.ts|1:white_check_mark:|||2s|
|
||||
|e2e/__tests__/circularInequality.test.ts|1:white_check_mark:|||1s|
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
|e2e/__tests__/emptySuiteError.test.ts|1:white_check_mark:|||885ms|
|
||||
|e2e/__tests__/env.test.ts|6:white_check_mark:|||5s|
|
||||
|e2e/__tests__/environmentAfterTeardown.test.ts|1:white_check_mark:|||892ms|
|
||||
|e2e/__tests__/errorOnDeprecated.test.ts|1:white_check_mark:||24:no_entry_sign:|56ms|
|
||||
|e2e/__tests__/errorOnDeprecated.test.ts|1:white_check_mark:||24:warning:|56ms|
|
||||
|e2e/__tests__/esmConfigFile.test.ts|3:white_check_mark:|||526ms|
|
||||
|e2e/__tests__/executeTestsOnceInMpr.ts|1:white_check_mark:|||976ms|
|
||||
|e2e/__tests__/existentRoots.test.ts|4:white_check_mark:|||627ms|
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
|e2e/__tests__/importedGlobals.test.ts|1:white_check_mark:|||1s|
|
||||
|e2e/__tests__/injectGlobals.test.ts|2:white_check_mark:|||2s|
|
||||
|e2e/__tests__/jasmineAsync.test.ts|15:white_check_mark:|||28s|
|
||||
|e2e/__tests__/jasmineAsyncWithPendingDuringTest.ts|1:white_check_mark:||1:no_entry_sign:|72ms|
|
||||
|e2e/__tests__/jasmineAsyncWithPendingDuringTest.ts|1:white_check_mark:||1:warning:|72ms|
|
||||
|e2e/__tests__/jest.config.js.test.ts|3:white_check_mark:|||2s|
|
||||
|e2e/__tests__/jest.config.ts.test.ts|5:white_check_mark:|||14s|
|
||||
|[e2e/__tests__/jestChangedFiles.test.ts](#r0s75)|9:white_check_mark:|1:x:||9s|
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
|e2e/__tests__/moduleParentNullInTest.ts|1:white_check_mark:|||886ms|
|
||||
|e2e/__tests__/multiProjectRunner.test.ts|14:white_check_mark:|||16s|
|
||||
|e2e/__tests__/nativeAsyncMock.test.ts|1:white_check_mark:|||55ms|
|
||||
|e2e/__tests__/nativeEsm.test.ts|2:white_check_mark:||1:no_entry_sign:|905ms|
|
||||
|e2e/__tests__/nativeEsm.test.ts|2:white_check_mark:||1:warning:|905ms|
|
||||
|e2e/__tests__/nativeEsmTypescript.test.ts|1:white_check_mark:|||956ms|
|
||||
|e2e/__tests__/nestedEventLoop.test.ts|1:white_check_mark:|||1s|
|
||||
|e2e/__tests__/nestedTestDefinitions.test.ts|4:white_check_mark:|||5s|
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
|e2e/__tests__/testRetries.test.ts|4:white_check_mark:|||3s|
|
||||
|e2e/__tests__/testTodo.test.ts|5:white_check_mark:|||4s|
|
||||
|e2e/__tests__/timeouts.test.ts|4:white_check_mark:|||4s|
|
||||
|e2e/__tests__/timeoutsLegacy.test.ts|1:white_check_mark:||3:no_entry_sign:|71ms|
|
||||
|e2e/__tests__/timeoutsLegacy.test.ts|1:white_check_mark:||3:warning:|71ms|
|
||||
|e2e/__tests__/timerResetMocks.test.ts|2:white_check_mark:|||2s|
|
||||
|e2e/__tests__/timerUseRealTimers.test.ts|1:white_check_mark:|||1s|
|
||||
|e2e/__tests__/toMatchInlineSnapshot.test.ts|12:white_check_mark:|||24s|
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[test/main.test.js](#r0s0)|1:white_check_mark:|3:x:||1ms|
|
||||
|[test/second.test.js](#r0s1)||1:x:|1:no_entry_sign:|8ms|
|
||||
|[test/second.test.js](#r0s1)||1:x:|1:warning:|8ms|
|
||||
### :x: <a id="user-content-r0s0" href="#r0s0">test/main.test.js</a>
|
||||
```
|
||||
Test 1
|
||||
|
|
@ -23,7 +23,7 @@ Test 2
|
|||
```
|
||||
### :x: <a id="user-content-r0s1" href="#r0s1">test/second.test.js</a>
|
||||
```
|
||||
:no_entry_sign: Skipped test
|
||||
:warning: Skipped test
|
||||
:x: Timeout test
|
||||
Timeout of 1ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (C:\Users\Michal\Workspace\dorny\test-reporter\reports\mocha\test\second.test.js)
|
||||
```
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -3,10 +3,10 @@
|
|||
**2** tests were completed in **116ms** with **0** passed, **1** failed and **1** skipped.
|
||||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[org.apache.pulsar.AddMissingPatchVersionTest](#r0s0)||1:x:|1:no_entry_sign:|116ms|
|
||||
|[org.apache.pulsar.AddMissingPatchVersionTest](#r0s0)||1:x:|1:warning:|116ms|
|
||||
### :x: <a id="user-content-r0s0" href="#r0s0">org.apache.pulsar.AddMissingPatchVersionTest</a>
|
||||
```
|
||||
:no_entry_sign: testVersionStrings
|
||||
:warning: testVersionStrings
|
||||
:x: testVersionStrings
|
||||
java.lang.AssertionError: expected [1.2.1] but found [1.2.0]
|
||||
```
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -4,11 +4,11 @@
|
|||
|Test suite|Passed|Failed|Skipped|Time|
|
||||
|:---|---:|---:|---:|---:|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageCredentialsTest](#r0s0)|6:white_check_mark:|||30ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.DropboxCloudStorageClientTest](#r0s1)|2:white_check_mark:||3:no_entry_sign:|101ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.FtpCloudStorageClientTest](#r0s2)|4:white_check_mark:||3:no_entry_sign:|166ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.DropboxCloudStorageClientTest](#r0s1)|2:white_check_mark:||3:warning:|101ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.FtpCloudStorageClientTest](#r0s2)|4:white_check_mark:||3:warning:|166ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.GmxCloudStorageClientTest](#r0s3)|2:white_check_mark:|||7ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.GoogleCloudStorageClientTest](#r0s4)|1:white_check_mark:||3:no_entry_sign:|40ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.OnedriveCloudStorageClientTest](#r0s5)|1:white_check_mark:||3:no_entry_sign:|15ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.GoogleCloudStorageClientTest](#r0s4)|1:white_check_mark:||3:warning:|40ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.OnedriveCloudStorageClientTest](#r0s5)|1:white_check_mark:||3:warning:|15ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageProviders.WebdavCloudStorageClientTest](#r0s6)|5:white_check_mark:|||16ms|
|
||||
|[VanillaCloudStorageClientTest.CloudStorageTokenTest](#r0s7)|9:white_check_mark:|||0ms|
|
||||
|[VanillaCloudStorageClientTest.OAuth2.AuthorizationResponseErrorTest](#r0s8)|3:white_check_mark:|||3ms|
|
||||
|
|
@ -28,9 +28,9 @@
|
|||
### :white_check_mark: <a id="user-content-r0s1" href="#r0s1">VanillaCloudStorageClientTest.CloudStorageProviders.DropboxCloudStorageClientTest</a>
|
||||
```
|
||||
:white_check_mark: FileLifecycleWorks
|
||||
:no_entry_sign: ReallyDoFetchToken
|
||||
:no_entry_sign: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:no_entry_sign: ReallyDoRefreshToken
|
||||
:warning: ReallyDoFetchToken
|
||||
:warning: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:warning: ReallyDoRefreshToken
|
||||
:white_check_mark: ThrowsAccessDeniedExceptionWithInvalidToken
|
||||
```
|
||||
### :white_check_mark: <a id="user-content-r0s2" href="#r0s2">VanillaCloudStorageClientTest.CloudStorageProviders.FtpCloudStorageClientTest</a>
|
||||
|
|
@ -39,9 +39,9 @@
|
|||
:white_check_mark: SanitizeCredentials_ChangesInvalidPrefix
|
||||
:white_check_mark: SecureSslConnectionWorks
|
||||
:white_check_mark: ThrowsWithHttpInsteadOfFtp
|
||||
:no_entry_sign: ThrowsWithInvalidPassword
|
||||
:no_entry_sign: ThrowsWithInvalidUrl
|
||||
:no_entry_sign: ThrowsWithInvalidUsername
|
||||
:warning: ThrowsWithInvalidPassword
|
||||
:warning: ThrowsWithInvalidUrl
|
||||
:warning: ThrowsWithInvalidUsername
|
||||
```
|
||||
### :white_check_mark: <a id="user-content-r0s3" href="#r0s3">VanillaCloudStorageClientTest.CloudStorageProviders.GmxCloudStorageClientTest</a>
|
||||
```
|
||||
|
|
@ -51,16 +51,16 @@
|
|||
### :white_check_mark: <a id="user-content-r0s4" href="#r0s4">VanillaCloudStorageClientTest.CloudStorageProviders.GoogleCloudStorageClientTest</a>
|
||||
```
|
||||
:white_check_mark: FileLifecycleWorks
|
||||
:no_entry_sign: ReallyDoFetchToken
|
||||
:no_entry_sign: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:no_entry_sign: ReallyDoRefreshToken
|
||||
:warning: ReallyDoFetchToken
|
||||
:warning: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:warning: ReallyDoRefreshToken
|
||||
```
|
||||
### :white_check_mark: <a id="user-content-r0s5" href="#r0s5">VanillaCloudStorageClientTest.CloudStorageProviders.OnedriveCloudStorageClientTest</a>
|
||||
```
|
||||
:white_check_mark: FileLifecycleWorks
|
||||
:no_entry_sign: ReallyDoFetchToken
|
||||
:no_entry_sign: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:no_entry_sign: ReallyDoRefreshToken
|
||||
:warning: ReallyDoFetchToken
|
||||
:warning: ReallyDoOpenAuthorizationPageInBrowser
|
||||
:warning: ReallyDoRefreshToken
|
||||
```
|
||||
### :white_check_mark: <a id="user-content-r0s6" href="#r0s6">VanillaCloudStorageClientTest.CloudStorageProviders.WebdavCloudStorageClientTest</a>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -68,6 +68,12 @@ inputs:
|
|||
Detailed listing of test suites and test cases will be skipped.
|
||||
default: 'false'
|
||||
required: false
|
||||
use-actions-summary:
|
||||
description: |
|
||||
Allows you to generate reports for Actions Summary
|
||||
https://github.com/orgs/github/teams/engineering/discussions/871
|
||||
default: 'true'
|
||||
required: false
|
||||
badge-title:
|
||||
description: Customize badge title
|
||||
required: false
|
||||
|
|
|
|||
187
dist/index.js
generated
vendored
187
dist/index.js
generated
vendored
|
|
@ -259,6 +259,7 @@ const github = __importStar(__nccwpck_require__(5438));
|
|||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
const artifact_provider_1 = __nccwpck_require__(7171);
|
||||
const local_file_provider_1 = __nccwpck_require__(9399);
|
||||
const get_annotations_1 = __nccwpck_require__(5867);
|
||||
const get_report_1 = __nccwpck_require__(3737);
|
||||
const dart_json_parser_1 = __nccwpck_require__(4528);
|
||||
const dotnet_trx_parser_1 = __nccwpck_require__(2664);
|
||||
|
|
@ -267,6 +268,7 @@ const jest_junit_parser_1 = __nccwpck_require__(1113);
|
|||
const mocha_json_parser_1 = __nccwpck_require__(6043);
|
||||
const path_utils_1 = __nccwpck_require__(4070);
|
||||
const github_utils_1 = __nccwpck_require__(3522);
|
||||
const markdown_utils_1 = __nccwpck_require__(6482);
|
||||
function main() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
|
|
@ -294,6 +296,7 @@ class TestReporter {
|
|||
this.failOnError = core.getInput('fail-on-error', { required: true }) === 'true';
|
||||
this.workDirInput = core.getInput('working-directory', { required: false });
|
||||
this.onlySummary = core.getInput('only-summary', { required: false }) === 'true';
|
||||
this.useActionsSummary = core.getInput('use-actions-summary', { required: false }) === 'true';
|
||||
this.badgeTitle = core.getInput('badge-title', { required: false });
|
||||
this.token = core.getInput('token', { required: true });
|
||||
this.context = (0, github_utils_1.getCheckRunContext)();
|
||||
|
|
@ -381,46 +384,43 @@ class TestReporter {
|
|||
const tr = yield parser.parse(file, content);
|
||||
results.push(tr);
|
||||
}
|
||||
// core.info(`Creating check run ${name}`)
|
||||
// const createResp = await this.octokit.checks.create({
|
||||
// head_sha: this.context.sha,
|
||||
// name,
|
||||
// status: 'in_progress',
|
||||
// output: {
|
||||
// title: name,
|
||||
// summary: ''
|
||||
// },
|
||||
// ...github.context.repo
|
||||
// })
|
||||
core.info('Creating report summary');
|
||||
const { listSuites, listTests, onlySummary, badgeTitle } = this;
|
||||
const baseUrl = '';
|
||||
const summary = (0, get_report_1.getReport)(results, { listSuites, listTests, baseUrl, onlySummary, badgeTitle });
|
||||
core.info('Summary content:');
|
||||
core.info(summary);
|
||||
yield fs.promises.writeFile(this.path.replace('*.trx', 'test-summary.md'), summary);
|
||||
core.info('File content:');
|
||||
core.info(fs.readFileSync(this.path.replace('*.trx', 'test-summary.md'), 'utf8'));
|
||||
// core.info('Creating annotations')
|
||||
// const annotations = getAnnotations(results, this.maxAnnotations)
|
||||
// const isFailed = results.some(tr => tr.result === 'failed')
|
||||
// const conclusion = isFailed ? 'failure' : 'success'
|
||||
// const icon = isFailed ? Icon.fail : Icon.success
|
||||
// core.info(`Updating check run conclusion (${conclusion}) and output`)
|
||||
// const resp = await this.octokit.checks.update({
|
||||
// check_run_id: createResp.data.id,
|
||||
// conclusion,
|
||||
// status: 'completed',
|
||||
// output: {
|
||||
// title: `${name} ${icon}`,
|
||||
// summary,
|
||||
// annotations
|
||||
// },
|
||||
// ...github.context.repo
|
||||
// })
|
||||
// core.info(`Check run create response: ${resp.status}`)
|
||||
// core.info(`Check run URL: ${resp.data.url}`)
|
||||
// core.info(`Check run HTML: ${resp.data.html_url}`)
|
||||
const { listSuites, listTests, onlySummary, useActionsSummary, badgeTitle } = this;
|
||||
let baseUrl = '';
|
||||
let checkRunId = 0;
|
||||
if (!this.useActionsSummary) {
|
||||
core.info(`Creating check run ${name}`);
|
||||
const createResp = yield this.octokit.rest.checks.create(Object.assign({ head_sha: this.context.sha, name, status: 'in_progress', output: {
|
||||
title: name,
|
||||
summary: ''
|
||||
} }, github.context.repo));
|
||||
baseUrl = createResp.data.html_url;
|
||||
checkRunId = createResp.data.id;
|
||||
}
|
||||
const summary = (0, get_report_1.getReport)(results, { listSuites, listTests, baseUrl, onlySummary, useActionsSummary, badgeTitle });
|
||||
if (this.useActionsSummary) {
|
||||
core.info('Summary content:');
|
||||
core.info(summary);
|
||||
yield fs.promises.writeFile(this.path.replace('*.trx', 'test-summary.md'), summary);
|
||||
core.info('File content:');
|
||||
core.info(fs.readFileSync(this.path.replace('*.trx', 'test-summary.md'), 'utf8'));
|
||||
}
|
||||
if (!this.useActionsSummary) {
|
||||
core.info('Creating annotations');
|
||||
const annotations = (0, get_annotations_1.getAnnotations)(results, this.maxAnnotations);
|
||||
const isFailed = results.some(tr => tr.result === 'failed');
|
||||
const conclusion = isFailed ? 'failure' : 'success';
|
||||
const icon = isFailed ? markdown_utils_1.Icon.fail : markdown_utils_1.Icon.success;
|
||||
core.info(`Updating check run conclusion (${conclusion}) and output`);
|
||||
const resp = yield this.octokit.rest.checks.update(Object.assign({ check_run_id: checkRunId, conclusion, status: 'completed', output: {
|
||||
title: `${name} ${icon}`,
|
||||
summary,
|
||||
annotations
|
||||
} }, github.context.repo));
|
||||
core.info(`Check run create response: ${resp.status}`);
|
||||
core.info(`Check run URL: ${resp.data.url}`);
|
||||
core.info(`Check run HTML: ${resp.data.html_url}`);
|
||||
}
|
||||
return results;
|
||||
});
|
||||
}
|
||||
|
|
@ -1361,6 +1361,94 @@ class MochaJsonParser {
|
|||
exports.MochaJsonParser = MochaJsonParser;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5867:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getAnnotations = void 0;
|
||||
const markdown_utils_1 = __nccwpck_require__(6482);
|
||||
const parse_utils_1 = __nccwpck_require__(7811);
|
||||
function getAnnotations(results, maxCount) {
|
||||
var _a, _b, _c, _d;
|
||||
if (maxCount === 0) {
|
||||
return [];
|
||||
}
|
||||
// Collect errors from TestRunResults
|
||||
// Merge duplicates if there are more test results files processed
|
||||
const errors = [];
|
||||
const mergeDup = results.length > 1;
|
||||
for (const tr of results) {
|
||||
for (const ts of tr.suites) {
|
||||
for (const tg of ts.groups) {
|
||||
for (const tc of tg.tests) {
|
||||
const err = tc.error;
|
||||
if (err === undefined) {
|
||||
continue;
|
||||
}
|
||||
const path = (_a = err.path) !== null && _a !== void 0 ? _a : tr.path;
|
||||
const line = (_b = err.line) !== null && _b !== void 0 ? _b : 0;
|
||||
if (mergeDup) {
|
||||
const dup = errors.find(e => path === e.path && line === e.line && err.details === e.details);
|
||||
if (dup !== undefined) {
|
||||
dup.testRunPaths.push(tr.path);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
errors.push({
|
||||
testRunPaths: [tr.path],
|
||||
suiteName: ts.name,
|
||||
testName: tg.name ? `${tg.name} ► ${tc.name}` : tc.name,
|
||||
details: err.details,
|
||||
message: (_d = (_c = err.message) !== null && _c !== void 0 ? _c : (0, parse_utils_1.getFirstNonEmptyLine)(err.details)) !== null && _d !== void 0 ? _d : 'Test failed',
|
||||
path,
|
||||
line
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Limit number of created annotations
|
||||
errors.splice(maxCount + 1);
|
||||
const annotations = errors.map(e => {
|
||||
const message = [
|
||||
'Failed test found in:',
|
||||
e.testRunPaths.map(p => ` ${p}`).join('\n'),
|
||||
'Error:',
|
||||
ident((0, markdown_utils_1.fixEol)(e.message), ' ')
|
||||
].join('\n');
|
||||
return enforceCheckRunLimits({
|
||||
path: e.path,
|
||||
start_line: e.line,
|
||||
end_line: e.line,
|
||||
annotation_level: 'failure',
|
||||
title: `${e.suiteName} ► ${e.testName}`,
|
||||
raw_details: (0, markdown_utils_1.fixEol)(e.details),
|
||||
message
|
||||
});
|
||||
});
|
||||
return annotations;
|
||||
}
|
||||
exports.getAnnotations = getAnnotations;
|
||||
function enforceCheckRunLimits(err) {
|
||||
err.title = (0, markdown_utils_1.ellipsis)(err.title || '', 255);
|
||||
err.message = (0, markdown_utils_1.ellipsis)(err.message, 65535);
|
||||
if (err.raw_details) {
|
||||
err.raw_details = (0, markdown_utils_1.ellipsis)(err.raw_details, 65535);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
function ident(text, prefix) {
|
||||
return text
|
||||
.split(/\n/g)
|
||||
.map(line => prefix + line)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3737:
|
||||
|
|
@ -1399,11 +1487,13 @@ const node_utils_1 = __nccwpck_require__(5824);
|
|||
const parse_utils_1 = __nccwpck_require__(7811);
|
||||
const slugger_1 = __nccwpck_require__(3328);
|
||||
const MAX_REPORT_LENGTH = 65535;
|
||||
const MAX_ACTIONS_SUMMARY_LENGTH = 131072; // 1048576 soon
|
||||
const defaultOptions = {
|
||||
listSuites: 'all',
|
||||
listTests: 'all',
|
||||
baseUrl: '',
|
||||
onlySummary: false,
|
||||
useActionsSummary: true,
|
||||
badgeTitle: 'tests'
|
||||
};
|
||||
function getReport(results, options = defaultOptions) {
|
||||
|
|
@ -1412,7 +1502,7 @@ function getReport(results, options = defaultOptions) {
|
|||
const opts = Object.assign({}, options);
|
||||
let lines = renderReport(results, opts);
|
||||
let report = lines.join('\n');
|
||||
if (getByteLength(report) <= MAX_REPORT_LENGTH) {
|
||||
if (getByteLength(report) <= getMaxReportLength(options)) {
|
||||
return report;
|
||||
}
|
||||
if (opts.listTests === 'all') {
|
||||
|
|
@ -1420,19 +1510,22 @@ function getReport(results, options = defaultOptions) {
|
|||
opts.listTests = 'failed';
|
||||
lines = renderReport(results, opts);
|
||||
report = lines.join('\n');
|
||||
if (getByteLength(report) <= MAX_REPORT_LENGTH) {
|
||||
if (getByteLength(report) <= getMaxReportLength(options)) {
|
||||
return report;
|
||||
}
|
||||
}
|
||||
core.warning(`Test report summary exceeded limit of ${MAX_REPORT_LENGTH} bytes and will be trimmed`);
|
||||
return trimReport(lines);
|
||||
core.warning(`Test report summary exceeded limit of ${getMaxReportLength(options)} bytes and will be trimmed`);
|
||||
return trimReport(lines, options);
|
||||
}
|
||||
exports.getReport = getReport;
|
||||
function trimReport(lines) {
|
||||
function getMaxReportLength(options = defaultOptions) {
|
||||
return options.useActionsSummary ? MAX_ACTIONS_SUMMARY_LENGTH : MAX_REPORT_LENGTH;
|
||||
}
|
||||
function trimReport(lines, options) {
|
||||
const closingBlock = '```';
|
||||
const errorMsg = `**Report exceeded GitHub limit of ${MAX_REPORT_LENGTH} bytes and has been trimmed**`;
|
||||
const errorMsg = `**Report exceeded GitHub limit of ${getMaxReportLength(options)} bytes and has been trimmed**`;
|
||||
const maxErrorMsgLength = closingBlock.length + errorMsg.length + 2;
|
||||
const maxReportLength = MAX_REPORT_LENGTH - maxErrorMsgLength;
|
||||
const maxReportLength = getMaxReportLength(options) - maxErrorMsgLength;
|
||||
let reportLength = 0;
|
||||
let codeBlock = false;
|
||||
let endLineIndex = 0;
|
||||
|
|
@ -1975,7 +2068,7 @@ var Align;
|
|||
Align["None"] = "---";
|
||||
})(Align = exports.Align || (exports.Align = {}));
|
||||
exports.Icon = {
|
||||
skip: ':no_entry_sign:',
|
||||
skip: ':warning:',
|
||||
success: ':white_check_mark:',
|
||||
fail: ':x:'
|
||||
};
|
||||
|
|
|
|||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
93
src/main.ts
93
src/main.ts
|
|
@ -8,6 +8,7 @@ import {LocalFileProvider} from './input-providers/local-file-provider'
|
|||
import {FileContent} from './input-providers/input-provider'
|
||||
import {ParseOptions, TestParser} from './test-parser'
|
||||
import {TestRunResult} from './test-results'
|
||||
import {getAnnotations} from './report/get-annotations'
|
||||
import {getReport} from './report/get-report'
|
||||
|
||||
import {DartJsonParser} from './parsers/dart-json/dart-json-parser'
|
||||
|
|
@ -18,6 +19,7 @@ import {MochaJsonParser} from './parsers/mocha-json/mocha-json-parser'
|
|||
|
||||
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
|
||||
import {getCheckRunContext} from './utils/github-utils'
|
||||
import {Icon} from './utils/markdown-utils'
|
||||
|
||||
async function main(): Promise<void> {
|
||||
try {
|
||||
|
|
@ -41,6 +43,7 @@ class TestReporter {
|
|||
readonly failOnError = core.getInput('fail-on-error', {required: true}) === 'true'
|
||||
readonly workDirInput = core.getInput('working-directory', {required: false})
|
||||
readonly onlySummary = core.getInput('only-summary', {required: false}) === 'true'
|
||||
readonly useActionsSummary = core.getInput('use-actions-summary', {required: false}) === 'true'
|
||||
readonly badgeTitle = core.getInput('badge-title', {required: false})
|
||||
readonly token = core.getInput('token', {required: true})
|
||||
readonly octokit: InstanceType<typeof GitHub>
|
||||
|
|
@ -154,50 +157,60 @@ class TestReporter {
|
|||
results.push(tr)
|
||||
}
|
||||
|
||||
// core.info(`Creating check run ${name}`)
|
||||
// const createResp = await this.octokit.checks.create({
|
||||
// head_sha: this.context.sha,
|
||||
// name,
|
||||
// status: 'in_progress',
|
||||
// output: {
|
||||
// title: name,
|
||||
// summary: ''
|
||||
// },
|
||||
// ...github.context.repo
|
||||
// })
|
||||
|
||||
core.info('Creating report summary')
|
||||
const {listSuites, listTests, onlySummary, badgeTitle} = this
|
||||
const baseUrl = ''
|
||||
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary, badgeTitle})
|
||||
core.info('Summary content:')
|
||||
core.info(summary)
|
||||
await fs.promises.writeFile(this.path.replace('*.trx', 'test-summary.md'), summary)
|
||||
core.info('File content:')
|
||||
core.info(fs.readFileSync(this.path.replace('*.trx', 'test-summary.md'), 'utf8'))
|
||||
const {listSuites, listTests, onlySummary, useActionsSummary, badgeTitle} = this
|
||||
let baseUrl = ''
|
||||
let checkRunId = 0
|
||||
if (!this.useActionsSummary) {
|
||||
core.info(`Creating check run ${name}`)
|
||||
const createResp = await this.octokit.rest.checks.create({
|
||||
head_sha: this.context.sha,
|
||||
name,
|
||||
status: 'in_progress',
|
||||
output: {
|
||||
title: name,
|
||||
summary: ''
|
||||
},
|
||||
...github.context.repo
|
||||
})
|
||||
baseUrl = createResp.data.html_url as string
|
||||
checkRunId = createResp.data.id
|
||||
}
|
||||
|
||||
// core.info('Creating annotations')
|
||||
// const annotations = getAnnotations(results, this.maxAnnotations)
|
||||
const summary = getReport(results, {listSuites, listTests, baseUrl, onlySummary, useActionsSummary, badgeTitle})
|
||||
|
||||
// const isFailed = results.some(tr => tr.result === 'failed')
|
||||
// const conclusion = isFailed ? 'failure' : 'success'
|
||||
// const icon = isFailed ? Icon.fail : Icon.success
|
||||
if (this.useActionsSummary) {
|
||||
core.info('Summary content:')
|
||||
core.info(summary)
|
||||
await fs.promises.writeFile(this.path.replace('*.trx', 'test-summary.md'), summary)
|
||||
core.info('File content:')
|
||||
core.info(fs.readFileSync(this.path.replace('*.trx', 'test-summary.md'), 'utf8'))
|
||||
}
|
||||
|
||||
// core.info(`Updating check run conclusion (${conclusion}) and output`)
|
||||
// const resp = await this.octokit.checks.update({
|
||||
// check_run_id: createResp.data.id,
|
||||
// conclusion,
|
||||
// status: 'completed',
|
||||
// output: {
|
||||
// title: `${name} ${icon}`,
|
||||
// summary,
|
||||
// annotations
|
||||
// },
|
||||
// ...github.context.repo
|
||||
// })
|
||||
// core.info(`Check run create response: ${resp.status}`)
|
||||
// core.info(`Check run URL: ${resp.data.url}`)
|
||||
// core.info(`Check run HTML: ${resp.data.html_url}`)
|
||||
if (!this.useActionsSummary) {
|
||||
core.info('Creating annotations')
|
||||
const annotations = getAnnotations(results, this.maxAnnotations)
|
||||
|
||||
const isFailed = results.some(tr => tr.result === 'failed')
|
||||
const conclusion = isFailed ? 'failure' : 'success'
|
||||
const icon = isFailed ? Icon.fail : Icon.success
|
||||
|
||||
core.info(`Updating check run conclusion (${conclusion}) and output`)
|
||||
const resp = await this.octokit.rest.checks.update({
|
||||
check_run_id: checkRunId,
|
||||
conclusion,
|
||||
status: 'completed',
|
||||
output: {
|
||||
title: `${name} ${icon}`,
|
||||
summary,
|
||||
annotations
|
||||
},
|
||||
...github.context.repo
|
||||
})
|
||||
core.info(`Check run create response: ${resp.status}`)
|
||||
core.info(`Check run URL: ${resp.data.url}`)
|
||||
core.info(`Check run HTML: ${resp.data.html_url}`)
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ import {getFirstNonEmptyLine} from '../utils/parse-utils'
|
|||
import {slug} from '../utils/slugger'
|
||||
|
||||
const MAX_REPORT_LENGTH = 65535
|
||||
const MAX_ACTIONS_SUMMARY_LENGTH = 131072 // 1048576 soon
|
||||
|
||||
export interface ReportOptions {
|
||||
listSuites: 'all' | 'failed' | 'none'
|
||||
listTests: 'all' | 'failed' | 'none'
|
||||
baseUrl: string
|
||||
onlySummary: boolean
|
||||
useActionsSummary: boolean
|
||||
badgeTitle: string
|
||||
}
|
||||
|
||||
|
|
@ -20,6 +22,7 @@ const defaultOptions: ReportOptions = {
|
|||
listTests: 'all',
|
||||
baseUrl: '',
|
||||
onlySummary: false,
|
||||
useActionsSummary: true,
|
||||
badgeTitle: 'tests'
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +35,7 @@ export function getReport(results: TestRunResult[], options: ReportOptions = def
|
|||
let lines = renderReport(results, opts)
|
||||
let report = lines.join('\n')
|
||||
|
||||
if (getByteLength(report) <= MAX_REPORT_LENGTH) {
|
||||
if (getByteLength(report) <= getMaxReportLength(options)) {
|
||||
return report
|
||||
}
|
||||
|
||||
|
|
@ -41,20 +44,24 @@ export function getReport(results: TestRunResult[], options: ReportOptions = def
|
|||
opts.listTests = 'failed'
|
||||
lines = renderReport(results, opts)
|
||||
report = lines.join('\n')
|
||||
if (getByteLength(report) <= MAX_REPORT_LENGTH) {
|
||||
if (getByteLength(report) <= getMaxReportLength(options)) {
|
||||
return report
|
||||
}
|
||||
}
|
||||
|
||||
core.warning(`Test report summary exceeded limit of ${MAX_REPORT_LENGTH} bytes and will be trimmed`)
|
||||
return trimReport(lines)
|
||||
core.warning(`Test report summary exceeded limit of ${getMaxReportLength(options)} bytes and will be trimmed`)
|
||||
return trimReport(lines, options)
|
||||
}
|
||||
|
||||
function trimReport(lines: string[]): string {
|
||||
function getMaxReportLength(options: ReportOptions = defaultOptions): number {
|
||||
return options.useActionsSummary ? MAX_ACTIONS_SUMMARY_LENGTH : MAX_REPORT_LENGTH
|
||||
}
|
||||
|
||||
function trimReport(lines: string[], options: ReportOptions): string {
|
||||
const closingBlock = '```'
|
||||
const errorMsg = `**Report exceeded GitHub limit of ${MAX_REPORT_LENGTH} bytes and has been trimmed**`
|
||||
const errorMsg = `**Report exceeded GitHub limit of ${getMaxReportLength(options)} bytes and has been trimmed**`
|
||||
const maxErrorMsgLength = closingBlock.length + errorMsg.length + 2
|
||||
const maxReportLength = MAX_REPORT_LENGTH - maxErrorMsgLength
|
||||
const maxReportLength = getMaxReportLength(options) - maxErrorMsgLength
|
||||
|
||||
let reportLength = 0
|
||||
let codeBlock = false
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export enum Align {
|
|||
}
|
||||
|
||||
export const Icon = {
|
||||
skip: ':no_entry_sign:',
|
||||
skip: ':warning:',
|
||||
success: ':white_check_mark:',
|
||||
fail: ':x:'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue