From bd4bb12355712b45a4718e8db0e9bd0345c6357f Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 13:58:43 +0100 Subject: [PATCH 1/4] Forgotten fix --- .github/workflows/health_base.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/health_base.yaml b/.github/workflows/health_base.yaml index 6b7c4c16..27df6fef 100644 --- a/.github/workflows/health_base.yaml +++ b/.github/workflows/health_base.yaml @@ -127,8 +127,7 @@ jobs: if: ${{ inputs.check == 'coverage' }} - name: Install firehose - run: dart pub global activate --source git https://github.com/dart-lang/ecosystem --git-path pkgs/firehose/ --git-ref=forceFlutter - # DO-NOT-SUBMIT + run: dart pub global activate firehose if: ${{ !inputs.local_debug }} - name: Install local firehose From b8e04df25db0de9967272827e5157d783acbf75b Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:05:00 +0100 Subject: [PATCH 2/4] Fix quest --- pkgs/quest/bin/quest.dart | 87 ++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/pkgs/quest/bin/quest.dart b/pkgs/quest/bin/quest.dart index 7e8075bf..ded1d52f 100644 --- a/pkgs/quest/bin/quest.dart +++ b/pkgs/quest/bin/quest.dart @@ -17,43 +17,35 @@ Future main(List arguments) async { var gitUri = arguments[1].replaceRange(0, 'git'.length, 'https'); gitUri = gitUri.substring(0, gitUri.length - '.git'.length); final branch = arguments[2]; - final lines = arguments[3].split('\n'); - final labels = lines - .sublist(1, lines.length - 1) - .map((e) => e.trim()) - .where((line) => line.startsWith('ecosystem-test')); - print('Labels: $labels'); - final packages = fire.Repository().locatePackages(); - //TODO: Possibly run for all packages, not just the first. - final package = packages.firstWhereOrNull((package) => - labels.any((label) => label == 'ecosystem-test-${package.name}')); - if (package != null) { - print('Found $package. Embark on a quest!'); - final version = '${package.name}:${json.encode({ - 'git': { - 'url': gitUri, - 'ref': branch, - 'path': - p.relative(package.directory.path, from: Directory.current.path) - } - })}'; - final chronicles = await Quest( - package.name, - version, - repositoriesFile, - ).embark(); - final comment = createComment(chronicles); - await writeComment(comment); - print(chronicles); - exitCode = chronicles.success ? 0 : 1; + final allLabels = arguments[3].split('\n'); + if (allLabels.length >= 1) { + final labels = allLabels + .map((e) => e.trim()) + .where((line) => line.startsWith('ecosystem-test')); + print('Labels: $labels'); + final packages = fire.Repository().locatePackages(); + //TODO: Possibly run for all packages, not just the first. + final package = packages.firstWhereOrNull( + (package) => + labels.any((label) => label == 'ecosystem-test-${package.name}'), + ); + if (package != null) { + print('Found $package. Embark on a quest!'); + final version = + '${package.name}:${json.encode({ + 'git': {'url': gitUri, 'ref': branch, 'path': p.relative(package.directory.path, from: Directory.current.path)}, + })}'; + final chronicles = + await Quest(package.name, version, repositoriesFile).embark(); + final comment = createComment(chronicles); + await writeComment(comment); + print(chronicles); + exitCode = chronicles.success ? 0 : 1; + } } } -enum Level { - solve, - analyze, - test; -} +enum Level { solve, analyze, test } /// The result of embarking on a quest. Stores the [package] which was tested /// with its new [version] as well as the [chapters] of the chronicles, each @@ -84,8 +76,9 @@ class Chapter { bool get success => failure == null; - Level? get failure => Level.values.firstWhereOrNull((level) => - before[level]?.success == true && after[level]?.success == false); + Level? get failure => Level.values.firstWhereOrNull( + (level) => before[level]?.success == true && after[level]?.success == false, + ); String toRow(Application application) => ''' | ${application.name} | ${Level.values.map((l) => '${before[l]?.success.toEmoji ?? '-'}/${after[l]?.success.toEmoji ?? '-'}').join(' | ')} |'''; @@ -127,17 +120,16 @@ class Application { static Future> listFromFile(String path) async { final s = await File(path).readAsString(); - return (jsonDecode(s) as Map) - .entries + return (jsonDecode(s) as Map).entries .where((e) => e.key != r'$schema') .map((e) => MapEntry(e.key as String, e.value as Map)) .map((e) { - return Application( - url: e.key, - name: (e.value['name'] as String?) ?? p.basename(e.key), - level: Level.values.firstWhere((l) => l.name == e.value['level']), - ); - }); + return Application( + url: e.key, + name: (e.value['name'] as String?) ?? p.basename(e.key), + level: Level.values.firstWhere((l) => l.name == e.value['level']), + ); + }); } @override @@ -179,8 +171,11 @@ class Quest { await runFlutter(['clean'], path); print('Rev package:$candidatePackage to version $version $application'); - final revSuccess = - await runFlutter(['pub', 'add', version], path, true); + final revSuccess = await runFlutter( + ['pub', 'add', version], + path, + true, + ); print('Run checks for modified package'); final resultAfter = await runChecks(path, application.level); From cd777ffb27984537a9fd4b4b233ed0929b0b2d79 Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:06:34 +0100 Subject: [PATCH 3/4] Fix quest again --- pkgs/quest/bin/quest.dart | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pkgs/quest/bin/quest.dart b/pkgs/quest/bin/quest.dart index ded1d52f..aea84646 100644 --- a/pkgs/quest/bin/quest.dart +++ b/pkgs/quest/bin/quest.dart @@ -18,7 +18,7 @@ Future main(List arguments) async { gitUri = gitUri.substring(0, gitUri.length - '.git'.length); final branch = arguments[2]; final allLabels = arguments[3].split('\n'); - if (allLabels.length >= 1) { + if (allLabels.isNotEmpty) { final labels = allLabels .map((e) => e.trim()) .where((line) => line.startsWith('ecosystem-test')); @@ -31,9 +31,13 @@ Future main(List arguments) async { ); if (package != null) { print('Found $package. Embark on a quest!'); - final version = - '${package.name}:${json.encode({ - 'git': {'url': gitUri, 'ref': branch, 'path': p.relative(package.directory.path, from: Directory.current.path)}, + final version = '${package.name}:${json.encode({ + 'git': { + 'url': gitUri, + 'ref': branch, + 'path': p.relative(package.directory.path, + from: Directory.current.path) + }, })}'; final chronicles = await Quest(package.name, version, repositoriesFile).embark(); @@ -77,8 +81,9 @@ class Chapter { bool get success => failure == null; Level? get failure => Level.values.firstWhereOrNull( - (level) => before[level]?.success == true && after[level]?.success == false, - ); + (level) => + before[level]?.success == true && after[level]?.success == false, + ); String toRow(Application application) => ''' | ${application.name} | ${Level.values.map((l) => '${before[l]?.success.toEmoji ?? '-'}/${after[l]?.success.toEmoji ?? '-'}').join(' | ')} |'''; @@ -120,16 +125,17 @@ class Application { static Future> listFromFile(String path) async { final s = await File(path).readAsString(); - return (jsonDecode(s) as Map).entries + return (jsonDecode(s) as Map) + .entries .where((e) => e.key != r'$schema') .map((e) => MapEntry(e.key as String, e.value as Map)) .map((e) { - return Application( - url: e.key, - name: (e.value['name'] as String?) ?? p.basename(e.key), - level: Level.values.firstWhere((l) => l.name == e.value['level']), - ); - }); + return Application( + url: e.key, + name: (e.value['name'] as String?) ?? p.basename(e.key), + level: Level.values.firstWhere((l) => l.name == e.value['level']), + ); + }); } @override From 8fb735fff02508411c6ba257177ee6dca7436dff Mon Sep 17 00:00:00 2001 From: Moritz Date: Fri, 6 Dec 2024 14:07:15 +0100 Subject: [PATCH 4/4] Fix quest again and again --- pkgs/quest/bin/quest.dart | 56 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/pkgs/quest/bin/quest.dart b/pkgs/quest/bin/quest.dart index aea84646..252dbb44 100644 --- a/pkgs/quest/bin/quest.dart +++ b/pkgs/quest/bin/quest.dart @@ -17,35 +17,33 @@ Future main(List arguments) async { var gitUri = arguments[1].replaceRange(0, 'git'.length, 'https'); gitUri = gitUri.substring(0, gitUri.length - '.git'.length); final branch = arguments[2]; - final allLabels = arguments[3].split('\n'); - if (allLabels.isNotEmpty) { - final labels = allLabels - .map((e) => e.trim()) - .where((line) => line.startsWith('ecosystem-test')); - print('Labels: $labels'); - final packages = fire.Repository().locatePackages(); - //TODO: Possibly run for all packages, not just the first. - final package = packages.firstWhereOrNull( - (package) => - labels.any((label) => label == 'ecosystem-test-${package.name}'), - ); - if (package != null) { - print('Found $package. Embark on a quest!'); - final version = '${package.name}:${json.encode({ - 'git': { - 'url': gitUri, - 'ref': branch, - 'path': p.relative(package.directory.path, - from: Directory.current.path) - }, - })}'; - final chronicles = - await Quest(package.name, version, repositoriesFile).embark(); - final comment = createComment(chronicles); - await writeComment(comment); - print(chronicles); - exitCode = chronicles.success ? 0 : 1; - } + final labels = arguments[3] + .split('\n') + .map((e) => e.trim()) + .where((line) => line.startsWith('ecosystem-test')); + print('Labels: $labels'); + final packages = fire.Repository().locatePackages(); + //TODO: Possibly run for all packages, not just the first. + final package = packages.firstWhereOrNull( + (package) => + labels.any((label) => label == 'ecosystem-test-${package.name}'), + ); + if (package != null) { + print('Found $package. Embark on a quest!'); + final version = '${package.name}:${json.encode({ + 'git': { + 'url': gitUri, + 'ref': branch, + 'path': + p.relative(package.directory.path, from: Directory.current.path) + }, + })}'; + final chronicles = + await Quest(package.name, version, repositoriesFile).embark(); + final comment = createComment(chronicles); + await writeComment(comment); + print(chronicles); + exitCode = chronicles.success ? 0 : 1; } }