CI en verde: assets de secretos en analyze y test de bundle sin binding
Los dos jobs de ci.yml fallaban desde julio, y no era por los secretos: - `flutter analyze` exige que existan los assets declarados en pubspec, y private-settings*.json están en .gitignore. El workflow los crea vacíos: para analizar basta con que existan. - test/file_test.dart usaba package:test y llamaba a getFileNameOfLang, que lee del rootBundle; sin binding moría, y con binding se quedaba colgado esperando al canal de assets. getFileNameOfLang acepta ahora un AssetBundle inyectable y el test usa uno de mentira, lo que además permite cubrir el idioma de respaldo y el fichero base. - SDK de Dart a >=3.8.0, que es lo que piden los generadores actuales. Reproducido antes y después en la misma imagen del runner (ghcr.io/cirruslabs/flutter:3.41.9): ANALYZE_EXIT=1/TEST_EXIT=1 -> ambos en verde.
This commit is contained in:
parent
7412f61502
commit
726ba7bffa
4 changed files with 68 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:flutter/services.dart' show AssetBundle, rootBundle;
|
||||
|
||||
final RegExp esRegExp = RegExp('^es-');
|
||||
|
||||
|
|
@ -20,13 +20,15 @@ Future<String> getFileNameOfLang(
|
|||
{required String dir,
|
||||
required String fileName,
|
||||
required String ext,
|
||||
required String lang}) async {
|
||||
required String lang,
|
||||
// Inyectable para poder probarlo sin depender del bundle real.
|
||||
AssetBundle? bundle}) async {
|
||||
final String base = '$dir/$fileName';
|
||||
final String fallback = getFallbackLang(lang);
|
||||
String file = '$base-$lang.$ext';
|
||||
if (await assetNotExists(file)) {
|
||||
if (await assetNotExists(file, bundle)) {
|
||||
file = '$base-$fallback.$ext';
|
||||
if (await assetNotExists(file)) {
|
||||
if (await assetNotExists(file, bundle)) {
|
||||
file = '$base.$ext';
|
||||
}
|
||||
}
|
||||
|
|
@ -34,8 +36,8 @@ Future<String> getFileNameOfLang(
|
|||
}
|
||||
|
||||
// https://github.com/flutter/flutter/issues/15325
|
||||
Future<bool> assetNotExists(String asset) {
|
||||
return rootBundle
|
||||
Future<bool> assetNotExists(String asset, [AssetBundle? bundle]) {
|
||||
return (bundle ?? rootBundle)
|
||||
.load(asset)
|
||||
.then((_) => false)
|
||||
.catchError((Object err, StackTrace stack) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue