1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-02-04 13:37:56 +01:00

update compiler to e2023

This commit is contained in:
Connor 2024-10-15 15:05:32 -05:00
parent 3ece1e5069
commit fa59c8e9ca
No known key found for this signature in database
GPG key ID: 455C6C81CB2BD091
4 changed files with 726 additions and 778 deletions

View file

@ -1,69 +1,69 @@
// import * as fs from 'fs' import * as fs from 'fs'
// import * as path from 'path' import * as path from 'path'
// import {DartJsonParser} from '../src/parsers/dart-json/dart-json-parser' import {DartJsonParser} from '../src/parsers/dart-json/dart-json-parser'
// import {ParseOptions} from '../src/test-parser' import {ParseOptions} from '../src/test-parser'
// import {getReport} from '../src/report/get-report' import {getReport} from '../src/report/get-report'
// import {normalizeFilePath} from '../src/utils/path-utils' import {normalizeFilePath} from '../src/utils/path-utils'
// describe('dart-json tests', () => { describe('dart-json tests', () => {
// it('produces empty test run result when there are no test cases', async () => { it('produces empty test run result when there are no test cases', async () => {
// const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'dart-json.json') const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'dart-json.json')
// const filePath = normalizeFilePath(path.relative(__dirname, fixturePath)) const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
// const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'}) const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
// const opts: ParseOptions = { const opts: ParseOptions = {
// parseErrors: true, parseErrors: true,
// trackedFiles: [] trackedFiles: []
// } }
// const parser = new DartJsonParser(opts, 'dart') const parser = new DartJsonParser(opts, 'dart')
// const result = await parser.parse(filePath, fileContent) const result = await parser.parse(filePath, fileContent)
// expect(result.tests).toBe(0) expect(result.tests).toBe(0)
// expect(result.result).toBe('success') expect(result.result).toBe('success')
// }) })
// it('matches report snapshot', async () => { it('matches report snapshot', async () => {
// const opts: ParseOptions = { const opts: ParseOptions = {
// parseErrors: true, parseErrors: true,
// trackedFiles: ['lib/main.dart', 'test/main_test.dart', 'test/second_test.dart'] trackedFiles: ['lib/main.dart', 'test/main_test.dart', 'test/second_test.dart']
// //workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dart/' //workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/dart/'
// } }
// const fixturePath = path.join(__dirname, 'fixtures', 'dart-json.json') const fixturePath = path.join(__dirname, 'fixtures', 'dart-json.json')
// const outputPath = path.join(__dirname, '__outputs__', 'dart-json.md') const outputPath = path.join(__dirname, '__outputs__', 'dart-json.md')
// const filePath = normalizeFilePath(path.relative(__dirname, fixturePath)) const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
// const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'}) const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
// const parser = new DartJsonParser(opts, 'dart') const parser = new DartJsonParser(opts, 'dart')
// const result = await parser.parse(filePath, fileContent) const result = await parser.parse(filePath, fileContent)
// expect(result).toMatchSnapshot() expect(result).toMatchSnapshot()
// const report = getReport([result]) const report = getReport([result])
// fs.mkdirSync(path.dirname(outputPath), {recursive: true}) fs.mkdirSync(path.dirname(outputPath), {recursive: true})
// fs.writeFileSync(outputPath, report) fs.writeFileSync(outputPath, report)
// }) })
// it('report from rrousselGit/provider test results matches snapshot', async () => { it('report from rrousselGit/provider test results matches snapshot', async () => {
// const fixturePath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'provider-test-results.json') const fixturePath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'provider-test-results.json')
// const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'files.txt') const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'flutter', 'files.txt')
// const outputPath = path.join(__dirname, '__outputs__', 'provider-test-results.md') const outputPath = path.join(__dirname, '__outputs__', 'provider-test-results.md')
// const filePath = normalizeFilePath(path.relative(__dirname, fixturePath)) const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
// const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'}) const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
// const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g) const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
// const opts: ParseOptions = { const opts: ParseOptions = {
// trackedFiles, trackedFiles,
// parseErrors: true parseErrors: true
// //workDir: '/__w/provider/provider/' //workDir: '/__w/provider/provider/'
// } }
// const parser = new DartJsonParser(opts, 'flutter') const parser = new DartJsonParser(opts, 'flutter')
// const result = await parser.parse(filePath, fileContent) const result = await parser.parse(filePath, fileContent)
// expect(result).toMatchSnapshot() expect(result).toMatchSnapshot()
// const report = getReport([result]) const report = getReport([result])
// fs.mkdirSync(path.dirname(outputPath), {recursive: true}) fs.mkdirSync(path.dirname(outputPath), {recursive: true})
// fs.writeFileSync(outputPath, report) fs.writeFileSync(outputPath, report)
// }) })
// }) })

408
dist/index.js generated vendored
View file

@ -29,15 +29,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -49,6 +40,16 @@ const adm_zip_1 = __importDefault(__nccwpck_require__(1316));
const picomatch_1 = __importDefault(__nccwpck_require__(4006)); const picomatch_1 = __importDefault(__nccwpck_require__(4006));
const github_utils_1 = __nccwpck_require__(6667); const github_utils_1 = __nccwpck_require__(6667);
class ArtifactProvider { class ArtifactProvider {
octokit;
artifact;
name;
pattern;
sha;
runId;
token;
artifactNameMatch;
fileNameMatch;
getReportName;
constructor(octokit, artifact, name, pattern, sha, runId, token) { constructor(octokit, artifact, name, pattern, sha, runId, token) {
this.octokit = octokit; this.octokit = octokit;
this.artifact = artifact; this.artifact = artifact;
@ -81,10 +82,12 @@ class ArtifactProvider {
} }
this.fileNameMatch = (0, picomatch_1.default)(pattern); this.fileNameMatch = (0, picomatch_1.default)(pattern);
} }
load() { async load() {
return __awaiter(this, void 0, void 0, function* () {
const result = {}; const result = {};
const resp = yield this.octokit.rest.actions.listWorkflowRunArtifacts(Object.assign(Object.assign({}, github.context.repo), { run_id: this.runId })); const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({
...github.context.repo,
run_id: this.runId
});
if (resp.data.artifacts.length === 0) { if (resp.data.artifacts.length === 0) {
core.warning(`No artifacts found in run ${this.runId}`); core.warning(`No artifacts found in run ${this.runId}`);
return {}; return {};
@ -96,7 +99,7 @@ class ArtifactProvider {
} }
for (const art of artifacts) { for (const art of artifacts) {
const fileName = `${art.name}.zip`; const fileName = `${art.name}.zip`;
yield (0, github_utils_1.downloadArtifact)(this.octokit, art.id, fileName, this.token); await (0, github_utils_1.downloadArtifact)(this.octokit, art.id, fileName, this.token);
core.startGroup(`Reading archive ${fileName}`); core.startGroup(`Reading archive ${fileName}`);
try { try {
const reportName = this.getReportName(art.name); const reportName = this.getReportName(art.name);
@ -129,12 +132,9 @@ class ArtifactProvider {
} }
} }
return result; return result;
});
} }
listTrackedFiles() { async listTrackedFiles() {
return __awaiter(this, void 0, void 0, function* () {
return (0, github_utils_1.listFiles)(this.octokit, this.sha); return (0, github_utils_1.listFiles)(this.octokit, this.sha);
});
} }
} }
exports.ArtifactProvider = ArtifactProvider; exports.ArtifactProvider = ArtifactProvider;
@ -170,15 +170,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -188,27 +179,25 @@ const fs = __importStar(__nccwpck_require__(9896));
const fast_glob_1 = __importDefault(__nccwpck_require__(5648)); const fast_glob_1 = __importDefault(__nccwpck_require__(5648));
const git_1 = __nccwpck_require__(5454); const git_1 = __nccwpck_require__(5454);
class LocalFileProvider { class LocalFileProvider {
name;
pattern;
constructor(name, pattern) { constructor(name, pattern) {
this.name = name; this.name = name;
this.pattern = pattern; this.pattern = pattern;
} }
load() { async load() {
return __awaiter(this, void 0, void 0, function* () {
const result = []; const result = [];
for (const pat of this.pattern) { for (const pat of this.pattern) {
const paths = yield (0, fast_glob_1.default)(pat, { dot: true }); const paths = await (0, fast_glob_1.default)(pat, { dot: true });
for (const file of paths) { for (const file of paths) {
const content = yield fs.promises.readFile(file, { encoding: 'utf8' }); const content = await fs.promises.readFile(file, { encoding: 'utf8' });
result.push({ file, content }); result.push({ file, content });
} }
} }
return { [this.name]: result }; return { [this.name]: result };
});
} }
listTrackedFiles() { async listTrackedFiles() {
return __awaiter(this, void 0, void 0, function* () {
return (0, git_1.listFiles)(); return (0, git_1.listFiles)();
});
} }
} }
exports.LocalFileProvider = LocalFileProvider; exports.LocalFileProvider = LocalFileProvider;
@ -244,15 +233,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const github = __importStar(__nccwpck_require__(3228)); const github = __importStar(__nccwpck_require__(3228));
@ -268,11 +248,10 @@ const mocha_json_parser_1 = __nccwpck_require__(5402);
const swift_xunit_parser_1 = __nccwpck_require__(7330); const swift_xunit_parser_1 = __nccwpck_require__(7330);
const path_utils_1 = __nccwpck_require__(9132); const path_utils_1 = __nccwpck_require__(9132);
const github_utils_1 = __nccwpck_require__(6667); const github_utils_1 = __nccwpck_require__(6667);
function main() { async function main() {
return __awaiter(this, void 0, void 0, function* () {
try { try {
const testReporter = new TestReporter(); const testReporter = new TestReporter();
yield testReporter.run(); await testReporter.run();
} }
catch (error) { catch (error) {
if (error instanceof Error) if (error instanceof Error)
@ -280,39 +259,26 @@ function main() {
else else
core.setFailed(JSON.stringify(error)); core.setFailed(JSON.stringify(error));
} }
});
} }
class TestReporter { class TestReporter {
maxAnnotationsPerBatch = 50;
artifact = core.getInput('artifact', { required: false });
name = core.getInput('name', { required: true });
path = core.getInput('path', { required: true });
pathReplaceBackslashes = core.getInput('path-replace-backslashes', { required: false }) === 'true';
reporter = core.getInput('reporter', { required: true });
listSuites = core.getInput('list-suites', { required: true });
listTests = core.getInput('list-tests', { required: true });
maxAnnotations = parseInt(core.getInput('max-annotations', { required: true }));
failOnError = core.getInput('fail-on-error', { required: true }) === 'true';
failOnEmpty = core.getInput('fail-on-empty', { required: true }) === 'true';
workDirInput = core.getInput('working-directory', { required: false });
onlySummary = core.getInput('only-summary', { required: false }) === 'true';
showHTMLNotice = core.getInput('show-html-notice', { required: false }) === 'true';
token = core.getInput('token', { required: true });
octokit;
context = (0, github_utils_1.getCheckRunContext)();
constructor() { constructor() {
this.maxAnnotationsPerBatch = 50;
this.artifact = core.getInput('artifact', { required: false });
this.name = core.getInput('name', { required: true });
this.path = core.getInput('path', { required: true });
this.pathReplaceBackslashes = core.getInput('path-replace-backslashes', { required: false }) === 'true';
this.reporter = core.getInput('reporter', { required: true });
this.listSuites = core.getInput('list-suites', { required: true });
this.listTests = core.getInput('list-tests', { required: true });
this.maxAnnotations = parseInt(core.getInput('max-annotations', { required: true }));
this.failOnError = core.getInput('fail-on-error', { required: true }) === 'true';
this.failOnEmpty = core.getInput('fail-on-empty', { required: true }) === 'true';
this.workDirInput = core.getInput('working-directory', { required: false });
this.onlySummary = core.getInput('only-summary', { required: false }) === 'true';
this.showHTMLNotice = core.getInput('show-html-notice', { required: false }) === 'true';
this.token = core.getInput('token', { required: true });
this.context = (0, github_utils_1.getCheckRunContext)();
this.handleAnnotations = (annotations, requestParams) => __awaiter(this, void 0, void 0, function* () {
const leftAnnotations = [...annotations];
let response;
do {
const toProcess = leftAnnotations.splice(0, 50);
const status = leftAnnotations.length > 0 ? 'in_progress' : 'completed';
response = yield this.updateAnnotation(toProcess, Object.assign(Object.assign({}, requestParams), { status }));
} while (leftAnnotations.length > 0);
return response;
});
this.updateAnnotation = (annotations, requestParams) => __awaiter(this, void 0, void 0, function* () {
return yield this.octokit.rest.checks.update(Object.assign(Object.assign({}, requestParams), { output: Object.assign(Object.assign({}, requestParams.output), { annotations }) }));
});
this.octokit = github.getOctokit(this.token); this.octokit = github.getOctokit(this.token);
if (this.listSuites !== 'all' && this.listSuites !== 'failed') { if (this.listSuites !== 'all' && this.listSuites !== 'failed') {
core.setFailed(`Input parameter 'list-suites' has invalid value of ${this.listSuites}`); core.setFailed(`Input parameter 'list-suites' has invalid value of ${this.listSuites}`);
@ -330,8 +296,7 @@ class TestReporter {
return; return;
} }
} }
run() { async run() {
return __awaiter(this, void 0, void 0, function* () {
if (this.workDirInput) { if (this.workDirInput) {
core.info(`Changing directory to '${this.workDirInput}'`); core.info(`Changing directory to '${this.workDirInput}'`);
process.chdir(this.workDirInput); process.chdir(this.workDirInput);
@ -345,7 +310,7 @@ class TestReporter {
? new artifact_provider_1.ArtifactProvider(this.octokit, this.artifact, this.name, pattern, this.context.sha, this.context.runId, this.token) ? new artifact_provider_1.ArtifactProvider(this.octokit, this.artifact, this.name, pattern, this.context.sha, this.context.runId, this.token)
: new local_file_provider_1.LocalFileProvider(this.name, pattern); : new local_file_provider_1.LocalFileProvider(this.name, pattern);
const parseErrors = this.maxAnnotations > 0; const parseErrors = this.maxAnnotations > 0;
const trackedFiles = parseErrors ? yield inputProvider.listTrackedFiles() : []; const trackedFiles = parseErrors ? await inputProvider.listTrackedFiles() : [];
const workDir = this.artifact ? undefined : (0, path_utils_1.normalizeDirPath)(process.cwd(), true); const workDir = this.artifact ? undefined : (0, path_utils_1.normalizeDirPath)(process.cwd(), true);
if (parseErrors) if (parseErrors)
core.info(`Found ${trackedFiles.length} files tracked by GitHub`); core.info(`Found ${trackedFiles.length} files tracked by GitHub`);
@ -358,11 +323,11 @@ class TestReporter {
const parser = this.getParser(this.reporter, options); const parser = this.getParser(this.reporter, options);
const results = []; const results = [];
const outputHtml = []; const outputHtml = [];
const input = yield inputProvider.load(); const input = await inputProvider.load();
for (const [reportName, files] of Object.entries(input)) { for (const [reportName, files] of Object.entries(input)) {
try { try {
core.startGroup(`Creating test report ${reportName}`); core.startGroup(`Creating test report ${reportName}`);
const [tr, html] = yield this.createReport(parser, reportName, files); const [tr, html] = await this.createReport(parser, reportName, files);
results.push(...tr); results.push(...tr);
if (html != null) { if (html != null) {
outputHtml.push(html); outputHtml.push(html);
@ -393,10 +358,8 @@ class TestReporter {
core.setFailed(`No test report files were found`); core.setFailed(`No test report files were found`);
return; return;
} }
});
} }
createReport(parser, name, files) { async createReport(parser, name, files) {
return __awaiter(this, void 0, void 0, function* () {
if (files.length === 0) { if (files.length === 0) {
core.warning(`No file matches path ${this.path}`); core.warning(`No file matches path ${this.path}`);
return [[], '']; return [[], ''];
@ -405,7 +368,7 @@ class TestReporter {
const results = []; const results = [];
for (const { file, content } of files) { for (const { file, content } of files) {
try { try {
const tr = yield parser.parse(file, content); const tr = await parser.parse(file, content);
results.push(tr); results.push(tr);
} }
catch (error) { catch (error) {
@ -414,10 +377,16 @@ class TestReporter {
} }
} }
core.info(`Creating check run ${name}`); 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: { const createResp = await this.octokit.rest.checks.create({
head_sha: this.context.sha,
name,
status: 'in_progress',
output: {
title: name, title: name,
summary: '' summary: ''
} }, github.context.repo)); },
...github.context.repo
});
core.info('Creating report summary'); core.info('Creating report summary');
const { listSuites, listTests, onlySummary } = this; const { listSuites, listTests, onlySummary } = this;
const baseUrl = createResp.data.html_url; const baseUrl = createResp.data.html_url;
@ -431,11 +400,17 @@ class TestReporter {
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0); const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `; const shortSummary = `${passed} passed, ${failed} failed and ${skipped} skipped `;
core.info(`Updating check run conclusion (${conclusion}) and output`); core.info(`Updating check run conclusion (${conclusion}) and output`);
const resp = yield this.handleAnnotations(annotations, Object.assign({ check_run_id: createResp.data.id, conclusion, status: 'completed', output: { const resp = await this.handleAnnotations(annotations, {
check_run_id: createResp.data.id,
conclusion,
status: 'completed',
output: {
title: shortSummary, title: shortSummary,
summary, summary,
annotations annotations
} }, github.context.repo)); },
...github.context.repo
});
core.info(`Check run create response: ${resp.status}`); core.info(`Check run create response: ${resp.status}`);
core.info(`Check run URL: ${resp.data.url}`); core.info(`Check run URL: ${resp.data.url}`);
core.info(`Check run HTML: ${resp.data.html_url}`); core.info(`Check run HTML: ${resp.data.html_url}`);
@ -448,7 +423,6 @@ class TestReporter {
core.setOutput('url', resp.data.url); core.setOutput('url', resp.data.url);
core.setOutput('url_html', resp.data.html_url); core.setOutput('url_html', resp.data.html_url);
return [results, resp.data.html_url]; return [results, resp.data.html_url];
});
} }
getParser(reporter, options) { getParser(reporter, options) {
switch (reporter) { switch (reporter) {
@ -470,6 +444,22 @@ class TestReporter {
throw new Error(`Input variable 'reporter' is set to invalid value '${reporter}'`); throw new Error(`Input variable 'reporter' is set to invalid value '${reporter}'`);
} }
} }
handleAnnotations = async (annotations, requestParams) => {
const leftAnnotations = [...annotations];
let response;
do {
const toProcess = leftAnnotations.splice(0, 50);
const status = leftAnnotations.length > 0 ? 'in_progress' : 'completed';
response = await this.updateAnnotation(toProcess, { ...requestParams, status });
} while (leftAnnotations.length > 0);
return response;
};
updateAnnotation = async (annotations, requestParams) => {
return await this.octokit.rest.checks.update({
...requestParams,
output: { ...requestParams.output, annotations }
});
};
} }
main(); main();
@ -477,19 +467,10 @@ main();
/***/ }), /***/ }),
/***/ 1658: /***/ 1658:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DotnetTrxParser = void 0; exports.DotnetTrxParser = void 0;
const xml2js_1 = __nccwpck_require__(758); const xml2js_1 = __nccwpck_require__(758);
@ -497,12 +478,17 @@ const path_utils_1 = __nccwpck_require__(9132);
const parse_utils_1 = __nccwpck_require__(9633); const parse_utils_1 = __nccwpck_require__(9633);
const test_results_1 = __nccwpck_require__(613); const test_results_1 = __nccwpck_require__(613);
class TestClass { class TestClass {
name;
constructor(name) { constructor(name) {
this.name = name; this.name = name;
this.tests = [];
} }
tests = [];
} }
class Test { class Test {
name;
outcome;
duration;
error;
constructor(name, outcome, duration, error) { constructor(name, outcome, duration, error) {
this.name = name; this.name = name;
this.outcome = outcome; this.outcome = outcome;
@ -521,27 +507,25 @@ class Test {
} }
} }
class DotnetTrxParser { class DotnetTrxParser {
options;
assumedWorkDir;
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }
parse(path, content) { async parse(path, content) {
return __awaiter(this, void 0, void 0, function* () { const trx = await this.getTrxReport(path, content);
const trx = yield this.getTrxReport(path, content);
const tc = this.getTestClasses(trx); const tc = this.getTestClasses(trx);
const tr = this.getTestRunResult(path, trx, tc); const tr = this.getTestRunResult(path, trx, tc);
tr.sort(true); tr.sort(true);
return tr; return tr;
});
} }
getTrxReport(path, content) { async getTrxReport(path, content) {
return __awaiter(this, void 0, void 0, function* () {
try { try {
return (yield (0, xml2js_1.parseStringPromise)(content)); return (await (0, xml2js_1.parseStringPromise)(content));
} }
catch (e) { catch (e) {
throw new Error(`Invalid XML at ${path}\n\n${e}`); throw new Error(`Invalid XML at ${path}\n\n${e}`);
} }
});
} }
getTestClasses(trx) { getTestClasses(trx) {
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined) { if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined) {
@ -592,12 +576,11 @@ class DotnetTrxParser {
return new test_results_1.TestRunResult(path, suites, totalTime); return new test_results_1.TestRunResult(path, suites, totalTime);
} }
getErrorInfo(testResult) { getErrorInfo(testResult) {
var _a;
if (testResult.$.outcome !== 'Failed') { if (testResult.$.outcome !== 'Failed') {
return undefined; return undefined;
} }
const output = testResult.Output; const output = testResult.Output;
const error = (output === null || output === void 0 ? void 0 : output.length) > 0 && ((_a = output[0].ErrorInfo) === null || _a === void 0 ? void 0 : _a.length) > 0 ? output[0].ErrorInfo[0] : undefined; const error = output?.length > 0 && output[0].ErrorInfo?.length > 0 ? output[0].ErrorInfo[0] : undefined;
return error; return error;
} }
getError(test) { getError(test) {
@ -648,8 +631,9 @@ class DotnetTrxParser {
} }
} }
getWorkDir(path) { getWorkDir(path) {
var _a, _b; return (this.options.workDir ??
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles))); this.assumedWorkDir ??
(this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
} }
} }
exports.DotnetTrxParser = DotnetTrxParser; exports.DotnetTrxParser = DotnetTrxParser;
@ -685,15 +669,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JavaJunitParser = void 0; exports.JavaJunitParser = void 0;
const path = __importStar(__nccwpck_require__(6928)); const path = __importStar(__nccwpck_require__(6928));
@ -702,20 +677,20 @@ const java_stack_trace_element_parser_1 = __nccwpck_require__(8105);
const path_utils_1 = __nccwpck_require__(9132); const path_utils_1 = __nccwpck_require__(9132);
const test_results_1 = __nccwpck_require__(613); const test_results_1 = __nccwpck_require__(613);
class JavaJunitParser { class JavaJunitParser {
options;
trackedFiles;
constructor(options) { constructor(options) {
var _a;
this.options = options; this.options = options;
// Map to efficient lookup of all paths with given file name // Map to efficient lookup of all paths with given file name
this.trackedFiles = {}; this.trackedFiles = {};
for (const filePath of options.trackedFiles) { for (const filePath of options.trackedFiles) {
const fileName = path.basename(filePath); const fileName = path.basename(filePath);
const files = (_a = this.trackedFiles[fileName]) !== null && _a !== void 0 ? _a : (this.trackedFiles[fileName] = []); const files = this.trackedFiles[fileName] ?? (this.trackedFiles[fileName] = []);
files.push((0, path_utils_1.normalizeFilePath)(filePath)); files.push((0, path_utils_1.normalizeFilePath)(filePath));
} }
} }
parse(filePath, content) { async parse(filePath, content) {
return __awaiter(this, void 0, void 0, function* () { const reportOrSuite = await this.getJunitReport(filePath, content);
const reportOrSuite = yield this.getJunitReport(filePath, content);
const isReport = reportOrSuite.testsuites !== undefined; const isReport = reportOrSuite.testsuites !== undefined;
// XML might contain: // XML might contain:
// - multiple suites under <testsuites> root node // - multiple suites under <testsuites> root node
@ -735,20 +710,16 @@ class JavaJunitParser {
}; };
} }
return this.getTestRunResult(filePath, ju); return this.getTestRunResult(filePath, ju);
});
} }
getJunitReport(filePath, content) { async getJunitReport(filePath, content) {
return __awaiter(this, void 0, void 0, function* () {
try { try {
return yield (0, xml2js_1.parseStringPromise)(content); return await (0, xml2js_1.parseStringPromise)(content);
} }
catch (e) { catch (e) {
throw new Error(`Invalid XML at ${filePath}\n\n${e}`); throw new Error(`Invalid XML at ${filePath}\n\n${e}`);
} }
});
} }
getTestRunResult(filePath, junit) { getTestRunResult(filePath, junit) {
var _a;
const suites = junit.testsuites.testsuite === undefined const suites = junit.testsuites.testsuite === undefined
? [] ? []
: junit.testsuites.testsuite.map(ts => { : junit.testsuites.testsuite.map(ts => {
@ -757,7 +728,7 @@ class JavaJunitParser {
const sr = new test_results_1.TestSuiteResult(name, this.getGroups(ts), time); const sr = new test_results_1.TestSuiteResult(name, this.getGroups(ts), time);
return sr; return sr;
}); });
const seconds = parseFloat((_a = junit.testsuites.$) === null || _a === void 0 ? void 0 : _a.time); const seconds = parseFloat(junit.testsuites.$?.time);
const time = isNaN(seconds) ? undefined : seconds * 1000; const time = isNaN(seconds) ? undefined : seconds * 1000;
return new test_results_1.TestRunResult(filePath, suites, time); return new test_results_1.TestRunResult(filePath, suites, time);
} }
@ -797,12 +768,11 @@ class JavaJunitParser {
return 'success'; return 'success';
} }
getTestCaseError(tc) { getTestCaseError(tc) {
var _a;
if (!this.options.parseErrors) { if (!this.options.parseErrors) {
return undefined; return undefined;
} }
// We process <error> and <failure> the same way // We process <error> and <failure> the same way
const failures = (_a = tc.failure) !== null && _a !== void 0 ? _a : tc.error; const failures = tc.failure ?? tc.error;
if (!failures) { if (!failures) {
return undefined; return undefined;
} }
@ -927,19 +897,10 @@ function parseClassLoaderAndModule(maybeClassLoaderAndModuleNameAndVersion) {
/***/ }), /***/ }),
/***/ 1042: /***/ 1042:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.JestJunitParser = void 0; exports.JestJunitParser = void 0;
const xml2js_1 = __nccwpck_require__(758); const xml2js_1 = __nccwpck_require__(758);
@ -947,24 +908,22 @@ const node_utils_1 = __nccwpck_require__(5384);
const path_utils_1 = __nccwpck_require__(9132); const path_utils_1 = __nccwpck_require__(9132);
const test_results_1 = __nccwpck_require__(613); const test_results_1 = __nccwpck_require__(613);
class JestJunitParser { class JestJunitParser {
options;
assumedWorkDir;
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }
parse(path, content) { async parse(path, content) {
return __awaiter(this, void 0, void 0, function* () { const ju = await this.getJunitReport(path, content);
const ju = yield this.getJunitReport(path, content);
return this.getTestRunResult(path, ju); return this.getTestRunResult(path, ju);
});
} }
getJunitReport(path, content) { async getJunitReport(path, content) {
return __awaiter(this, void 0, void 0, function* () {
try { try {
return (yield (0, xml2js_1.parseStringPromise)(content)); return (await (0, xml2js_1.parseStringPromise)(content));
} }
catch (e) { catch (e) {
throw new Error(`Invalid XML at ${path}\n\n${e}`); throw new Error(`Invalid XML at ${path}\n\n${e}`);
} }
});
} }
getTestRunResult(path, junit) { getTestRunResult(path, junit) {
const suites = junit.testsuites.testsuite === undefined const suites = junit.testsuites.testsuite === undefined
@ -1036,8 +995,9 @@ class JestJunitParser {
return path; return path;
} }
getWorkDir(path) { getWorkDir(path) {
var _a, _b; return (this.options.workDir ??
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles))); this.assumedWorkDir ??
(this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
} }
escapeCharacters(s) { escapeCharacters(s) {
return s.replace(/([<>])/g, '\\$1'); return s.replace(/([<>])/g, '\\$1');
@ -1049,35 +1009,26 @@ exports.JestJunitParser = JestJunitParser;
/***/ }), /***/ }),
/***/ 5402: /***/ 5402:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict"; "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.MochaJsonParser = void 0; exports.MochaJsonParser = void 0;
const test_results_1 = __nccwpck_require__(613); const test_results_1 = __nccwpck_require__(613);
const node_utils_1 = __nccwpck_require__(5384); const node_utils_1 = __nccwpck_require__(5384);
const path_utils_1 = __nccwpck_require__(9132); const path_utils_1 = __nccwpck_require__(9132);
class MochaJsonParser { class MochaJsonParser {
options;
assumedWorkDir;
constructor(options) { constructor(options) {
this.options = options; this.options = options;
} }
parse(path, content) { async parse(path, content) {
return __awaiter(this, void 0, void 0, function* () {
const mocha = this.getMochaJson(path, content); const mocha = this.getMochaJson(path, content);
const result = this.getTestRunResult(path, mocha); const result = this.getTestRunResult(path, mocha);
result.sort(true); result.sort(true);
return Promise.resolve(result); return Promise.resolve(result);
});
} }
getMochaJson(path, content) { getMochaJson(path, content) {
try { try {
@ -1090,9 +1041,8 @@ class MochaJsonParser {
getTestRunResult(resultsPath, mocha) { getTestRunResult(resultsPath, mocha) {
const suitesMap = {}; const suitesMap = {};
const getSuite = (test) => { const getSuite = (test) => {
var _a;
const path = this.getRelativePath(test.file); const path = this.getRelativePath(test.file);
return (_a = suitesMap[path]) !== null && _a !== void 0 ? _a : (suitesMap[path] = new test_results_1.TestSuiteResult(path, [])); return suitesMap[path] ?? (suitesMap[path] = new test_results_1.TestSuiteResult(path, []));
}; };
for (const test of mocha.passes) { for (const test of mocha.passes) {
const suite = getSuite(test); const suite = getSuite(test);
@ -1110,7 +1060,6 @@ class MochaJsonParser {
return new test_results_1.TestRunResult(resultsPath, suites, mocha.stats.duration); return new test_results_1.TestRunResult(resultsPath, suites, mocha.stats.duration);
} }
processTest(suite, test, result) { processTest(suite, test, result) {
var _a;
const groupName = test.fullTitle !== test.title const groupName = test.fullTitle !== test.title
? test.fullTitle.substr(0, test.fullTitle.length - test.title.length).trimEnd() ? test.fullTitle.substr(0, test.fullTitle.length - test.title.length).trimEnd()
: null; : null;
@ -1120,7 +1069,7 @@ class MochaJsonParser {
suite.groups.push(group); suite.groups.push(group);
} }
const error = this.getTestCaseError(test); const error = this.getTestCaseError(test);
const testCase = new test_results_1.TestCaseResult(test.title, result, (_a = test.duration) !== null && _a !== void 0 ? _a : 0, error); const testCase = new test_results_1.TestCaseResult(test.title, result, test.duration ?? 0, error);
group.tests.push(testCase); group.tests.push(testCase);
} }
getTestCaseError(test) { getTestCaseError(test) {
@ -1152,8 +1101,9 @@ class MochaJsonParser {
return path; return path;
} }
getWorkDir(path) { getWorkDir(path) {
var _a, _b; return (this.options.workDir ??
return ((_b = (_a = this.options.workDir) !== null && _a !== void 0 ? _a : this.assumedWorkDir) !== null && _b !== void 0 ? _b : (this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles))); this.assumedWorkDir ??
(this.assumedWorkDir = (0, path_utils_1.getBasePath)(path, this.options.trackedFiles)));
} }
} }
exports.MochaJsonParser = MochaJsonParser; exports.MochaJsonParser = MochaJsonParser;
@ -1170,6 +1120,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.SwiftXunitParser = void 0; exports.SwiftXunitParser = void 0;
const java_junit_parser_1 = __nccwpck_require__(8342); const java_junit_parser_1 = __nccwpck_require__(8342);
class SwiftXunitParser extends java_junit_parser_1.JavaJunitParser { class SwiftXunitParser extends java_junit_parser_1.JavaJunitParser {
options;
constructor(options) { constructor(options) {
super(options); super(options);
this.options = options; this.options = options;
@ -1190,7 +1141,6 @@ exports.getAnnotations = getAnnotations;
const markdown_utils_1 = __nccwpck_require__(5129); const markdown_utils_1 = __nccwpck_require__(5129);
const parse_utils_1 = __nccwpck_require__(9633); const parse_utils_1 = __nccwpck_require__(9633);
function getAnnotations(results, maxCount) { function getAnnotations(results, maxCount) {
var _a, _b, _c, _d;
if (maxCount === 0) { if (maxCount === 0) {
return []; return [];
} }
@ -1206,8 +1156,8 @@ function getAnnotations(results, maxCount) {
if (err === undefined) { if (err === undefined) {
continue; continue;
} }
const path = (_a = err.path) !== null && _a !== void 0 ? _a : tr.path; const path = err.path ?? tr.path;
const line = (_b = err.line) !== null && _b !== void 0 ? _b : 0; const line = err.line ?? 0;
if (mergeDup) { if (mergeDup) {
const dup = errors.find(e => path === e.path && line === e.line && err.details === e.details); const dup = errors.find(e => path === e.path && line === e.line && err.details === e.details);
if (dup !== undefined) { if (dup !== undefined) {
@ -1220,7 +1170,7 @@ function getAnnotations(results, maxCount) {
suiteName: ts.name, suiteName: ts.name,
testName: tg.name ? `${tg.name}${tc.name}` : tc.name, testName: tg.name ? `${tg.name}${tc.name}` : tc.name,
details: err.details, 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', message: err.message ?? (0, parse_utils_1.getFirstNonEmptyLine)(err.details) ?? 'Test failed',
path, path,
line line
}); });
@ -1312,7 +1262,7 @@ const defaultOptions = {
function getReport(results, options = defaultOptions) { function getReport(results, options = defaultOptions) {
core.info('Generating check run summary'); core.info('Generating check run summary');
applySort(results); applySort(results);
const opts = Object.assign({}, options); const opts = { ...options };
let lines = renderReport(results, opts); let lines = renderReport(results, opts);
let report = lines.join('\n'); let report = lines.join('\n');
if (getByteLength(report) <= MAX_REPORT_LENGTH) { if (getByteLength(report) <= MAX_REPORT_LENGTH) {
@ -1459,7 +1409,6 @@ function getSuitesReport(tr, runIndex, options) {
return sections; return sections;
} }
function getTestsReport(ts, runIndex, suiteIndex, options) { function getTestsReport(ts, runIndex, suiteIndex, options) {
var _a, _b, _c;
if (options.listTests === 'failed' && ts.result !== 'failed') { if (options.listTests === 'failed' && ts.result !== 'failed') {
return []; return [];
} }
@ -1489,7 +1438,9 @@ function getTestsReport(ts, runIndex, suiteIndex, options) {
const result = getResultIcon(tc.result); const result = getResultIcon(tc.result);
sections.push(`${space}${result} ${tc.name}`); sections.push(`${space}${result} ${tc.name}`);
if (tc.error) { if (tc.error) {
const lines = (_c = ((_a = tc.error.message) !== null && _a !== void 0 ? _a : (_b = (0, parse_utils_1.getFirstNonEmptyLine)(tc.error.details)) === null || _b === void 0 ? void 0 : _b.trim())) === null || _c === void 0 ? void 0 : _c.split(/\r?\n/g).map(l => '\t' + l); const lines = (tc.error.message ?? (0, parse_utils_1.getFirstNonEmptyLine)(tc.error.details)?.trim())
?.split(/\r?\n/g)
.map(l => '\t' + l);
if (lines) { if (lines) {
sections.push(...lines); sections.push(...lines);
} }
@ -1532,6 +1483,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.TestCaseResult = exports.TestGroupResult = exports.TestSuiteResult = exports.TestRunResult = void 0; exports.TestCaseResult = exports.TestGroupResult = exports.TestSuiteResult = exports.TestRunResult = void 0;
const node_utils_1 = __nccwpck_require__(5384); const node_utils_1 = __nccwpck_require__(5384);
class TestRunResult { class TestRunResult {
path;
suites;
totalTime;
constructor(path, suites, totalTime) { constructor(path, suites, totalTime) {
this.path = path; this.path = path;
this.suites = suites; this.suites = suites;
@ -1550,8 +1504,7 @@ class TestRunResult {
return this.suites.reduce((sum, g) => sum + g.skipped, 0); return this.suites.reduce((sum, g) => sum + g.skipped, 0);
} }
get time() { get time() {
var _a; return this.totalTime ?? this.suites.reduce((sum, g) => sum + g.time, 0);
return (_a = this.totalTime) !== null && _a !== void 0 ? _a : this.suites.reduce((sum, g) => sum + g.time, 0);
} }
get result() { get result() {
return this.suites.some(t => t.result === 'failed') ? 'failed' : 'success'; return this.suites.some(t => t.result === 'failed') ? 'failed' : 'success';
@ -1570,6 +1523,9 @@ class TestRunResult {
} }
exports.TestRunResult = TestRunResult; exports.TestRunResult = TestRunResult;
class TestSuiteResult { class TestSuiteResult {
name;
groups;
totalTime;
constructor(name, groups, totalTime) { constructor(name, groups, totalTime) {
this.name = name; this.name = name;
this.groups = groups; this.groups = groups;
@ -1588,8 +1544,7 @@ class TestSuiteResult {
return this.groups.reduce((sum, g) => sum + g.skipped, 0); return this.groups.reduce((sum, g) => sum + g.skipped, 0);
} }
get time() { get time() {
var _a; return this.totalTime ?? this.groups.reduce((sum, g) => sum + g.time, 0);
return (_a = this.totalTime) !== null && _a !== void 0 ? _a : this.groups.reduce((sum, g) => sum + g.time, 0);
} }
get result() { get result() {
return this.groups.some(t => t.result === 'failed') ? 'failed' : 'success'; return this.groups.some(t => t.result === 'failed') ? 'failed' : 'success';
@ -1598,7 +1553,7 @@ class TestSuiteResult {
return this.groups.filter(grp => grp.result === 'failed'); return this.groups.filter(grp => grp.result === 'failed');
} }
sort(deep) { sort(deep) {
this.groups.sort((a, b) => { var _a, _b; return ((_a = a.name) !== null && _a !== void 0 ? _a : '').localeCompare((_b = b.name) !== null && _b !== void 0 ? _b : '', node_utils_1.DEFAULT_LOCALE); }); this.groups.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? '', node_utils_1.DEFAULT_LOCALE));
if (deep) { if (deep) {
for (const grp of this.groups) { for (const grp of this.groups) {
grp.sort(); grp.sort();
@ -1608,6 +1563,8 @@ class TestSuiteResult {
} }
exports.TestSuiteResult = TestSuiteResult; exports.TestSuiteResult = TestSuiteResult;
class TestGroupResult { class TestGroupResult {
name;
tests;
constructor(name, tests) { constructor(name, tests) {
this.name = name; this.name = name;
this.tests = tests; this.tests = tests;
@ -1636,6 +1593,10 @@ class TestGroupResult {
} }
exports.TestGroupResult = TestGroupResult; exports.TestGroupResult = TestGroupResult;
class TestCaseResult { class TestCaseResult {
name;
result;
time;
error;
constructor(name, result, time, error) { constructor(name, result, time, error) {
this.name = name; this.name = name;
this.result = result; this.result = result;
@ -1676,32 +1637,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.listFiles = listFiles; exports.listFiles = listFiles;
const core = __importStar(__nccwpck_require__(7484)); const core = __importStar(__nccwpck_require__(7484));
const exec_1 = __nccwpck_require__(5236); const exec_1 = __nccwpck_require__(5236);
function listFiles() { async function listFiles() {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Listing all files tracked by git'); core.startGroup('Listing all files tracked by git');
let output = ''; let output = '';
try { try {
output = (yield (0, exec_1.getExecOutput)('git', ['ls-files', '-z'])).stdout; output = (await (0, exec_1.getExecOutput)('git', ['ls-files', '-z'])).stdout;
} }
finally { finally {
fixStdOutNullTermination(); fixStdOutNullTermination();
core.endGroup(); core.endGroup();
} }
return output.split('\u0000').filter(s => s.length > 0); return output.split('\u0000').filter(s => s.length > 0);
});
} }
function fixStdOutNullTermination() { function fixStdOutNullTermination() {
// Previous command uses NULL as delimiters and output is printed to stdout. // Previous command uses NULL as delimiters and output is printed to stdout.
@ -1741,15 +1691,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -1784,16 +1725,19 @@ function getCheckRunContext() {
} }
return { sha: github.context.sha, runId }; return { sha: github.context.sha, runId };
} }
function downloadArtifact(octokit, artifactId, fileName, token) { async function downloadArtifact(octokit, artifactId, fileName, token) {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup(`Downloading artifact ${fileName}`); core.startGroup(`Downloading artifact ${fileName}`);
try { try {
core.info(`Artifact ID: ${artifactId}`); core.info(`Artifact ID: ${artifactId}`);
const req = octokit.rest.actions.downloadArtifact.endpoint(Object.assign(Object.assign({}, github.context.repo), { artifact_id: artifactId, archive_format: 'zip' })); const req = octokit.rest.actions.downloadArtifact.endpoint({
...github.context.repo,
artifact_id: artifactId,
archive_format: 'zip'
});
const headers = { const headers = {
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`
}; };
const resp = yield (0, got_1.default)(req.url, { const resp = await (0, got_1.default)(req.url, {
headers, headers,
followRedirect: false followRedirect: false
}); });
@ -1816,35 +1760,41 @@ function downloadArtifact(octokit, artifactId, fileName, token) {
downloadStream.on('downloadProgress', ({ transferred }) => { downloadStream.on('downloadProgress', ({ transferred }) => {
core.info(`Progress: ${transferred} B`); core.info(`Progress: ${transferred} B`);
}); });
yield asyncStream(downloadStream, fileWriterStream); await asyncStream(downloadStream, fileWriterStream);
} }
finally { finally {
core.endGroup(); core.endGroup();
} }
});
} }
function listFiles(octokit, sha) { async function listFiles(octokit, sha) {
return __awaiter(this, void 0, void 0, function* () {
core.startGroup('Fetching list of tracked files from GitHub'); core.startGroup('Fetching list of tracked files from GitHub');
try { try {
const commit = yield octokit.rest.git.getCommit(Object.assign({ commit_sha: sha }, github.context.repo)); const commit = await octokit.rest.git.getCommit({
const files = yield listGitTree(octokit, commit.data.tree.sha, ''); commit_sha: sha,
...github.context.repo
});
const files = await listGitTree(octokit, commit.data.tree.sha, '');
return files; return files;
} }
finally { finally {
core.endGroup(); core.endGroup();
} }
});
} }
function listGitTree(octokit, sha, path) { async function listGitTree(octokit, sha, path) {
return __awaiter(this, void 0, void 0, function* () {
const pathLog = path ? ` at ${path}` : ''; const pathLog = path ? ` at ${path}` : '';
core.info(`Fetching tree ${sha}${pathLog}`); core.info(`Fetching tree ${sha}${pathLog}`);
let truncated = false; let truncated = false;
let tree = yield octokit.rest.git.getTree(Object.assign({ recursive: 'true', tree_sha: sha }, github.context.repo)); let tree = await octokit.rest.git.getTree({
recursive: 'true',
tree_sha: sha,
...github.context.repo
});
if (tree.data.truncated) { if (tree.data.truncated) {
truncated = true; truncated = true;
tree = yield octokit.rest.git.getTree(Object.assign({ tree_sha: sha }, github.context.repo)); tree = await octokit.rest.git.getTree({
tree_sha: sha,
...github.context.repo
});
} }
const result = []; const result = [];
for (const tr of tree.data.tree) { for (const tr of tree.data.tree) {
@ -1853,12 +1803,11 @@ function listGitTree(octokit, sha, path) {
result.push(file); result.push(file);
} }
else if (tr.type === 'tree' && truncated) { else if (tr.type === 'tree' && truncated) {
const files = yield listGitTree(octokit, tr.sha, `${file}/`); const files = await listGitTree(octokit, tr.sha, `${file}/`);
result.push(...files); result.push(...files);
} }
} }
return result; return result;
});
} }
@ -1902,8 +1851,7 @@ function tableEscape(content) {
return content.toString().replace('|', '\\|'); return content.toString().replace('|', '\\|');
} }
function fixEol(text) { function fixEol(text) {
var _a; return text?.replace(/\r/g, '') ?? '';
return (_a = text === null || text === void 0 ? void 0 : text.replace(/\r/g, '')) !== null && _a !== void 0 ? _a : '';
} }
function ellipsis(text, maxLength) { function ellipsis(text, maxLength) {
if (text.length <= maxLength) { if (text.length <= maxLength) {
@ -1983,8 +1931,8 @@ function parseIsoDate(str) {
return new Date(str); return new Date(str);
} }
function getFirstNonEmptyLine(stackTrace) { function getFirstNonEmptyLine(stackTrace) {
const lines = stackTrace === null || stackTrace === void 0 ? void 0 : stackTrace.split(/\r?\n/g); const lines = stackTrace?.split(/\r?\n/g);
return lines === null || lines === void 0 ? void 0 : lines.find(str => !/^\s*$/.test(str)); return lines?.find(str => !/^\s*$/.test(str));
} }

View file

@ -1,261 +1,261 @@
// import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser'
// import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils'
// import { import {
// ReportEvent, ReportEvent,
// Suite, Suite,
// Group, Group,
// TestStartEvent, TestStartEvent,
// TestDoneEvent, TestDoneEvent,
// ErrorEvent, ErrorEvent,
// isSuiteEvent, isSuiteEvent,
// isGroupEvent, isGroupEvent,
// isTestStartEvent, isTestStartEvent,
// isTestDoneEvent, isTestDoneEvent,
// isErrorEvent, isErrorEvent,
// isDoneEvent, isDoneEvent,
// isMessageEvent, isMessageEvent,
// MessageEvent MessageEvent
// } from './dart-json-types' } from './dart-json-types'
// import { import {
// TestExecutionResult, TestExecutionResult,
// TestRunResult, TestRunResult,
// TestSuiteResult, TestSuiteResult,
// TestGroupResult, TestGroupResult,
// TestCaseResult, TestCaseResult,
// TestCaseError TestCaseError
// } from '../../test-results' } from '../../test-results'
// class TestRun { class TestRun {
// constructor( constructor(
// readonly path: string, readonly path: string,
// readonly suites: TestSuite[], readonly suites: TestSuite[],
// readonly success: boolean, readonly success: boolean,
// readonly time: number readonly time: number
// ) {} ) {}
// } }
// class TestSuite { class TestSuite {
// constructor(readonly suite: Suite) {} constructor(readonly suite: Suite) {}
// readonly groups: {[id: number]: TestGroup} = {} readonly groups: {[id: number]: TestGroup} = {}
// } }
// class TestGroup { class TestGroup {
// constructor(readonly group: Group) {} constructor(readonly group: Group) {}
// readonly tests: TestCase[] = [] readonly tests: TestCase[] = []
// } }
// class TestCase { class TestCase {
// constructor(readonly testStart: TestStartEvent) { constructor(readonly testStart: TestStartEvent) {
// this.groupId = testStart.test.groupIDs[testStart.test.groupIDs.length - 1] this.groupId = testStart.test.groupIDs[testStart.test.groupIDs.length - 1]
// } }
// readonly groupId: number readonly groupId: number
// readonly print: MessageEvent[] = [] readonly print: MessageEvent[] = []
// testDone?: TestDoneEvent testDone?: TestDoneEvent
// error?: ErrorEvent error?: ErrorEvent
// get result(): TestExecutionResult { get result(): TestExecutionResult {
// if (this.testDone?.skipped) { if (this.testDone?.skipped) {
// return 'skipped' return 'skipped'
// } }
// if (this.testDone?.result === 'success') { if (this.testDone?.result === 'success') {
// return 'success' return 'success'
// } }
// if (this.testDone?.result === 'error' || this.testDone?.result === 'failure') { if (this.testDone?.result === 'error' || this.testDone?.result === 'failure') {
// return 'failed' return 'failed'
// } }
// return undefined return undefined
// } }
// get time(): number { get time(): number {
// return this.testDone !== undefined ? this.testDone.time - this.testStart.time : 0 return this.testDone !== undefined ? this.testDone.time - this.testStart.time : 0
// } }
// } }
// export class DartJsonParser implements TestParser { export class DartJsonParser implements TestParser {
// assumedWorkDir: string | undefined assumedWorkDir: string | undefined
// constructor( constructor(
// readonly options: ParseOptions, readonly options: ParseOptions,
// readonly sdk: 'dart' | 'flutter' readonly sdk: 'dart' | 'flutter'
// ) {} ) {}
// async parse(path: string, content: string): Promise<TestRunResult> { async parse(path: string, content: string): Promise<TestRunResult> {
// const tr = this.getTestRun(path, content) const tr = this.getTestRun(path, content)
// const result = this.getTestRunResult(tr) const result = this.getTestRunResult(tr)
// return Promise.resolve(result) return Promise.resolve(result)
// } }
// private getTestRun(path: string, content: string): TestRun { private getTestRun(path: string, content: string): TestRun {
// const lines = content.split(/\n\r?/g) const lines = content.split(/\n\r?/g)
// const events = lines const events = lines
// .map((str, i) => { .map((str, i) => {
// if (str.trim() === '') { if (str.trim() === '') {
// return null return null
// } }
// try { try {
// return JSON.parse(str) return JSON.parse(str)
// } catch (e) { } catch (e) {
// const errWithCol = e as {columnNumber?: number} const errWithCol = e as {columnNumber?: number}
// const col = errWithCol.columnNumber !== undefined ? `:${errWithCol.columnNumber}` : '' const col = errWithCol.columnNumber !== undefined ? `:${errWithCol.columnNumber}` : ''
// throw new Error(`Invalid JSON at ${path}:${i + 1}${col}\n\n${e}`) throw new Error(`Invalid JSON at ${path}:${i + 1}${col}\n\n${e}`)
// } }
// }) })
// .filter(evt => evt != null) as ReportEvent[] .filter(evt => evt != null) as ReportEvent[]
// let success = false let success = false
// let totalTime = 0 let totalTime = 0
// const suites: {[id: number]: TestSuite} = {} const suites: {[id: number]: TestSuite} = {}
// const tests: {[id: number]: TestCase} = {} const tests: {[id: number]: TestCase} = {}
// for (const evt of events) { for (const evt of events) {
// if (isSuiteEvent(evt)) { if (isSuiteEvent(evt)) {
// suites[evt.suite.id] = new TestSuite(evt.suite) suites[evt.suite.id] = new TestSuite(evt.suite)
// } else if (isGroupEvent(evt)) { } else if (isGroupEvent(evt)) {
// suites[evt.group.suiteID].groups[evt.group.id] = new TestGroup(evt.group) suites[evt.group.suiteID].groups[evt.group.id] = new TestGroup(evt.group)
// } else if (isTestStartEvent(evt) && evt.test.url !== null) { } else if (isTestStartEvent(evt) && evt.test.url !== null) {
// const test: TestCase = new TestCase(evt) const test: TestCase = new TestCase(evt)
// const suite = suites[evt.test.suiteID] const suite = suites[evt.test.suiteID]
// const group = suite.groups[evt.test.groupIDs[evt.test.groupIDs.length - 1]] const group = suite.groups[evt.test.groupIDs[evt.test.groupIDs.length - 1]]
// group.tests.push(test) group.tests.push(test)
// tests[evt.test.id] = test tests[evt.test.id] = test
// } else if (isTestDoneEvent(evt) && !evt.hidden && tests[evt.testID]) { } else if (isTestDoneEvent(evt) && !evt.hidden && tests[evt.testID]) {
// tests[evt.testID].testDone = evt tests[evt.testID].testDone = evt
// } else if (isErrorEvent(evt) && tests[evt.testID]) { } else if (isErrorEvent(evt) && tests[evt.testID]) {
// tests[evt.testID].error = evt tests[evt.testID].error = evt
// } else if (isMessageEvent(evt) && tests[evt.testID]) { } else if (isMessageEvent(evt) && tests[evt.testID]) {
// tests[evt.testID].print.push(evt) tests[evt.testID].print.push(evt)
// } else if (isDoneEvent(evt)) { } else if (isDoneEvent(evt)) {
// success = evt.success success = evt.success
// totalTime = evt.time totalTime = evt.time
// } }
// } }
// return new TestRun(path, Object.values(suites), success, totalTime) return new TestRun(path, Object.values(suites), success, totalTime)
// } }
// private getTestRunResult(tr: TestRun): TestRunResult { private getTestRunResult(tr: TestRun): TestRunResult {
// const suites = tr.suites.map(s => { const suites = tr.suites.map(s => {
// return new TestSuiteResult(this.getRelativePath(s.suite.path), this.getGroups(s)) return new TestSuiteResult(this.getRelativePath(s.suite.path), this.getGroups(s))
// }) })
// return new TestRunResult(tr.path, suites, tr.time) return new TestRunResult(tr.path, suites, tr.time)
// } }
// private getGroups(suite: TestSuite): TestGroupResult[] { private getGroups(suite: TestSuite): TestGroupResult[] {
// const groups = Object.values(suite.groups).filter(grp => grp.tests.length > 0) const groups = Object.values(suite.groups).filter(grp => grp.tests.length > 0)
// groups.sort((a, b) => (a.group.line ?? 0) - (b.group.line ?? 0)) groups.sort((a, b) => (a.group.line ?? 0) - (b.group.line ?? 0))
// return groups.map(group => { return groups.map(group => {
// group.tests.sort((a, b) => (a.testStart.test.line ?? 0) - (b.testStart.test.line ?? 0)) group.tests.sort((a, b) => (a.testStart.test.line ?? 0) - (b.testStart.test.line ?? 0))
// const tests = group.tests.map(tc => { const tests = group.tests.map(tc => {
// const error = this.getError(suite, tc) const error = this.getError(suite, tc)
// const testName = const testName =
// group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name) group.group.name !== undefined && tc.testStart.test.name.startsWith(group.group.name)
// ? tc.testStart.test.name.slice(group.group.name.length).trim() ? tc.testStart.test.name.slice(group.group.name.length).trim()
// : tc.testStart.test.name.trim() : tc.testStart.test.name.trim()
// return new TestCaseResult(testName, tc.result, tc.time, error) return new TestCaseResult(testName, tc.result, tc.time, error)
// }) })
// return new TestGroupResult(group.group.name, tests) return new TestGroupResult(group.group.name, tests)
// }) })
// } }
// private getError(testSuite: TestSuite, test: TestCase): TestCaseError | undefined { private getError(testSuite: TestSuite, test: TestCase): TestCaseError | undefined {
// if (!this.options.parseErrors || !test.error) { if (!this.options.parseErrors || !test.error) {
// return undefined return undefined
// } }
// const {trackedFiles} = this.options const {trackedFiles} = this.options
// const stackTrace = test.error?.stackTrace ?? '' const stackTrace = test.error?.stackTrace ?? ''
// const print = test.print const print = test.print
// .filter(p => p.messageType === 'print') .filter(p => p.messageType === 'print')
// .map(p => p.message) .map(p => p.message)
// .join('\n') .join('\n')
// const details = [print, stackTrace].filter(str => str !== '').join('\n') const details = [print, stackTrace].filter(str => str !== '').join('\n')
// const src = this.exceptionThrowSource(details, trackedFiles) const src = this.exceptionThrowSource(details, trackedFiles)
// const message = this.getErrorMessage(test.error?.error ?? '', print) const message = this.getErrorMessage(test.error?.error ?? '', print)
// let path let path
// let line let line
// if (src !== undefined) { if (src !== undefined) {
// path = src.path path = src.path
// line = src.line line = src.line
// } else { } else {
// const testStartPath = this.getRelativePath(testSuite.suite.path) const testStartPath = this.getRelativePath(testSuite.suite.path)
// if (trackedFiles.includes(testStartPath)) { if (trackedFiles.includes(testStartPath)) {
// path = testStartPath path = testStartPath
// line = test.testStart.test.root_line ?? test.testStart.test.line ?? undefined line = test.testStart.test.root_line ?? test.testStart.test.line ?? undefined
// } }
// } }
// return { return {
// path, path,
// line, line,
// message, message,
// details details
// } }
// } }
// private getErrorMessage(message: string, print: string): string { private getErrorMessage(message: string, print: string): string {
// if (this.sdk === 'flutter') { if (this.sdk === 'flutter') {
// const uselessMessageRe = /^Test failed\. See exception logs above\.\nThe test description was:/m const uselessMessageRe = /^Test failed\. See exception logs above\.\nThe test description was:/m
// const flutterPrintRe = const flutterPrintRe =
// /^══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═+\s+(.*)\s+When the exception was thrown, this was the stack:/ms /^ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK +\s+(.*)\s+When the exception was thrown, this was the stack:/ms
// if (uselessMessageRe.test(message)) { if (uselessMessageRe.test(message)) {
// const match = print.match(flutterPrintRe) const match = print.match(flutterPrintRe)
// if (match !== null) { if (match !== null) {
// return match[1] return match[1]
// } }
// } }
// } }
// return message || print return message || print
// } }
// private exceptionThrowSource(ex: string, trackedFiles: string[]): {path: string; line: number} | undefined { private exceptionThrowSource(ex: string, trackedFiles: string[]): {path: string; line: number} | undefined {
// const lines = ex.split(/\r?\n/g) const lines = ex.split(/\r?\n/g)
// // regexp to extract file path and line number from stack trace // regexp to extract file path and line number from stack trace
// const dartRe = /^(?!package:)(.*)\s+(\d+):\d+\s+/ const dartRe = /^(?!package:)(.*)\s+(\d+):\d+\s+/
// const flutterRe = /^#\d+\s+.*\((?!package:)(.*):(\d+):\d+\)$/ const flutterRe = /^#\d+\s+.*\((?!package:)(.*):(\d+):\d+\)$/
// const re = this.sdk === 'dart' ? dartRe : flutterRe const re = this.sdk === 'dart' ? dartRe : flutterRe
// for (const str of lines) { for (const str of lines) {
// const match = str.match(re) const match = str.match(re)
// if (match !== null) { if (match !== null) {
// const [_, pathStr, lineStr] = match const [_, pathStr, lineStr] = match
// const path = normalizeFilePath(this.getRelativePath(pathStr)) const path = normalizeFilePath(this.getRelativePath(pathStr))
// if (trackedFiles.includes(path)) { if (trackedFiles.includes(path)) {
// const line = parseInt(lineStr) const line = parseInt(lineStr)
// return {path, line} return {path, line}
// } }
// } }
// } }
// } }
// private getRelativePath(path: string): string { private getRelativePath(path: string): string {
// const prefix = 'file://' const prefix = 'file://'
// if (path.startsWith(prefix)) { if (path.startsWith(prefix)) {
// path = path.substr(prefix.length) path = path.substr(prefix.length)
// } }
// path = normalizeFilePath(path) path = normalizeFilePath(path)
// const workDir = this.getWorkDir(path) const workDir = this.getWorkDir(path)
// if (workDir !== undefined && path.startsWith(workDir)) { if (workDir !== undefined && path.startsWith(workDir)) {
// path = path.substr(workDir.length) path = path.substr(workDir.length)
// } }
// return path return path
// } }
// private getWorkDir(path: string): string | undefined { private getWorkDir(path: string): string | undefined {
// return ( return (
// this.options.workDir ?? this.options.workDir ??
// this.assumedWorkDir ?? this.assumedWorkDir ??
// (this.assumedWorkDir = getBasePath(path, this.options.trackedFiles)) (this.assumedWorkDir = getBasePath(path, this.options.trackedFiles))
// ) )
// } }
// } }

View file

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2023", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */