-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: validate publish dry runs (#2161)
* draft script for checking publish * draft implementation * comment * trigger ci * Update workflow * Update workflow * Update workflow * Update workflow * revert example{ * Update workflow * Temporarily restrict drift for testing * Update pubspec.yaml * Update pubspec.yaml * Revert * Update analyze.yml * Update event_example.dart
- Loading branch information
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
An internal command-line application to validate publish. | ||
We temporarily need to use the `--skip-validation` flag in order to publish with backwards compatible WASM support. | ||
Since we now don't have validations in place, this validation tool will catch unexpected errors that might occur during dry runs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:lints/recommended.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:args/args.dart'; | ||
|
||
void main(List<String> arguments) async { | ||
final parser = ArgParser() | ||
..addOption( | ||
'executable', | ||
allowed: ['dart', 'flutter'], | ||
defaultsTo: 'dart', | ||
help: 'Specify the executable to use (dart or flutter)', | ||
); | ||
|
||
ArgResults args; | ||
try { | ||
args = parser.parse(arguments); | ||
} on FormatException catch (e) { | ||
print('Error: ${e.message}'); | ||
print('Usage: dart script.dart [--executable <dart|flutter>]'); | ||
exit(1); | ||
} | ||
|
||
final executable = args['executable'] as String; | ||
|
||
final result = await Process.run(executable, ['pub', 'publish', '--dry-run']); | ||
final publishOutput = result.stderr as String; | ||
|
||
if (publishOutput.contains('Found no `pubspec.yaml` file')) { | ||
print(publishOutput); | ||
exit(1); | ||
} | ||
|
||
const expectedErrors = [ | ||
'lib/src/integrations/connectivity/web_connectivity_provider.dart: This package does not have web in the `dependencies` section of `pubspec.yaml`', | ||
'lib/src/event_processor/enricher/web_enricher_event_processor.dart: This package does not have web in the `dependencies` section of `pubspec.yaml`', | ||
'lib/src/origin_web.dart: This package does not have web in the `dependencies` section of `pubspec.yaml`', | ||
'lib/src/platform/_web_platform.dart: This package does not have web in the `dependencies` section of `pubspec.yaml`' | ||
]; | ||
|
||
// So far the expected errors all start with `* line` | ||
final errorLines = publishOutput | ||
.split('\n') | ||
.where((line) => line.startsWith('* line')) | ||
.toList(); | ||
|
||
final unexpectedErrors = errorLines.where((errorLine) { | ||
return !expectedErrors | ||
.any((expectedError) => errorLine.contains(expectedError)); | ||
}).toList(); | ||
|
||
if (unexpectedErrors.isEmpty) { | ||
print('Only expected errors found. Validation passed.'); | ||
exit(0); | ||
} else { | ||
print('Unexpected errors found:'); | ||
unexpectedErrors.forEach(print); | ||
exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: publish_validation | ||
description: Command-line application for validating publish dry runs. | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ^3.4.3 | ||
|
||
dependencies: | ||
args: ^2.5.0 | ||
|
||
dev_dependencies: | ||
lints: ^3.0.0 | ||
test: ^1.24.0 |