4
4
5
5
import 'dart:async' ;
6
6
import 'dart:convert' ;
7
+ import 'dart:io' ;
7
8
8
9
import 'package:mono_repo/mono_repo.dart' ;
9
10
import 'package:mono_repo/src/ci_test_script.dart' ;
@@ -284,12 +285,12 @@ package:pkg_b''',
284
285
285
286
group ('--validate' , () {
286
287
setUp (() async {
287
- await d. dir ( 'sub_pkg' , [
288
- d. file (monoPkgFileName, testConfig2),
289
- d. file ( 'pubspec.yaml' , '''
290
- name: pkg_name
291
- ''')
292
- ]). create ( );
288
+ await populateConfig (
289
+ r'''
290
+ github:
291
+ dependabot: {}
292
+ ''' ,
293
+ );
293
294
});
294
295
295
296
test ('throws if there is no generated config' , () async {
@@ -315,15 +316,32 @@ name: pkg_name
315
316
316
317
test ("doesn't throw if the previous config is up to date" , () async {
317
318
testGenerateConfig (
318
- printMatcher: _subPkgStandardOutput,
319
+ printMatcher: _subPkgStandardOutput (withDependabot : true ) ,
319
320
);
320
321
321
322
// Just check that this doesn't throw.
322
323
testGenerateConfig (
323
- printMatcher: '''
324
- package:sub_pkg
325
- Wrote `${p .join (d .sandbox , defaultGitHubWorkflowFilePath )}`.
326
- Wrote `${p .join (d .sandbox , ciScriptPath )}`.''' ,
324
+ printMatcher: 'package:sub_pkg' ,
325
+ validateOnly: true ,
326
+ );
327
+ });
328
+
329
+ test ("doesn't throw if the previous config has different action versions" ,
330
+ () async {
331
+ testGenerateConfig (
332
+ printMatcher: _subPkgStandardOutput (withDependabot: true ),
333
+ );
334
+ final generatedFile = File (d.path (defaultGitHubWorkflowFilePath));
335
+ final contents = generatedFile.readAsStringSync ();
336
+ generatedFile.writeAsStringSync (
337
+ contents.replaceAll (
338
+ 'dart-lang/setup-dart@' ,
339
+ 'dart-lang/setup-dart@Foo' ,
340
+ ),
341
+ );
342
+ testGenerateConfig (
343
+ printMatcher: 'package:sub_pkg' ,
344
+ validateOnly: true ,
327
345
);
328
346
});
329
347
});
@@ -337,7 +355,7 @@ name: pkg_name
337
355
]).create ();
338
356
339
357
testGenerateConfig (
340
- printMatcher: _subPkgStandardOutput,
358
+ printMatcher: _subPkgStandardOutput () ,
341
359
);
342
360
await d.file (ciScriptPath, ciShellOutput).validate ();
343
361
});
@@ -356,7 +374,7 @@ environment:
356
374
printMatcher: '''
357
375
package:sub_pkg
358
376
There are jobs defined that are not compatible with the package SDK constraint (>=2.1.0 <3.0.0): `1.23.0`.
359
- $_writeScriptOutput ''' ,
377
+ ${ _writeScriptOutput ( false )} ''' ,
360
378
);
361
379
362
380
await d.file (ciScriptPath, ciShellOutput).validate ();
@@ -393,7 +411,7 @@ name: pkg_a
393
411
printMatcher: '''
394
412
${Iterable .generate (count , (i ) => 'package:${pkgName (i )}' ).join ('\n ' )}
395
413
package:sub_pkg
396
- $_writeScriptOutput ''' ,
414
+ ${ _writeScriptOutput ( false )} ''' ,
397
415
);
398
416
399
417
validateSandbox (
@@ -446,7 +464,7 @@ name: pkg_b
446
464
printMatcher: '''
447
465
package:pkg_a
448
466
package:pkg_b
449
- $_writeScriptOutput ''' ,
467
+ ${ _writeScriptOutput ( false )} ''' ,
450
468
);
451
469
452
470
validateSandbox (
@@ -517,7 +535,7 @@ name: pkg_b
517
535
printMatcher: '''
518
536
package:pkg_a
519
537
package:pkg_b
520
- $_writeScriptOutput ''' ,
538
+ ${ _writeScriptOutput ( false )} ''' ,
521
539
);
522
540
523
541
validateSandbox (
@@ -613,7 +631,7 @@ name: pkg_a
613
631
package:pkg_a
614
632
`dart` values (stable) are not used and can be removed.
615
633
`os` values (unneeded) are not used and can be removed.
616
- $_writeScriptOutput ''' ,
634
+ ${ _writeScriptOutput ( false )} ''' ,
617
635
);
618
636
619
637
validateSandbox (
@@ -644,7 +662,7 @@ name: pkg_a
644
662
testGenerateConfig (
645
663
printMatcher: '''
646
664
package:pkg_a
647
- $_writeScriptOutput ''' ,
665
+ ${ _writeScriptOutput ( false )} ''' ,
648
666
);
649
667
650
668
validateSandbox (
@@ -782,7 +800,7 @@ $lines
782
800
await d.nothing (ciScriptPath).validate ();
783
801
784
802
testGenerateConfig (
785
- printMatcher: _subPkgStandardOutput,
803
+ printMatcher: _subPkgStandardOutput () ,
786
804
);
787
805
788
806
if (expectedGithubContent != null ) {
@@ -920,7 +938,7 @@ dependencies:
920
938
package:pkg_a
921
939
package:pkg_b
922
940
package:pkg_c
923
- $_writeScriptOutput ''' ,
941
+ ${ _writeScriptOutput ( false )} ''' ,
924
942
);
925
943
926
944
validateSandbox (
@@ -961,7 +979,7 @@ line 1, column 13 of mono_repo.yaml: Unsupported value for "pub_action". Value m
961
979
await populateConfig (monoConfigContent);
962
980
963
981
testGenerateConfig (
964
- printMatcher: _subPkgStandardOutput,
982
+ printMatcher: _subPkgStandardOutput () ,
965
983
);
966
984
967
985
// TODO: validate GitHub case
@@ -974,7 +992,7 @@ line 1, column 13 of mono_repo.yaml: Unsupported value for "pub_action". Value m
974
992
await populateConfig (monoConfigContent);
975
993
976
994
testGenerateConfig (
977
- printMatcher: _subPkgStandardOutput,
995
+ printMatcher: _subPkgStandardOutput () ,
978
996
);
979
997
980
998
// TODO: validate GitHub case
@@ -1009,7 +1027,7 @@ line 1, column 14 of mono_repo.yaml: Unsupported value for "pretty_ansi". Value
1009
1027
await populateConfig (toYaml ({'pretty_ansi' : false }));
1010
1028
1011
1029
testGenerateConfig (
1012
- printMatcher: _subPkgStandardOutput,
1030
+ printMatcher: _subPkgStandardOutput () ,
1013
1031
);
1014
1032
1015
1033
await d
@@ -1126,7 +1144,7 @@ line 1, column 16 of mono_repo.yaml: Unsupported value for "self_validate". Valu
1126
1144
await populateConfig (monoConfigContent);
1127
1145
1128
1146
testGenerateConfig (
1129
- printMatcher: _subPkgStandardOutput,
1147
+ printMatcher: _subPkgStandardOutput () ,
1130
1148
);
1131
1149
1132
1150
validateSandbox (
@@ -1143,7 +1161,7 @@ line 1, column 16 of mono_repo.yaml: Unsupported value for "self_validate". Valu
1143
1161
await populateConfig (monoConfigContent);
1144
1162
1145
1163
testGenerateConfig (
1146
- printMatcher: _subPkgStandardOutput,
1164
+ printMatcher: _subPkgStandardOutput () ,
1147
1165
);
1148
1166
1149
1167
validateSandbox (
@@ -1210,7 +1228,7 @@ environment:
1210
1228
testGenerateConfig (
1211
1229
printMatcher: '''
1212
1230
package:pkg_a
1213
- $_writeScriptOutput ''' ,
1231
+ ${ _writeScriptOutput ( false )} ''' ,
1214
1232
);
1215
1233
1216
1234
validateSandbox (
@@ -1388,13 +1406,16 @@ github:
1388
1406
});
1389
1407
}
1390
1408
1391
- String get _subPkgStandardOutput => '''
1409
+ String _subPkgStandardOutput ({ bool withDependabot = false }) => '''
1392
1410
package:sub_pkg
1393
- $_writeScriptOutput ''' ;
1394
-
1395
- String get _writeScriptOutput => '''
1396
- Wrote `${p .join (d .sandbox , defaultGitHubWorkflowFilePath )}`.
1397
- $ciScriptPathMessage ''' ;
1411
+ ${_writeScriptOutput (withDependabot )}''' ;
1412
+
1413
+ String _writeScriptOutput (bool withDependabot) => [
1414
+ 'Wrote `${p .join (d .sandbox , defaultGitHubWorkflowFilePath )}`.' ,
1415
+ if (withDependabot)
1416
+ 'Wrote `${p .join (d .sandbox , '.github/dependabot.yml' )}`.' ,
1417
+ ciScriptPathMessage
1418
+ ].join ('\n ' );
1398
1419
1399
1420
Future <void > _testBadConfig (
1400
1421
Object monoRepoYaml,
0 commit comments