Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ci/scripts/check_version.sh → .ci/scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -e
# missing version/CHANGELOG detection since PR-level overrides aren't available
# in post-submit.
if [[ $LUCI_PR == "" ]]; then
.ci/scripts/tool_runner.sh version-check --ignore-platform-interface-breaks
.ci/scripts/tool_runner.sh validate --ignore-platform-interface-breaks
else
.ci/scripts/tool_runner.sh version-check --check-for-missing-changes --pr-labels="$PR_OVERRIDE_LABELS"
.ci/scripts/tool_runner.sh validate --check-for-missing-changes --pr-labels="$PR_OVERRIDE_LABELS"
fi
38 changes: 2 additions & 36 deletions .ci/targets/repo_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,12 @@ tasks:
script: .ci/scripts/tool_runner.sh
args: ["license-check"]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this isn't combined is that it's a repo-wide command, not package-level (because we don't want files to accidentally not get license blocks when they aren't in a package).

It is annoying for local validation that it's not part of the same command, but I haven't thought of a good way to combine it yet without making it more likely to miss files.

always: true
# The major and minor version here should match the lowest version analyzed
# in legacy version analysis (.ci.yaml analyze_legacy).
- name: pubspec validation
script: .ci/scripts/tool_runner.sh
args:
- "pubspec-check"
- "--min-min-flutter-version=3.35.0"
- "--allow-dependencies=script/configs/allowed_unpinned_deps.yaml"
- "--allow-pinned-dependencies=script/configs/allowed_pinned_deps.yaml"
always: true
- name: README validation
script: .ci/scripts/tool_runner.sh
args: ["readme-check"]
always: true
# Re-run with --require-excerpts, skipping packages that still need
# to be converted. Once https://github.com/flutter/flutter/issues/102679
# has been fixed, this can be removed --require-excerpts added to the
# run above.
- name: README snippet configuration validation
script: .ci/scripts/tool_runner.sh
args: ["readme-check", "--require-excerpts", "--exclude=script/configs/temp_exclude_excerpt.yaml"]
always: true
- name: README snippet validation
script: .ci/scripts/tool_runner.sh
args: ["update-excerpts", "--fail-on-change"]
always: true
- name: Gradle validation
script: .ci/scripts/tool_runner.sh
args: ["gradle-check"]
always: true
- name: Repository-level package metadata validation
script: .ci/scripts/tool_runner.sh
args: ["check-repo-package-info"]
always: true
- name: Dependabot coverage validation
script: .ci/scripts/tool_runner.sh
args: ["dependabot-check"]
always: true
- name: CHANGELOG and version validation
script: .ci/scripts/check_version.sh
- name: Repository standards validation
script: .ci/scripts/validate.sh
always: true
- name: federated safety check
script: .ci/scripts/check_federated_safety.sh
Expand Down
4 changes: 1 addition & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart update-dependency
The tool can also run native and integration tests, but these may require a more complete environment than is available.
- **Validation**: Run these checks to ensure that changes follow team guidelines:
```bash
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart validate --packages <changed_packages>
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart publish-check --packages <changed_packages>
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart readme-check --packages <changed_packages>
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart version-check --packages <changed_packages>
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart license-check
dart run $REPO_ROOT/script/tool/bin/flutter_plugin_tools.dart repo-package-info-check
```

### Specialized Workflows
Expand Down
2 changes: 2 additions & 0 deletions packages/espresso/ci_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO(stuartmorgan): Remove this; see https://github.com/flutter/flutter/issues/102679
exempt_from_excerpts: true
2 changes: 2 additions & 0 deletions packages/in_app_purchase/in_app_purchase/ci_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO(stuartmorgan): Remove this; see https://github.com/flutter/flutter/issues/102679
exempt_from_excerpts: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO(stuartmorgan): Remove this; see https://github.com/flutter/flutter/issues/102679
exempt_from_excerpts: true
2 changes: 2 additions & 0 deletions packages/quick_actions/quick_actions/ci_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO(stuartmorgan): Remove this; see https://github.com/flutter/flutter/issues/102679
exempt_from_excerpts: true
12 changes: 0 additions & 12 deletions script/configs/temp_exclude_excerpt.yaml

This file was deleted.

14 changes: 13 additions & 1 deletion script/tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dart run script/tool/bin/flutter_plugin_tools.dart format --packages package_nam

The `flutter/packages` repository uses clang version `15.0.0` . Newer versions of clang may format code differently.

### Run the Static Analysis
### Run Static Analysis

To analyze only Dart code:

Expand All @@ -68,6 +68,18 @@ dart run script/tool/bin/flutter_plugin_tools.dart analyze --ios --macos --packa

Dart analysis can be excluded with `--no-dart`.

### Run General Validation

To check that changes follow team standards and best practices, run:

```sh
dart run script/tool/bin/flutter_plugin_tools.dart validate --check-for-missing-changes --packages package_name
```

If you are making changes that fall under a CHANGELOG and/or version change
exemption you can omit the `--check-for-missing-changes` flag to skip those
checks.

### Run Dart Unit Tests

```sh
Expand Down
19 changes: 17 additions & 2 deletions script/tool/lib/src/common/ci_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:yaml/yaml.dart';
/// A class representing the parsed content of a `ci_config.yaml` file.
class CIConfig {
/// Creates a [CIConfig] from a parsed YAML map.
CIConfig._(this.isBatchRelease);
CIConfig._({required this.isBatchRelease, required this.requiresExcerpts});

/// Parses a [CIConfig] from a YAML string.
///
Expand All @@ -26,18 +26,33 @@ class CIConfig {
isBatchRelease = release['batch'] == true;
}

return CIConfig._(isBatchRelease);
// Any package that hasn't been explicitly exempted is assumed to require
// excerpts.
var requiresExcerpts = true;
final Object? exemptFromExcerpts = loaded['exempt_from_excerpts'];
if (exemptFromExcerpts is bool) {
requiresExcerpts = !exemptFromExcerpts;
}

return CIConfig._(
isBatchRelease: isBatchRelease,
requiresExcerpts: requiresExcerpts,
);
}

static const Map<String, Object?> _validCIConfigSyntax = <String, Object?>{
'release': <String, Object?>{
'batch': <bool>{true, false},
},
'exempt_from_excerpts': <bool>{true, false},
};

/// Returns true if the package is configured for batch release.
final bool isBatchRelease;

/// Returns true if the package is configured to require excerpts.
final bool requiresExcerpts;

static void _checkCIConfigEntries(
YamlMap config, {
required Map<String, Object?> syntax,
Expand Down
4 changes: 4 additions & 0 deletions script/tool/lib/src/common/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,7 @@ Directory? ciLogsDirectory(Platform platform, FileSystem fileSystem) {
}
return logsDirectory;
}

/// The directory that contains repo-specific configuration for this tooling.
Directory toolConfigDirectory(Directory repoRoot) =>
repoRoot.childDirectory('tool_config');
18 changes: 18 additions & 0 deletions script/tool/lib/src/common/file_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:file/file.dart';
import 'package:path/path.dart' as p;
import 'package:yaml/yaml.dart';

/// Returns a [File] created by appending all but the last item in [components]
/// to [base] as subdirectories, then appending the last as a file.
Expand Down Expand Up @@ -49,3 +50,20 @@ String relativePosixPath(
platformContext.relative(entity.absolute.path, from: from.path),
),
);

/// Loads the file at [filename], which must contain a YAML list of strings.
///
/// If the file is not found, returns null.
List<String>? loadYamlList(File file) {
if (!file.existsSync()) {
return null;
}
final String contents = file.readAsStringSync();
final Object? yaml = loadYaml(contents);
// Treat an empty or comment-only file as an empty list, to avoid requiring
// adding an explicit empty list entry to the YAML when no entries are needed.
if (yaml == null) {
return [];
}
return (yaml as YamlList).toList().cast<String>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cast to YamlList will throw a TypeError if the YAML content is not a list (e.g., if it's a map or a scalar). Since this is a utility function, it should handle invalid YAML structures more gracefully or provide a clearer error message.

  if (yaml is! YamlList) {
    return <String>[];
  }
  return yaml.toList().cast<String>();

}
8 changes: 4 additions & 4 deletions script/tool/lib/src/common/package_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'package:file/file.dart';
import 'package:git/git.dart';
import 'package:path/path.dart' as p;
import 'package:platform/platform.dart';
import 'package:yaml/yaml.dart';

import 'core.dart';
import 'file_utils.dart';
import 'git_version_finder.dart';
import 'output_utils.dart';
import 'process_runner.dart';
Expand Down Expand Up @@ -286,11 +286,11 @@ abstract class PackageCommand extends Command<void> {
return getStringListArg(key).expand<String>((String item) {
if (item.endsWith('.yaml')) {
final File file = packagesDir.fileSystem.file(item);
final Object? yaml = loadYaml(file.readAsStringSync());
if (yaml == null) {
final List<String>? list = loadYamlList(file);
if (list == null) {
return const <String>[];
}
return (yaml as YamlList).toList().cast<String>();
return list;
}
return <String>[item];
}).toSet();
Expand Down
2 changes: 2 additions & 0 deletions script/tool/lib/src/common/package_state_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ Future<bool> _isDevChange(
pathComponents.contains('lint-baseline.xml') ||
// Example build files are very unlikely to be interesting to clients.
_isExampleBuildFile(pathComponents) ||
// CI config files don't affect clients.
pathComponents.last == 'ci_config.yaml' ||
// Test-only gradle depenedencies don't affect clients.
await _isGradleTestDependencyChange(
pathComponents,
Expand Down
4 changes: 4 additions & 0 deletions script/tool/lib/src/common/repository_package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ class RepositoryPackage {
!isPlatformInterface &&
directory.basename != directory.parent.basename;

/// True if this appears to be a top-level package, according to repository
/// conventions.
bool get isTopLevel => getEnclosingPackage() == null;

/// True if this appears to be an example package, according to package
/// conventions.
bool get isExample {
Expand Down
64 changes: 0 additions & 64 deletions script/tool/lib/src/dependabot_check_command.dart

This file was deleted.

44 changes: 0 additions & 44 deletions script/tool/lib/src/gradle_check_command.dart

This file was deleted.

Loading
Loading