@@ -7,6 +7,28 @@ import { fileURLToPath } from "node:url";
77
88const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
99
10+ // Check if running in GitHub Actions
11+ const isGitHubActions = process . env . GITHUB_ACTIONS === "true" ;
12+
13+ // GitHub Actions annotation helpers
14+ function ghaError ( message : string , file ?: string , line ?: number ) {
15+ if ( ! isGitHubActions ) return ;
16+ const params = [ file && `file=${ file } ` , line && `line=${ line } ` ]
17+ . filter ( Boolean )
18+ . join ( "," ) ;
19+ console . log ( `::error ${ params } ::${ message . replace ( / \n / g, "%0A" ) } ` ) ;
20+ }
21+
22+ function ghaGroup ( name : string ) {
23+ if ( ! isGitHubActions ) return ;
24+ console . log ( `::group::${ name } ` ) ;
25+ }
26+
27+ function ghaEndGroup ( ) {
28+ if ( ! isGitHubActions ) return ;
29+ console . log ( `::endgroup::` ) ;
30+ }
31+
1032type TestResult = {
1133 status : "pass" | "fail" ;
1234 message ?: string ;
@@ -166,6 +188,7 @@ async function main() {
166188 let needsReload = true ;
167189
168190 for ( const test of tests ) {
191+ ghaGroup ( `Test: ${ test . name } ` ) ;
169192 process . stdout . write ( ` ${ test . name } ... ` ) ;
170193
171194 // Reload page if needed (first run or after failure)
@@ -193,6 +216,7 @@ async function main() {
193216 console . error (
194217 " Check that scramjet is built and all dependencies are available.\n"
195218 ) ;
219+ ghaError ( `Harness failed to initialize: ${ statusText } ` ) ;
196220 await browser . close ( ) ;
197221 process . exit ( 1 ) ;
198222 }
@@ -212,6 +236,9 @@ async function main() {
212236 if ( result . message ) {
213237 console . log ( ` ${ result . message } ` ) ;
214238 }
239+ ghaError (
240+ `Test "${ test . name } " failed: ${ result . message || "Unknown error" } `
241+ ) ;
215242 needsReload = true ; // Reload after failure
216243 }
217244 } catch ( error ) {
@@ -228,8 +255,12 @@ async function main() {
228255 console . log (
229256 ` ${ error instanceof Error ? error . message : String ( error ) } `
230257 ) ;
258+ ghaError (
259+ `Test "${ test . name } " error: ${ error instanceof Error ? error . message : String ( error ) } `
260+ ) ;
231261 needsReload = true ; // Reload after error
232262 }
263+ ghaEndGroup ( ) ;
233264 }
234265
235266 testPage . cleanup ( ) ;
0 commit comments