1+ // Auto-detection patterns for common report files
2+ const AUTO_PATTERNS = {
3+ test : [
4+ "**/junit*.xml" ,
5+ "**/test-results/**/*.xml" ,
6+ "**/test-reports/**/*.xml" ,
7+ "**/*test*.xml" ,
8+ "**/*.tap" ,
9+ ] ,
10+ coverage : [
11+ "**/coverage/lcov.info" ,
12+ "**/coverage/cobertura-coverage.xml" ,
13+ "**/coverage.xml" ,
14+ "**/lcov.info" ,
15+ "**/cobertura.xml" ,
16+ ] ,
17+ lint : [
18+ "**/eslint-report.json" ,
19+ "**/eslint.json" ,
20+ "**/checkstyle-result.xml" ,
21+ "**/checkstyle.xml" ,
22+ ] ,
23+ } ;
24+
125// Dynamically import ES modules
226async function runAction ( { core, glob : globModule , inputs } ) {
327 try {
@@ -9,12 +33,33 @@ async function runAction({ core, glob: globModule, inputs }) {
933 core . info ( `Report Name: ${ inputs . reportName } ` ) ;
1034 core . info ( `Output Format: ${ inputs . outputFormat } ` ) ;
1135
12- // Find report files using glob
13- const patternList = inputs . reportPaths
36+ // Handle auto-detection
37+ let patternList = inputs . reportPaths
1438 . split ( / [ , \n ] / )
1539 . map ( ( p ) => p . trim ( ) )
1640 . filter ( ( p ) => p . length > 0 ) ;
1741
42+ // Check for auto mode
43+ const autoMode = patternList . find ( ( p ) => p . startsWith ( "auto:" ) ) ;
44+ if ( autoMode ) {
45+ const mode = autoMode . split ( ":" ) [ 1 ] ;
46+ core . info ( `Auto-detection mode: ${ mode } ` ) ;
47+
48+ patternList = [ ] ;
49+ if ( mode === "all" || mode === "test" ) {
50+ patternList . push ( ...AUTO_PATTERNS . test ) ;
51+ }
52+ if ( mode === "all" || mode === "coverage" ) {
53+ patternList . push ( ...AUTO_PATTERNS . coverage ) ;
54+ }
55+ if ( mode === "all" || mode === "lint" ) {
56+ patternList . push ( ...AUTO_PATTERNS . lint ) ;
57+ }
58+
59+ core . info ( `Using patterns: ${ patternList . join ( ", " ) } ` ) ;
60+ }
61+
62+ // Find report files using glob
1863 const files = [ ] ;
1964 for ( const pattern of patternList ) {
2065 const globber = await globModule . create ( pattern , {
@@ -40,6 +85,14 @@ async function runAction({ core, glob: globModule, inputs }) {
4085 ( msg ) => core . error ( msg ) ,
4186 ) ;
4287
88+ // Generate GitHub annotations if requested
89+ if (
90+ inputs . outputFormat === "annotations" ||
91+ inputs . outputFormat === "both"
92+ ) {
93+ generateAnnotations ( core , aggregatedData ) ;
94+ }
95+
4396 // Generate outputs using core
4497 const { markdown, summary } = parserCore . generateOutput (
4598 aggregatedData ,
@@ -86,4 +139,44 @@ async function runAction({ core, glob: globModule, inputs }) {
86139 }
87140}
88141
142+ /**
143+ * Generate GitHub annotations for failed tests and lint issues
144+ */
145+ function generateAnnotations ( core , reportData ) {
146+ // Annotate failed tests
147+ const failedTests = reportData . getFailedTests ( ) ;
148+ for ( const test of failedTests . slice ( 0 , 10 ) ) {
149+ // Limit to 10 annotations
150+ const properties = {
151+ title : `Test Failed: ${ test . name } ` ,
152+ } ;
153+
154+ if ( test . file ) {
155+ properties . file = test . file ;
156+ }
157+
158+ core . error ( test . message || "Test failed" , properties ) ;
159+ }
160+
161+ // Annotate lint errors and warnings
162+ annotateLintIssues ( core , reportData . getErrors ( ) , core . error , 10 ) ;
163+ annotateLintIssues ( core , reportData . getWarnings ( ) , core . warning , 10 ) ;
164+ }
165+
166+ /**
167+ * Helper to annotate lint issues
168+ */
169+ function annotateLintIssues ( core , issues , annotationFn , limit ) {
170+ for ( const issue of issues . slice ( 0 , limit ) ) {
171+ const properties = {
172+ title : `${ issue . rule } : ${ issue . message } ` ,
173+ file : issue . file ,
174+ startLine : issue . line ,
175+ startColumn : issue . column ,
176+ } ;
177+
178+ annotationFn . call ( core , issue . message , properties ) ;
179+ }
180+ }
181+
89182module . exports = { runAction } ;
0 commit comments