@@ -40,14 +40,14 @@ void hostedWorkflowsUsePinnedJdksAndExerciseAColdForgeBootstrap() throws Excepti
4040
4141 for (String workflow : new String [] { ci , codeql }) {
4242 assertFalse (workflow .contains ("distribution: microsoft" ));
43+ assertTrue (workflow .contains ("java-version: '25.0.3+9.0.LTS'" ));
4344 assertTrue (workflow .contains ("java-version: '8.0.502+7'" ));
4445 assertTrue (workflow .contains ("java-version: '17.0.1+12'" ));
45- assertTrue (workflow .lastIndexOf ("java-version: '17.0.1+12'" )
46- > workflow .lastIndexOf ("java-version: '8.0.502+7'" ));
47- assertTrue (workflow .contains ("$JAVA_HOME,$JAVA_HOME_8_X64" ));
4846 assertTrue (workflow .contains ("-Dorg.gradle.java.installations.auto-detect=false" ));
4947 assertTrue (workflow .contains ("-Dorg.gradle.java.installations.auto-download=false" ));
5048 }
49+ assertPinnedToolchains (ci , 2 , 3 );
50+ assertPinnedToolchains (codeql , 1 , 1 );
5151
5252 assertTrue (ci .contains ("name: Cold Forge bootstrap" ));
5353 assertTrue (ci .contains ("GRADLE_USER_HOME: ${{ runner.temp }}/orespawn-cold-gradle" ));
@@ -56,11 +56,43 @@ void hostedWorkflowsUsePinnedJdksAndExerciseAColdForgeBootstrap() throws Excepti
5656 assertTrue (ci .contains ("classes verifyLegacyFixtures" ));
5757 assertTrue (ci .contains ("--rerun-tasks --offline --no-daemon --no-build-cache" ));
5858 assertFalse (ci .contains ("Mavenizer compatibility" ));
59- assertFalse (ci .contains ("25.0.3" ));
6059 }
6160
6261 private static String readWorkflow (String name ) throws Exception {
6362 return new String (Files .readAllBytes (Paths .get (".github" , "workflows" , name )),
6463 StandardCharsets .UTF_8 );
6564 }
65+
66+ private static void assertPinnedToolchains (String workflow , int expectedJobs , int expectedPathUses ) {
67+ String java25 = "java-version: '25.0.3+9.0.LTS'" ;
68+ String java8 = "java-version: '8.0.502+7'" ;
69+ String java17 = "java-version: '17.0.1+12'" ;
70+ String paths = "$JAVA_HOME,$JAVA_HOME_8_X64,$JAVA_HOME_25_X64" ;
71+
72+ assertEquals (expectedJobs , occurrences (workflow , java25 ));
73+ assertEquals (expectedJobs , occurrences (workflow , java8 ));
74+ assertEquals (expectedJobs , occurrences (workflow , java17 ));
75+ assertEquals (expectedPathUses , occurrences (workflow , paths ));
76+
77+ int cursor = 0 ;
78+ for (int job = 0 ; job < expectedJobs ; job ++) {
79+ int java25Index = workflow .indexOf (java25 , cursor );
80+ int java8Index = workflow .indexOf (java8 , java25Index + java25 .length ());
81+ int java17Index = workflow .indexOf (java17 , java8Index + java8 .length ());
82+ assertTrue (java25Index >= cursor );
83+ assertTrue (java8Index > java25Index );
84+ assertTrue (java17Index > java8Index );
85+ cursor = java17Index + java17 .length ();
86+ }
87+ }
88+
89+ private static int occurrences (String value , String needle ) {
90+ int count = 0 ;
91+ int offset = 0 ;
92+ while ((offset = value .indexOf (needle , offset )) >= 0 ) {
93+ count ++;
94+ offset += needle .length ();
95+ }
96+ return count ;
97+ }
6698}
0 commit comments