@reporters/github 1.1.0 → 1.1.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.2](https://github.com/MoLow/reporters/compare/github-v1.1.1...github-v1.1.2) (2023-02-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **github:** remove redundant diagnostics ([b62df32](https://github.com/MoLow/reporters/commit/b62df3280b141af763386a68b0b4e386bef907e7))
9
+
10
+ ## [1.1.1](https://github.com/MoLow/reporters/compare/github-v1.1.0...github-v1.1.1) (2023-02-28)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **github:** silent if not running on github actions ([#33](https://github.com/MoLow/reporters/issues/33)) ([a480454](https://github.com/MoLow/reporters/commit/a480454ac7ca0471744ec00b69a6c67a1d3c8ada))
16
+
3
17
  ## [1.1.0](https://github.com/MoLow/reporters/compare/github-v1.0.2...github-v1.1.0) (2023-02-02)
4
18
 
5
19
 
package/index.js CHANGED
@@ -33,6 +33,11 @@ const DIAGNOSTIC_VALUES = {
33
33
  };
34
34
 
35
35
  module.exports = async function githubReporter(source) {
36
+ if (!process.env.GITHUB_ACTIONS) {
37
+ // eslint-disable-next-line no-unused-vars
38
+ for await (const _ of source);
39
+ return;
40
+ }
36
41
  const counter = { pass: 0, fail: 0 };
37
42
  const diagnostics = [];
38
43
  for await (const event of source) {
@@ -59,9 +64,10 @@ module.exports = async function githubReporter(source) {
59
64
  counter.fail += 1;
60
65
  break;
61
66
  } case 'test:diagnostic':
62
- core.notice(event.data.message, { file: getFilePath(event.data.file) });
63
67
  if (event.data.nesting === 0) {
64
68
  diagnostics.push(event.data.message);
69
+ } else {
70
+ core.notice(event.data.message, { file: getFilePath(event.data.file) });
65
71
  }
66
72
  break;
67
73
  default:
@@ -80,8 +86,10 @@ module.exports = async function githubReporter(source) {
80
86
  core.notice(formatedDiagnostics.map((d) => d.join(': ')).join(EOL));
81
87
  core.endGroup();
82
88
 
83
- await core.summary
84
- .addHeading('Test Results')
85
- .addTable(formatedDiagnostics)
86
- .write();
89
+ if (process.env.GITHUB_STEP_SUMMARY) {
90
+ await core.summary
91
+ .addHeading('Test Results')
92
+ .addTable(formatedDiagnostics)
93
+ .write();
94
+ }
87
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reporters/github",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A github actions reporter for `node:test`",
5
5
  "keywords": [
6
6
  "github actions",
@@ -14,7 +14,7 @@
14
14
  "stack-utils": "^2.0.6"
15
15
  },
16
16
  "scripts": {
17
- "test": "node --test-reporter=spec --test"
17
+ "test": "node --test-reporter=spec --test-reporter-destination=stdout --test-reporter=./index.js --test-reporter-destination=stdout --test"
18
18
  },
19
19
  "bugs": {
20
20
  "url": "https://github.com/MoLow/reporters/issues"
@@ -11,7 +11,7 @@ const GITHUB_STEP_SUMMARY = join(tmpdir(), 'github-actions-test-reporter');
11
11
  writeFileSync(GITHUB_STEP_SUMMARY, '');
12
12
 
13
13
  const child = spawnSync(process.execPath, ['--test-reporter', './index.js', '../../tests/example'], {
14
- env: { GITHUB_STEP_SUMMARY, GITHUB_WORKSPACE: path.resolve(__dirname, '../../../') },
14
+ env: { GITHUB_ACTIONS: true, GITHUB_STEP_SUMMARY, GITHUB_WORKSPACE: path.resolve(__dirname, '../../../') },
15
15
  });
16
16
 
17
17
  assert.strictEqual(child.stderr?.toString(), '');
package/tests/output.js CHANGED
@@ -5,13 +5,6 @@ module.exports = {
5
5
  ::debug::starting to run fails
6
6
  ::error title=fails,file=tests/example.js::\\[Error \\[ERR_TEST_FAILURE\\]: this is an error\\] {%0A failureType: 'testCodeFailure',%0A cause: Error: this is an error%0A at Object.<anonymous> (.*/example.js:6:11).*
7
7
  ::error title=tests,file=tests/example.js::\\[Error \\[ERR_TEST_FAILURE\\]: 1 subtest failed\\] { failureType: 'subtestsFailed', cause: '1 subtest failed', code: 'ERR_TEST_FAILURE' }
8
- ::notice file=tests/example.js::tests 1
9
- ::notice file=tests/example.js::pass 0
10
- ::notice file=tests/example.js::fail 1
11
- ::notice file=tests/example.js::cancelled 0
12
- ::notice file=tests/example.js::skipped 0
13
- ::notice file=tests/example.js::todo 0
14
- ::notice file=tests/example.js::duration_ms .*
15
8
  ::group::Test results \\(1 passed, 2 failed\\)
16
9
  ::notice::Total Tests: 1%0APassed ✅: 0%0AFailed ❌: 1%0ACanceled 🚫: 0%0ASkipped ⏭️: 0%0ATodo 📝: 0%0ADuration: .*ms
17
10
  ::endgroup::