@@ -88,74 +88,6 @@ function commenterScript(): string {
8888 return script ;
8989}
9090
91- function scopeScript ( ) : string {
92- const workflow = parse ( readFileSync ( PRODUCER_WORKFLOW_PATH , "utf8" ) ) as ProducerWorkflow ;
93- const step = workflow . jobs ?. scope ?. steps ?. find ( ( candidate ) => candidate . id === "scope" ) ;
94- const script = step ?. with ?. script ;
95- if ( ! script ) {
96- throw new Error ( "missing iOS Periphery scope script" ) ;
97- }
98- return script ;
99- }
100-
101- async function runScope ( options : {
102- diffExitCode ?: number ;
103- draft ?: boolean ;
104- eventName ?: string ;
105- files ?: Array < string | { filename : string ; previous_filename ?: string } > ;
106- } ) : Promise < string | undefined > {
107- const outputs = new Map < string , string > ( ) ;
108- const core = {
109- setOutput ( name : string , value : string ) {
110- outputs . set ( name , value ) ;
111- } ,
112- } ;
113- const context = {
114- eventName : options . eventName ?? "pull_request" ,
115- payload : {
116- pull_request : {
117- base : { sha : "base-sha" } ,
118- draft : options . draft ?? false ,
119- number : 123 ,
120- } ,
121- } ,
122- repo : {
123- owner : "openclaw" ,
124- repo : "openclaw" ,
125- } ,
126- } ;
127- const exec = {
128- async getExecOutput ( command : string , args : string [ ] ) {
129- if ( command !== "git" || args . slice ( 0 , 5 ) . join ( " " ) !== "diff --quiet base-sha HEAD --" ) {
130- throw new Error ( `unexpected scope command: ${ command } ${ args . join ( " " ) } ` ) ;
131- }
132- if ( options . diffExitCode !== undefined ) {
133- return { exitCode : options . diffExitCode } ;
134- }
135- const pathspecs = args . slice ( 5 ) ;
136- const filenames = ( options . files ?? [ ] ) . flatMap ( ( file ) =>
137- typeof file === "string"
138- ? [ file ]
139- : [ file . filename , file . previous_filename ] . filter ( ( name ) : name is string => Boolean ( name ) ) ,
140- ) ;
141- const changed = filenames . some ( ( filename ) =>
142- pathspecs . some ( ( pathspec ) =>
143- pathspec . endsWith ( "/" ) ? filename . startsWith ( pathspec ) : filename === pathspec ,
144- ) ,
145- ) ;
146- return { exitCode : changed ? 1 : 0 } ;
147- } ,
148- } ;
149- const execute = compileFunction ( `return (async () => {\n${ scopeScript ( ) } \n})();` , [
150- "context" ,
151- "core" ,
152- "exec" ,
153- ] ) as ( context : unknown , core : unknown , exec : unknown ) => Promise < void > ;
154-
155- await execute ( context , core , exec ) ;
156- return outputs . get ( "should-scan" ) ;
157- }
158-
15991async function runCommenter (
16092 artifact : Artifact ,
16193 archiveData : Buffer ,
@@ -476,69 +408,6 @@ describe("iOS Periphery comment workflow", () => {
476408 expect ( workflow . jobs ?. scan ?. [ "runs-on" ] ) . toContain ( "github.run_attempt > 1" ) ;
477409 }
478410 } ) ;
479-
480- it ( "runs scope detection for PR transitions that can clear stale findings" , ( ) => {
481- const workflow = parse ( readFileSync ( PRODUCER_WORKFLOW_PATH , "utf8" ) ) as ProducerWorkflow ;
482-
483- expect ( workflow . on ?. pull_request ?. types ) . toContain ( "converted_to_draft" ) ;
484- expect ( workflow . on ?. pull_request ?. paths ) . toBeUndefined ( ) ;
485- expect ( ( ) =>
486- compileFunction ( `return (async () => {\n${ scopeScript ( ) } \n})();` , [
487- "context" ,
488- "core" ,
489- "exec" ,
490- ] ) ,
491- ) . not . toThrow ( ) ;
492- expect ( scopeScript ( ) ) . toContain ( "exec.getExecOutput" ) ;
493- expect ( scopeScript ( ) ) . not . toContain ( "pulls.listFiles" ) ;
494- } ) ;
495-
496- it . each ( [
497- {
498- expected : "false" ,
499- files : [ "apps/ios/Sources/Test.swift" ] ,
500- name : "draft pull request" ,
501- options : { draft : true } ,
502- } ,
503- {
504- expected : "true" ,
505- files : [ "apps/ios/Sources/Test.swift" ] ,
506- name : "iOS change" ,
507- options : { } ,
508- } ,
509- {
510- expected : "false" ,
511- files : [ "docs/index.md" ] ,
512- name : "out-of-scope change" ,
513- options : { } ,
514- } ,
515- {
516- expected : "true" ,
517- files : [
518- {
519- filename : "docs/Moved.swift" ,
520- previous_filename : "apps/ios/Sources/Moved.swift" ,
521- } ,
522- ] ,
523- name : "iOS file renamed out of scope" ,
524- options : { } ,
525- } ,
526- {
527- expected : "true" ,
528- files : [ ] ,
529- name : "manual dispatch" ,
530- options : { eventName : "workflow_dispatch" } ,
531- } ,
532- ] ) ( "sets scope output for $name" , async ( { expected, files, options } ) => {
533- await expect ( runScope ( { ...options , files } ) ) . resolves . toBe ( expected ) ;
534- } ) ;
535-
536- it ( "fails closed when git cannot compare the base and head" , async ( ) => {
537- await expect ( runScope ( { diffExitCode : 128 } ) ) . rejects . toThrow (
538- "git diff failed with exit code 128" ,
539- ) ;
540- } ) ;
541-
542411 it ( "accepts a valid small Periphery artifact" , async ( ) => {
543412 const archive = makeZip ( {
544413 "periphery.json" : "[]\n" ,
0 commit comments