@empiricalrun/reporter
Advanced tools
Comparing version 0.6.0 to 0.6.1
# @empiricalrun/reporter | ||
## 0.6.1 | ||
### Patch Changes | ||
- bad62f7: feat: dashboard sink runs for test-run workflow | ||
## 0.6.0 | ||
@@ -4,0 +10,0 @@ |
@@ -27,4 +27,3 @@ "use strict"; | ||
Test ${results.hasPassed ? "passed" : "failed"}. | ||
View details: ${this.reportSource.reportLink()}} | ||
`, | ||
View details: ${this.reportSource.reportLink()}}`, | ||
pull_request: this.prLink, | ||
@@ -40,4 +39,3 @@ }; | ||
Test started. | ||
View details: ${this.runLink}} | ||
`, | ||
View details: ${this.runLink}}`, | ||
pull_request: this.prLink, | ||
@@ -53,4 +51,3 @@ }; | ||
Test failed to run. | ||
View details: ${this.runLink}} | ||
`, | ||
View details: ${this.runLink}}`, | ||
pull_request: this.prLink, | ||
@@ -66,4 +63,3 @@ }; | ||
Test generation started. | ||
View details: ${this.runLink}} | ||
`, | ||
View details: ${this.runLink}}`, | ||
pull_request: this.prLink, | ||
@@ -79,4 +75,3 @@ }; | ||
Successfully generated tests. | ||
View details: ${this.prLink}} | ||
`, | ||
View details: ${this.prLink}}`, | ||
pull_request: this.prLink, | ||
@@ -101,3 +96,3 @@ }; | ||
catch (e) { | ||
console.error(`Error sending message to Slack: ${e.code}`); | ||
console.error(`Error sending message to Dashboard: ${e.code}`); | ||
console.error(e.message); | ||
@@ -104,0 +99,0 @@ } |
@@ -21,2 +21,3 @@ export declare function humanReadable(duration: number): string; | ||
export declare function getGhEventPullNumber(): number | undefined; | ||
export declare function isRunningForAutomatedPR(): boolean; | ||
/** | ||
@@ -23,0 +24,0 @@ * |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getGhEventPrLink = exports.getGhEventPullNumber = exports.getGhEvent = exports.buildGhRunLink = exports.parseJsonReport = exports.humanReadable = void 0; | ||
exports.getGhEventPrLink = exports.isRunningForAutomatedPR = exports.getGhEventPullNumber = exports.getGhEvent = exports.buildGhRunLink = exports.parseJsonReport = exports.humanReadable = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -54,2 +54,11 @@ function humanReadable(duration) { | ||
exports.getGhEventPullNumber = getGhEventPullNumber; | ||
function isRunningForAutomatedPR() { | ||
const event = getGhEvent(); | ||
if (event) { | ||
const { labels } = event.pull_request; | ||
return (getGhEventPullNumber() && labels.some((l) => l.name === "automated")); | ||
} | ||
return false; | ||
} | ||
exports.isRunningForAutomatedPR = isRunningForAutomatedPR; | ||
/** | ||
@@ -56,0 +65,0 @@ * |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TestRunWorkflow = void 0; | ||
const dashboard_1 = require("../sink/dashboard"); | ||
const google_1 = require("../sink/google"); | ||
@@ -33,10 +34,11 @@ const slack_1 = require("../sink/slack"); | ||
} | ||
let sink; | ||
let sinks = []; | ||
try { | ||
const sinkUrl = new URL(process.env.SLACK_WEBHOOK_URL); | ||
const sinkUrlStr = sinkUrl.toString(); | ||
if (sinkUrl.hostname === "hooks.slack.com") { | ||
sink = new slack_1.SlackReportSink(sinkUrl.toString(), runLink, runId, reportSource); | ||
sinks.push(new slack_1.SlackReportSink(sinkUrlStr, runLink, runId, reportSource)); | ||
} | ||
else if (sinkUrl.hostname === "chat.googleapis.com") { | ||
sink = new google_1.GoogleChatReportSink(sinkUrl.toString(), runLink, runId, reportSource); | ||
sinks.push(new google_1.GoogleChatReportSink(sinkUrlStr, runLink, runId, reportSource)); | ||
} | ||
@@ -50,11 +52,15 @@ else { | ||
} | ||
if ((0, utils_1.isRunningForAutomatedPR)()) { | ||
const prLink = (0, utils_1.getGhEventPrLink)(repoName); | ||
sinks.push(new dashboard_1.DashboardSink("", runLink, runId, reportSource, prLink)); | ||
} | ||
if (messageType === "start") { | ||
await sink.sendStartMessage(); | ||
await Promise.all(sinks.map((s) => s.sendStartMessage())); | ||
} | ||
else if (messageType === "end") { | ||
if (!reportSource.reportExists()) { | ||
await sink.sendMessageForError(); | ||
await Promise.all(sinks.map((s) => s.sendMessageForError())); | ||
} | ||
else { | ||
await sink.sendEndMessage(); | ||
await Promise.all(sinks.map((s) => s.sendEndMessage())); | ||
} | ||
@@ -61,0 +67,0 @@ } |
{ | ||
"name": "@empiricalrun/reporter", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "registry": "https://registry.npmjs.org/", |
@@ -7,7 +7,4 @@ # reporter | ||
Current version only returns the message payload for the slack github | ||
action (slackapi/slack-github-action@v1.26.0) to pick and send to slack. | ||
```sh | ||
npx @empiricalrun/reporter $MESSAGE_TYPE $CUSTOMER_NAME $RUN_ID $REPORT_TYPE | ||
npx @empiricalrun/reporter $WORKFLOW $MESSAGE_TYPE $CUSTOMER_NAME $RUN_ID $REPORT_TYPE | ||
``` | ||
@@ -17,2 +14,3 @@ | ||
- `$WORKFLOW`: can be `test-run` or `test-gen` | ||
- `$MESSAGE_TYPE`: can be `start` (message for tests started) or `end` (message for tests completed) | ||
@@ -19,0 +17,0 @@ - `$CUSTOMER_NAME`: name of the customer (e.g. leap-wallet) which resolves to _both_ github and r2 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43552
1045
2
29