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
2 changes: 1 addition & 1 deletion .ci/targets/macos_repo_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ tasks:
always: true
- name: validate iOS and macOS podspecs
script: .ci/scripts/tool_runner.sh
args: ["podspec-check", "--exclude=script/configs/exclude_xcode_deprecation.yaml"]
args: ["podspec-check"]
always: true
36 changes: 8 additions & 28 deletions script/tool/lib/src/podspec_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PodspecCheckCommand extends PackageLoopingCommand {

@override
final String description =
'Runs "pod lib lint" on all iOS and macOS plugin podspecs, as well as '
'Runs "pod lib lint --quick" on all iOS and macOS plugin podspecs, as well as '
'making sure the podspecs follow repository standards.\n\n'
'This command requires "pod" and "flutter" to be in your path. Runs on macOS only.';

Expand Down Expand Up @@ -111,11 +111,6 @@ class PodspecCheckCommand extends PackageLoopingCommand {
}

Future<List<File>> _podspecsToLint(RepositoryPackage package) async {
// Since the pigeon platform tests podspecs require generated files that are not included in git,
// the podspec lint fails.
if (package.path.contains('packages/pigeon/platform_tests/')) {
return <File>[];
}
final List<File> podspecs =
await getFilesForPackage(package).where((File entity) {
final String filename = entity.basename;
Expand All @@ -130,36 +125,21 @@ class PodspecCheckCommand extends PackageLoopingCommand {
}

Future<bool> _lintPodspec(File podspec) async {
// Do not run the static analyzer on plugins with known analyzer issues.
final String podspecPath = podspec.path;

final String podspecBasename = podspec.basename;
print('Linting $podspecBasename');

// Lint plugin as framework (use_frameworks!).
final ProcessResult frameworkResult =
await _runPodLint(podspecPath, libraryLint: true);
print(frameworkResult.stdout);
print(frameworkResult.stderr);
print('Linting ${podspec.basename}');

// Lint plugin as library.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The difference only matters when building, so we don't need to run both modes.

final ProcessResult libraryResult =
await _runPodLint(podspecPath, libraryLint: false);
print(libraryResult.stdout);
print(libraryResult.stderr);
final ProcessResult lintResult = await _runPodLint(podspec.path);
print(lintResult.stdout);
print(lintResult.stderr);

return frameworkResult.exitCode == 0 && libraryResult.exitCode == 0;
return lintResult.exitCode == 0;
}

Future<ProcessResult> _runPodLint(String podspecPath,
{required bool libraryLint}) async {
Future<ProcessResult> _runPodLint(String podspecPath) async {
final List<String> arguments = <String>[
'lib',
'lint',
podspecPath,
'--configuration=Debug', // Release targets unsupported arm64 simulators. Use Debug to only build against targeted x86_64 simulator devices.
'--skip-tests',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These flags aren't used in --quick mode.

if (libraryLint) '--use-libraries'
'--quick',
];

print('Running "pod ${arguments.join(' ')}"');
Expand Down
63 changes: 2 additions & 61 deletions script/tool/test/podspec_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,7 @@ void main() {
.platformDirectory(FlutterPlatform.ios)
.childFile('plugin1.podspec')
.path,
'--configuration=Debug',
'--skip-tests',
'--use-libraries'
],
packagesDir.path),
ProcessCall(
'pod',
<String>[
'lib',
'lint',
plugin
.platformDirectory(FlutterPlatform.ios)
.childFile('plugin1.podspec')
.path,
'--configuration=Debug',
'--skip-tests',
'--quick',
],
packagesDir.path),
]),
Expand Down Expand Up @@ -207,22 +192,7 @@ void main() {
.platformDirectory(FlutterPlatform.macos)
.childFile('plugin1.podspec')
.path,
'--configuration=Debug',
'--skip-tests',
'--use-libraries'
],
packagesDir.path),
ProcessCall(
'pod',
<String>[
'lib',
'lint',
plugin
.platformDirectory(FlutterPlatform.macos)
.childFile('plugin1.podspec')
.path,
'--configuration=Debug',
'--skip-tests',
'--quick',
],
packagesDir.path),
]),
Expand Down Expand Up @@ -283,35 +253,6 @@ void main() {
));
});

test('fails if linting as a static library fails', () async {
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir);
_writeFakePodspec(plugin, 'ios');

// Simulate failure from the second call to `pod`.
processRunner.mockProcessesForExecutable['pod'] = <FakeProcessInfo>[
FakeProcessInfo(MockProcess()),
FakeProcessInfo(MockProcess(exitCode: 1)),
];

Error? commandError;
final List<String> output = await runCapturingPrint(
runner, <String>['podspec-check'], errorHandler: (Error e) {
commandError = e;
});

expect(commandError, isA<ToolExit>());

expect(
output,
containsAllInOrder(
<Matcher>[
contains('The following packages had errors:'),
contains('plugin1:\n'
' plugin1.podspec')
],
));
});

test('fails if an iOS Swift plugin is missing the search paths workaround',
() async {
final RepositoryPackage plugin = createFakePlugin(
Expand Down