Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request transitions the hardcoded list of Flutter CI-supported repositories to a dynamic configuration (ciEnabledRepos) and implements case-insensitive repository slug matching and canonicalization across several services, including the scheduler, token generator, and Gerrit service. Additionally, it removes the legacy useForAllRepos flag from the LGTM configuration. The review feedback suggests two improvements: using a more idiomatic constructor tear-off with Iterable.map when initializing ciEnabledRepoSlugs, and performing a broader is Map type check instead of is Map<String, dynamic> to avoid potential runtime type mismatches when retrieving GitHub App installations.
| }) : ciEnabledRepoSlugs = UnmodifiableSetView<RepositorySlug>( | ||
| LinkedHashSet<RepositorySlug>( | ||
| equals: (a, b) => | ||
| a.fullName.toLowerCase() == b.fullName.toLowerCase(), | ||
| hashCode: (s) => s.fullName.toLowerCase().hashCode, | ||
| )..addAll(<RepositorySlug>[ | ||
| for (final repo in ciEnabledRepos) RepositorySlug.full(repo), | ||
| ]), | ||
| ); |
There was a problem hiding this comment.
Using a constructor tear-off with Iterable.map is more concise and idiomatic in modern Dart than using a collection for loop inside a list literal.
}) : ciEnabledRepoSlugs = UnmodifiableSetView<RepositorySlug>(
LinkedHashSet<RepositorySlug>(
equals: (a, b) =>
a.fullName.toLowerCase() == b.fullName.toLowerCase(),
hashCode: (s) => s.fullName.toLowerCase().hashCode,
)..addAll(ciEnabledRepos.map(RepositorySlug.full)),
);| final appInstallation = installation is Map<String, dynamic> | ||
| ? installation['installation_id'] as String? | ||
| : null; |
There was a problem hiding this comment.
Checking installation is Map is more robust and idiomatic than checking installation is Map<String, dynamic>, as it avoids potential runtime type mismatches if the map is instantiated with a slightly different generic type (e.g., Map<String, Object>).
| final appInstallation = installation is Map<String, dynamic> | |
| ? installation['installation_id'] as String? | |
| : null; | |
| final appInstallation = installation is Map | |
| ? installation['installation_id'] as String? | |
| : null; |
…emove useForAllRepos Move Flutter CI repository membership into app_dart/config.yaml under ciEnabledRepos, validate and canonicalize slugs once at config load time, and expose Config.supportedRepos as a precomputed case-insensitive set. Also remove wantLgtm.useForAllRepos (so VacuumWantLgtm always sweeps disabled repos) and harden Config._generateGithubToken with a case-insensitive installation lookup and explicit StateError when an installation ID is missing.
0947d2e to
1242c8a
Compare
Summary
Moves the Flutter CI repository list (
flutter/cocoon,flutter/flutter,flutter/packages) from hardcoded Dart constants intociEnabledReposinapp_dart/config.yaml, and removes the unusedwantLgtm.useForAllReposflag. This prepares for onboarding non-CIWANT_LGTMrepositories (such asflutter/rfc) in #5237 without changing live CI behavior.Changes
ciEnabledRepostoapp_dart/config.yaml,app_dart/lib/src/generated_config.dart, andDynamicConfig, validated and canonicalized once viaparseCanonicalRepoSlugs.Config.supportedReposwith a precomputed case-insensitiveLinkedHashSet<RepositorySlug>(DynamicConfig.ciEnabledRepoSlugs) and canonicalize mixed-case slugs viasupportedRepos.lookup(...)inVacuumGithubCommits,GerritService.findMirroredCommit, andScheduler._addCommit.Config.defaultBranchandConfig.generateGithubToken(cache key, lock key, and installation lookup) case-insensitive, throwing an explicitStateErrorwhen a repository is missing fromAPP_DART_GITHUBAPP_INSTALLATIONS.wantLgtm.useForAllReposfromapp_dart/config.yaml,WantLgtmFlags, andWantLgtmCheckWriter.sweepInProgressRunsso per-repo rollbacks always sweep cleanly.FakeConfig.supportedReposand add unit tests for dynamicciEnabledRepos, slug validation, legacy JSON tolerance, mixed-case lookup canonicalization, and missing installation errors.Rollout Notes
ciEnabledReposand removingwantLgtm.useForAllReposare N-1 compatible (json_serializableignores unrecognized keys and defaults missing keys to the existing three CI repositories).Testing
dart format --output=none --set-exit-if-changed app_dart/lib/ app_dart/test/ packages/cocoon_integration_test/lib/: 0 diffs.dart analyze --fatal-infos(app_dart,packages/cocoon_integration_test): 0 issues.dart testinapp_dart: 1,261/1,261 passed.dart testinpackages/cocoon_integration_test: 49/49 passed.