Skip to content

Commit 2441b8a

Browse files
Release v3.0.1
- Improved PR comment formatting with clickable file links - Added validation for invalid report format configuration - Added error handling for malformed YAML config files - Added error handling for invalid custom-matchers JSON input - Skip annotations with empty messages - Improved error messages and handling in XML report parsing - Ensure all annotations have a start line for proper GitHub display - Added test coverage for invalid YAML config parsing - Excluded untestable xpath fallback code from coverage reporting
1 parent e7d6c06 commit 2441b8a

File tree

10 files changed

+310
-166
lines changed

10 files changed

+310
-166
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
dist/
44
node_modules/
55
coverage/
6+
fixtures/invalid-config.yml

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
# Changelog
44

5+
## [3.0.1] - 2025-12-30
6+
7+
### Fixed
8+
9+
- Improved PR comment formatting with clickable file links when annotations are skipped
10+
- Added validation for invalid report format configuration
11+
- Added error handling for malformed YAML config files
12+
- Added error handling for invalid custom-matchers JSON input
13+
- Skip annotations with empty messages to avoid creating blank annotations
14+
- Improved error messages and handling in XML report parsing
15+
- Ensure all annotations have a start line for proper GitHub display
16+
- Added test coverage for invalid YAML config parsing error handling
17+
- Excluded untestable xpath fallback code from coverage reporting
18+
519
## [3.0.0] - 2025-12-17
620

721
### Breaking Changes

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,12 @@ steps:
5757

5858
When the maximum number of annotations per type is reached, additional
5959
annotations are not displayed as GitHub annotations to avoid clutter. Instead,
60-
they are added as a comment on the pull request using GitHub's markdown box
61-
syntax:
62-
63-
- **Error** boxes for skipped error annotations
64-
- **Warning** boxes for skipped warning annotations
65-
- **Note** boxes for skipped notice annotations
66-
67-
This ensures that all issues are still visible to developers without
68-
overwhelming the GitHub UI.
60+
they are added as a comment on the pull request.
6961

7062
> [!NOTE] For more information about GitHub Actions annotation limitations, see
7163
> the
7264
> [official documentation](https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md#limitations).
7365

74-
> [!NOTE]
75-
>
76-
> You'll need to have a reasonably modern version of
77-
> [Node.js](https://nodejs.org) handy (20.x or later should work!). If you are
78-
> using a version manager like [`nodenv`](https://github.com/nodenv/nodenv) or
79-
> [`fnm`](https://github.com/Schniz/fnm), this template has a `.node-version`
80-
> file at the root of the repository that can be used to automatically switch to
81-
> the correct version when you `cd` into the repository. Additionally, this
82-
> `.node-version` file is used by GitHub Actions in any `actions/setup-node`
83-
> actions.
84-
8566
## Custom Matchers
8667

8768
You can define custom matchers to parse your reports and create annotations.

__tests__/main.test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ at Tests.Registration.main(Registration.java:202)`,
355355
it('should handle reports with no items', async () => {
356356
testInputs.reports = ['junit|fixtures/empty-report.xml'];
357357
await main.run();
358+
expect(warningMock).toHaveBeenCalledWith(
359+
"No items found in fixtures/empty-report.xml using XPath '//testcase'",
360+
);
358361
expect(errorMock).not.toHaveBeenCalled();
359362
expect(setOutputMock).toHaveBeenCalledWith('errors', 0);
360363
expect(setOutputMock).toHaveBeenCalledWith('warnings', 0);
@@ -432,4 +435,53 @@ at Tests.Registration.main(Registration.java:202)`,
432435
`Failed to create PR comment: ${apiError}`,
433436
);
434437
});
438+
439+
it('should throw error for invalid report format', async () => {
440+
testInputs.reports = ['invalid-format-no-pipe'];
441+
await expect(main.run()).rejects.toThrow(
442+
"Invalid report format: 'invalid-format-no-pipe'. Expected 'matcher|patterns'.",
443+
);
444+
});
445+
446+
it('should handle missing config file', async () => {
447+
testInputs.configPath = '/nonexistent/config.yml';
448+
await main.run();
449+
expect(infoMock).toHaveBeenCalledWith(
450+
'No config file found at /nonexistent/config.yml.',
451+
);
452+
});
453+
454+
it('should throw error for invalid custom-matchers JSON', async () => {
455+
testInputs['custom-matchers'] = '{invalid json';
456+
await expect(main.run()).rejects.toThrow();
457+
expect(errorMock).toHaveBeenCalledWith(
458+
expect.stringContaining('Failed to parse custom-matchers input'),
459+
);
460+
});
461+
462+
it('should throw error for invalid YAML config', async () => {
463+
testInputs.configPath = 'fixtures/invalid-config.yml';
464+
await expect(main.run()).rejects.toThrow();
465+
expect(errorMock).toHaveBeenCalledWith(
466+
expect.stringContaining(
467+
'Failed to parse YAML config at fixtures/invalid-config.yml',
468+
),
469+
);
470+
});
471+
472+
it('should skip items with empty messages', async () => {
473+
testInputs['custom-matchers'] = `{
474+
"custom-matcher": {
475+
"format": "xml",
476+
"item": "//testCase",
477+
"message": "@empty",
478+
"file": "@file",
479+
"startLine": "@line"
480+
}
481+
}`;
482+
testInputs.reports = ['custom-matcher|fixtures/custom-format.xml'];
483+
await main.run();
484+
// Should not create any annotations since message is empty
485+
expect(setOutputMock).toHaveBeenCalledWith('total', 0);
486+
});
435487
});

dist/index.js

Lines changed: 113 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fixtures/invalid-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
reports:
2+
- junit|fixtures/junit-generic.xml
3+
maxAnnotations: 10
4+
invalid: yaml: content:
5+
- with
6+
bad: indentation
7+
[unclosed bracket

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "report-annotate",
33
"description": "Annotate PR from report e.g. junit",
4-
"version": "3.0.0",
4+
"version": "3.0.1",
55
"author": "",
66
"type": "module",
77
"private": true,

0 commit comments

Comments
 (0)