squally-reporter 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +59 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53,6 +53,39 @@ function detectCommitSha() {
53
53
  return null;
54
54
  }
55
55
  }
56
+ // GitLab CI exposes the full commit message directly (CI_COMMIT_MESSAGE).
57
+ // GitHub Actions has no equivalent env var, so it falls through to the git
58
+ // fallback below same as local runs - actions/checkout always leaves at
59
+ // least the HEAD commit available, even at fetch depth 1.
60
+ function detectCommitMessage() {
61
+ if (process.env.CI_COMMIT_MESSAGE)
62
+ return process.env.CI_COMMIT_MESSAGE;
63
+ try {
64
+ return (0, node_child_process_1.execSync)("git log -1 --pretty=%B").toString().trim();
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
70
+ // GitHub Actions' GITHUB_ACTOR is the user who triggered the workflow run
71
+ // (a username, not necessarily the commit author, but the closest thing
72
+ // GitHub exposes without shelling out). GitLab's CI_COMMIT_AUTHOR is
73
+ // "Name <email>" - only the name part is kept. Falls back to the actual
74
+ // git commit author for everything else (other CI providers, local runs).
75
+ function detectAuthorName() {
76
+ if (process.env.GITHUB_ACTOR)
77
+ return process.env.GITHUB_ACTOR;
78
+ if (process.env.CI_COMMIT_AUTHOR) {
79
+ const match = process.env.CI_COMMIT_AUTHOR.match(/^(.*?)\s*<[^>]*>\s*$/);
80
+ return match ? match[1] : process.env.CI_COMMIT_AUTHOR;
81
+ }
82
+ try {
83
+ return (0, node_child_process_1.execSync)("git log -1 --pretty=%an").toString().trim();
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
56
89
  // --- Flakiness Engine v2 (Phase A): tested application revision ---
57
90
  //
58
91
  // commitSha above is the test-automation repo's own commit. For teams whose
@@ -110,6 +143,22 @@ function detectEventType() {
110
143
  function toPosixPath(p) {
111
144
  return p.split(node_path_1.default.sep).join("/");
112
145
  }
146
+ // Playwright captures stdout/stderr as two separate arrays (each internally
147
+ // chronological, but not merged with each other), so a true byte-accurate
148
+ // interleaving between the two streams isn't available here - stdout lines
149
+ // come first, then stderr, each tagged with its source. No [warn] prefix:
150
+ // Node itself writes console.warn to stderr right alongside console.error,
151
+ // so that distinction isn't recoverable from this API either.
152
+ function formatConsoleOutput(result) {
153
+ const lines = [];
154
+ for (const chunk of result.stdout) {
155
+ lines.push(`[log] ${chunk.toString().replace(/\s+$/, "")}`);
156
+ }
157
+ for (const chunk of result.stderr) {
158
+ lines.push(`[error] ${chunk.toString().replace(/\s+$/, "")}`);
159
+ }
160
+ return lines.length > 0 ? lines.join("\n") : null;
161
+ }
113
162
  class SquallyReporter {
114
163
  constructor(options = {}) {
115
164
  this.startedAt = new Date();
@@ -136,13 +185,23 @@ class SquallyReporter {
136
185
  retryCount: result.retry,
137
186
  errorMessage: error?.message ?? null,
138
187
  errorStack: error?.stack ?? null,
188
+ consoleOutput: formatConsoleOutput(result),
139
189
  });
140
190
  }
141
191
  async onEnd(result) {
192
+ // A run with 0 test results is meaningless for Squally's flakiness
193
+ // calculation and would just be dashboard clutter - regardless of why
194
+ // there were none (npx playwright test --list, an empty testDir, a
195
+ // --grep filter that matched nothing). Bail out before building/
196
+ // sending anything.
197
+ if (this.results.length === 0)
198
+ return;
142
199
  const resolvedRevision = resolveTestedRevision();
143
200
  const payload = {
144
201
  branch: detectBranch(),
145
202
  commitSha: detectCommitSha(),
203
+ commitMessage: detectCommitMessage(),
204
+ authorName: detectAuthorName(),
146
205
  ciProvider: detectCiProvider(),
147
206
  status: result.status === "passed" ? "passed" : "failed",
148
207
  startedAt: this.startedAt.toISOString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squally-reporter",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Playwright reporter that sends test results to your Squally dashboard.",
5
5
  "author": "Squally <squally.dev@gmail.com>",
6
6
  "keywords": [