@@ -134,6 +134,12 @@ fn count(haystack: []const u8, needle: []const u8) usize {
134134 return total ;
135135}
136136
137+ fn countSources (sources : []const []const u8 , needle : []const u8 ) usize {
138+ var total : usize = 0 ;
139+ for (sources ) | source | total += count (source , needle );
140+ return total ;
141+ }
142+
137143fn read (gpa : std.mem.Allocator , io : std.Io , path : []const u8 ) ! []u8 {
138144 return std .Io .Dir .cwd ().readFileAlloc (io , path , gpa , .limited (max_source_bytes ));
139145}
@@ -666,8 +672,19 @@ fn auditGitIndex(gpa: std.mem.Allocator, io: std.Io, inventory: Inventory) !void
666672}
667673
668674fn auditCi (gpa : std.mem.Allocator , io : std.Io , inventory : Inventory ) ! void {
669- const source = try read (gpa , io , ".github/workflows/ci.yml" );
670- defer gpa .free (source );
675+ const workflow_paths = [_ ][]const u8 {
676+ ".github/workflows/ci.yml" ,
677+ ".github/workflows/performance.yml" ,
678+ ".github/workflows/release.yml" ,
679+ };
680+ var sources : [workflow_paths .len ][]u8 = undefined ;
681+ var loaded : usize = 0 ;
682+ defer for (sources [0.. loaded ]) | source | gpa .free (source );
683+ for (& sources , workflow_paths ) | * source , path | {
684+ source .* = try read (gpa , io , path );
685+ loaded += 1 ;
686+ }
687+
671688 var sibling_occurrences : usize = 0 ;
672689 for (inventory .boundaries .owned_sibling_checkouts ) | item | {
673690 const fragment = try std .fmt .allocPrint (
@@ -676,52 +693,55 @@ fn auditCi(gpa: std.mem.Allocator, io: std.Io, inventory: Inventory) !void {
676693 .{ item .repository , item .path , item .revision },
677694 );
678695 defer gpa .free (fragment );
679- const actual = count ( source , fragment );
696+ const actual = countSources ( & sources , fragment );
680697 if (actual != item .occurrences )
681698 return fail ("owned sibling {s}@{s} occurs {d} times, expected {d}" , .{ item .repository , item .revision , actual , item .occurrences });
682699 sibling_occurrences += item .occurrences ;
683700 }
684- if (count ( source , "repository: " ) != sibling_occurrences )
685- return fail ("CI contains an unclassified owned sibling checkout" , .{});
701+ if (countSources ( & sources , "repository: " ) != sibling_occurrences )
702+ return fail ("workflow set contains an unclassified owned sibling checkout" , .{});
686703
687704 var action_occurrences : usize = 0 ;
688705 for (inventory .boundaries .ci_actions ) | item | {
689706 const fragment = try std .fmt .allocPrint (gpa , "uses: {s}" , .{item .name });
690707 defer gpa .free (fragment );
691- const actual = count ( source , fragment );
692- if (actual != item .count ) return fail ("CI action '{s}' occurs {d} times, expected {d}" , .{ item .name , actual , item .count });
708+ const actual = countSources ( & sources , fragment );
709+ if (actual != item .count ) return fail ("workflow action '{s}' occurs {d} times, expected {d}" , .{ item .name , actual , item .count });
693710 action_occurrences += item .count ;
694711 }
695- if (count ( source , "uses: " ) != action_occurrences ) return fail ("CI contains an unclassified action" , .{});
712+ if (countSources ( & sources , "uses: " ) != action_occurrences ) return fail ("workflow set contains an unclassified action" , .{});
696713
697714 var download_occurrences : usize = 0 ;
698715 for (inventory .boundaries .pinned_downloads ) | item | {
699- const urls = count ( source , item .url );
700- const hashes = count ( source , item .sha256 );
716+ const urls = countSources ( & sources , item .url );
717+ const hashes = countSources ( & sources , item .sha256 );
701718 if (urls != item .occurrences or hashes != item .occurrences )
702719 return fail ("download pin '{s}' occurs URL/hash {d}/{d}, expected {d}/{d}" , .{ item .url , urls , hashes , item .occurrences , item .occurrences });
703720 download_occurrences += item .occurrences ;
704721 }
705- if (count ( source , "releases/download/" ) != download_occurrences )
706- return fail ("CI contains an unclassified release download" , .{});
722+ if (countSources ( & sources , "releases/download/" ) != download_occurrences )
723+ return fail ("workflow set contains an unclassified release download" , .{});
707724
708725 for (inventory .boundaries .pinned_ci_corpora ) | item | {
709726 const remote = try std .fmt .allocPrint (gpa , "remote add origin {s}" , .{item .url });
710727 defer gpa .free (remote );
711- var rest = source ;
712728 var matched = false ;
713- while (std .mem .indexOf (u8 , rest , remote )) | at | {
714- const end = @min (rest .len , at + remote .len + 500 );
715- if (std .mem .indexOf (u8 , rest [at .. end ], item .revision ) != null ) {
716- matched = true ;
717- break ;
729+ for (sources ) | source | {
730+ var rest = source ;
731+ while (std .mem .indexOf (u8 , rest , remote )) | at | {
732+ const end = @min (rest .len , at + remote .len + 500 );
733+ if (std .mem .indexOf (u8 , rest [at .. end ], item .revision ) != null ) {
734+ matched = true ;
735+ break ;
736+ }
737+ rest = rest [at + remote .len .. ];
718738 }
719- rest = rest [ at + remote . len .. ] ;
739+ if ( matched ) break ;
720740 }
721741 if (! matched ) return fail ("CI corpus {s}@{s} is not pinned beside its remote" , .{ item .url , item .revision });
722742 }
723- if (count ( source , "remote add origin https://github.com/WebAssembly/" ) != inventory .boundaries .pinned_ci_corpora .len )
724- return fail ("CI contains an unclassified WebAssembly corpus checkout" , .{});
743+ if (countSources ( & sources , "remote add origin https://github.com/WebAssembly/" ) != inventory .boundaries .pinned_ci_corpora .len )
744+ return fail ("workflow set contains an unclassified WebAssembly corpus checkout" , .{});
725745}
726746
727747fn auditProductionSources (gpa : std.mem.Allocator , io : std.Io , inventory : Inventory ) ! void {
0 commit comments