28
28
import java .util .Optional ;
29
29
import java .util .Properties ;
30
30
import java .util .concurrent .ExecutorService ;
31
+ import java .util .function .Predicate ;
31
32
32
33
import org .apache .commons .io .FileUtils ;
34
+
33
35
import org .springframework .data .release .TimedCommand ;
34
36
import org .springframework .data .release .git .Branch ;
35
37
import org .springframework .data .release .git .GitOperations ;
39
41
import org .springframework .data .release .model .Project ;
40
42
import org .springframework .data .release .model .Projects ;
41
43
import org .springframework .data .release .model .SupportedProject ;
42
- import org .springframework .data .release .model .Train ;
43
44
import org .springframework .data .release .model .TrainIteration ;
44
45
import org .springframework .data .release .utils .ExecutionUtils ;
45
46
import org .springframework .data .release .utils .Logger ;
47
+ import org .springframework .data .util .Predicates ;
46
48
import org .springframework .data .util .Streamable ;
47
49
import org .springframework .stereotype .Component ;
48
50
@@ -70,11 +72,19 @@ public class InfrastructureOperations extends TimedCommand {
70
72
* @param iteration
71
73
*/
72
74
void distributeCiProperties (TrainIteration iteration ) {
75
+ distributeFile (iteration , "ci/pipeline.properties" , "CI Properties" , Predicates .isTrue ());
76
+ }
73
77
74
- File master = workspace .getFile (CI_PROPERTIES , iteration .getSupportedProject (Projects .BUILD ));
78
+ void distributeGhWorkflow (TrainIteration iteration ) {
79
+ distributeFile (iteration , ".github/workflows/project.yml" , "GitHub Actions" , project -> project != Projects .BOM );
80
+ }
81
+
82
+ private void distributeFile (TrainIteration iteration , String file , String description ,
83
+ Predicate <Project > projectFilter ) {
84
+ File master = workspace .getFile (file , iteration .getSupportedProject (Projects .BUILD ));
75
85
76
86
if (!master .exists ()) {
77
- throw new IllegalStateException (String .format ("CI Properties file %s does not exist" , master ));
87
+ throw new IllegalStateException (String .format ("%s file %s does not exist" , description , master ));
78
88
}
79
89
80
90
ExecutionUtils .run (executor , iteration , module -> {
@@ -86,29 +96,33 @@ void distributeCiProperties(TrainIteration iteration) {
86
96
git .checkout (project , branch );
87
97
});
88
98
89
- verifyExistingPropertyFiles (iteration .getTrain (), master );
99
+ Streamable <ModuleIteration > projects = Streamable .of (iteration .getModulesExcept (Projects .BUILD ))
100
+ .filter (it -> projectFilter .test (it .getProject ())).filter (it -> it .getProject ().getMaintainer ().isCore ());
101
+
102
+ verifyExistingFiles (projects , file , description );
90
103
91
- ExecutionUtils .run (executor , Streamable . of ( iteration . getModulesExcept ( Projects . BUILD )) , module -> {
104
+ ExecutionUtils .run (executor , projects , module -> {
92
105
93
- File target = workspace .getFile (CI_PROPERTIES , module .getSupportedProject ());
106
+ File target = workspace .getFile (file , module .getSupportedProject ());
94
107
target .delete ();
95
108
96
109
FileUtils .copyFile (master , target );
97
110
98
- git .add (module .getSupportedProject (), CI_PROPERTIES );
99
- git .commit (module , "Update CI properties." , Optional .empty (), false );
111
+ git .add (module .getSupportedProject (), file );
112
+ git .commit (module , String . format ( "Update %s." , description ) , Optional .empty (), false );
100
113
git .push (module );
101
114
});
102
115
}
103
116
104
- private void verifyExistingPropertyFiles ( Train train , File master ) {
117
+ private void verifyExistingFiles ( Streamable < ModuleIteration > train , String file , String description ) {
105
118
106
- for (SupportedProject project : train ) {
119
+ for (ModuleIteration moduleIteration : train ) {
107
120
108
- File target = workspace .getFile (CI_PROPERTIES , project );
121
+ File target = workspace .getFile (file , moduleIteration . getSupportedProject () );
109
122
110
123
if (!target .exists ()) {
111
- throw new IllegalStateException (String .format ("CI Properties file %s does not exist" , master ));
124
+ throw new IllegalStateException (
125
+ String .format ("%s file %s does not exist in %s" , description , file , moduleIteration .getSupportedProject ()));
112
126
}
113
127
}
114
128
}
0 commit comments