squally-reporter 0.1.0 → 0.2.0

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 +61 -1
  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
@@ -102,6 +135,30 @@ function detectEventType() {
102
135
  return process.env.CI_PIPELINE_SOURCE;
103
136
  return null;
104
137
  }
138
+ // path.relative() joins with path.sep, which is "\" on Windows and "/" on
139
+ // POSIX. Since testName+filePath is Squally's test identity, an
140
+ // un-normalized filePath would make the same test look like two different
141
+ // tests depending on which OS the run happened on - always normalize to
142
+ // forward slashes regardless of host platform.
143
+ function toPosixPath(p) {
144
+ return p.split(node_path_1.default.sep).join("/");
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
+ }
105
162
  class SquallyReporter {
106
163
  constructor(options = {}) {
107
164
  this.startedAt = new Date();
@@ -122,12 +179,13 @@ class SquallyReporter {
122
179
  const error = result.errors[0];
123
180
  this.results.push({
124
181
  testName: test.titlePath().slice(1).join(" > "),
125
- filePath: node_path_1.default.relative(process.cwd(), test.location.file),
182
+ filePath: toPosixPath(node_path_1.default.relative(process.cwd(), test.location.file)),
126
183
  status: mapStatus(result.status),
127
184
  durationMs: result.duration,
128
185
  retryCount: result.retry,
129
186
  errorMessage: error?.message ?? null,
130
187
  errorStack: error?.stack ?? null,
188
+ consoleOutput: formatConsoleOutput(result),
131
189
  });
132
190
  }
133
191
  async onEnd(result) {
@@ -135,6 +193,8 @@ class SquallyReporter {
135
193
  const payload = {
136
194
  branch: detectBranch(),
137
195
  commitSha: detectCommitSha(),
196
+ commitMessage: detectCommitMessage(),
197
+ authorName: detectAuthorName(),
138
198
  ciProvider: detectCiProvider(),
139
199
  status: result.status === "passed" ? "passed" : "failed",
140
200
  startedAt: this.startedAt.toISOString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squally-reporter",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Playwright reporter that sends test results to your Squally dashboard.",
5
5
  "author": "Squally <squally.dev@gmail.com>",
6
6
  "keywords": [