mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 14:57:09 +01:00
fix: only push results when the url is set
This commit is contained in:
parent
108abd4de9
commit
59060a80a8
2 changed files with 42 additions and 38 deletions
36
dist/index.js
generated
vendored
36
dist/index.js
generated
vendored
|
|
@ -192,7 +192,7 @@ class TestReporter {
|
|||
}
|
||||
}
|
||||
run() {
|
||||
var _a;
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.workDirInput) {
|
||||
core.info(`Changing directory to '${this.workDirInput}'`);
|
||||
|
|
@ -218,21 +218,23 @@ class TestReporter {
|
|||
const parser = this.getParser(this.reporter, options);
|
||||
const results = [];
|
||||
const input = yield inputProvider.load();
|
||||
try {
|
||||
const readStream = input.trxZip.toBuffer();
|
||||
const version = fs_1.default.existsSync('test/EVA.TestSuite.Core/bin/Release/version.txt')
|
||||
? fs_1.default.readFileSync('test/EVA.TestSuite.Core/bin/Release/version.txt').toString()
|
||||
: null;
|
||||
const commitID = fs_1.default.existsSync('test/EVA.TestSuite.Core/bin/Release/commit.txt')
|
||||
? fs_1.default.readFileSync('test/EVA.TestSuite.Core/bin/Release/commit.txt').toString()
|
||||
: null;
|
||||
core.info(`Using EVA version ${version}, commit ${commitID}, branch ${this.context.branch}, current directory: ${(0, process_1.cwd)()}`);
|
||||
const post = (0, bent_1.default)(this.resultsEndpoint, 'POST', {}, 200);
|
||||
yield post(`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${commitID ? '&EVACommitID=' + commitID : ''}&EVABranch=${encodeURI(this.context.branch)}`, readStream);
|
||||
core.info(`Uploaded TRX files`);
|
||||
}
|
||||
catch (ex) {
|
||||
core.warning(`Could not upload TRX ZIP file: ${ex}`);
|
||||
if (((_a = this.resultsEndpoint) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
||||
try {
|
||||
const readStream = input.trxZip.toBuffer();
|
||||
const version = fs_1.default.existsSync('test/EVA.TestSuite.Core/bin/Release/version.txt')
|
||||
? fs_1.default.readFileSync('test/EVA.TestSuite.Core/bin/Release/version.txt').toString()
|
||||
: null;
|
||||
const commitID = fs_1.default.existsSync('test/EVA.TestSuite.Core/bin/Release/commit.txt')
|
||||
? fs_1.default.readFileSync('test/EVA.TestSuite.Core/bin/Release/commit.txt').toString()
|
||||
: null;
|
||||
core.info(`Using EVA version ${version}, commit ${commitID}, branch ${this.context.branch}, current directory: ${(0, process_1.cwd)()}`);
|
||||
const post = (0, bent_1.default)(this.resultsEndpoint, 'POST', {}, 200);
|
||||
yield post(`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${commitID ? '&EVACommitID=' + commitID : ''}&EVABranch=${encodeURI(this.context.branch)}`, readStream);
|
||||
core.info(`Uploaded TRX files`);
|
||||
}
|
||||
catch (ex) {
|
||||
core.warning(`Could not upload TRX ZIP file: ${ex}`);
|
||||
}
|
||||
}
|
||||
for (const [reportName, files] of Object.entries(input.reports)) {
|
||||
try {
|
||||
|
|
@ -270,7 +272,7 @@ class TestReporter {
|
|||
core.endGroup();
|
||||
return;
|
||||
}
|
||||
core.info(`${t.name}: ${(_a = t.error) === null || _a === void 0 ? void 0 : _a.message}`);
|
||||
core.info(`${t.name}: ${(_b = t.error) === null || _b === void 0 ? void 0 : _b.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
44
src/main.ts
44
src/main.ts
|
|
@ -105,29 +105,31 @@ class TestReporter {
|
|||
const results: TestRunResultWithUrl[] = []
|
||||
const input = await inputProvider.load()
|
||||
|
||||
try {
|
||||
const readStream = input.trxZip.toBuffer()
|
||||
const version = fs.existsSync('test/EVA.TestSuite.Core/bin/Release/version.txt')
|
||||
? fs.readFileSync('test/EVA.TestSuite.Core/bin/Release/version.txt').toString()
|
||||
: null
|
||||
const commitID = fs.existsSync('test/EVA.TestSuite.Core/bin/Release/commit.txt')
|
||||
? fs.readFileSync('test/EVA.TestSuite.Core/bin/Release/commit.txt').toString()
|
||||
: null
|
||||
if (this.resultsEndpoint?.length > 0) {
|
||||
try {
|
||||
const readStream = input.trxZip.toBuffer()
|
||||
const version = fs.existsSync('test/EVA.TestSuite.Core/bin/Release/version.txt')
|
||||
? fs.readFileSync('test/EVA.TestSuite.Core/bin/Release/version.txt').toString()
|
||||
: null
|
||||
const commitID = fs.existsSync('test/EVA.TestSuite.Core/bin/Release/commit.txt')
|
||||
? fs.readFileSync('test/EVA.TestSuite.Core/bin/Release/commit.txt').toString()
|
||||
: null
|
||||
|
||||
core.info(
|
||||
`Using EVA version ${version}, commit ${commitID}, branch ${this.context.branch}, current directory: ${cwd()}`
|
||||
)
|
||||
core.info(
|
||||
`Using EVA version ${version}, commit ${commitID}, branch ${this.context.branch}, current directory: ${cwd()}`
|
||||
)
|
||||
|
||||
const post = bent(this.resultsEndpoint, 'POST', {}, 200)
|
||||
await post(
|
||||
`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${
|
||||
commitID ? '&EVACommitID=' + commitID : ''
|
||||
}&EVABranch=${encodeURI(this.context.branch)}`,
|
||||
readStream
|
||||
)
|
||||
core.info(`Uploaded TRX files`)
|
||||
} catch (ex) {
|
||||
core.warning(`Could not upload TRX ZIP file: ${ex}`)
|
||||
const post = bent(this.resultsEndpoint, 'POST', {}, 200)
|
||||
await post(
|
||||
`TestResults?Secret=${this.resultsEndpointSecret}${version ? '&EVAVersion=' + version : ''}${
|
||||
commitID ? '&EVACommitID=' + commitID : ''
|
||||
}&EVABranch=${encodeURI(this.context.branch)}`,
|
||||
readStream
|
||||
)
|
||||
core.info(`Uploaded TRX files`)
|
||||
} catch (ex) {
|
||||
core.warning(`Could not upload TRX ZIP file: ${ex}`)
|
||||
}
|
||||
}
|
||||
|
||||
for (const [reportName, files] of Object.entries(input.reports)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue