Skip to content

Commit

Permalink
[ci] Run analysis with older versions of Flutter (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan authored Mar 17, 2022
1 parent 1cc7cea commit 017d64d
Show file tree
Hide file tree
Showing 26 changed files with 138 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .ci/scripts/prepare_tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ git fetch origin master

# Pinned version of the plugin tools, to avoid breakage in this repository
# when pushing updates from flutter/plugins.
dart pub global activate flutter_plugin_tools 0.7.3
dart pub global activate flutter_plugin_tools 0.8.1
25 changes: 20 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE
- git fetch origin
# Switch to the requested channel.
- git checkout $TARGET_TREEISH
# When using a branch rather than a hash, reset to the upstream branch
# rather than using pull, since the base image can sometimes be in a state
# where it has diverged from upstream (!).
- if [[ "$TARGET_TREEISH" == "$CHANNEL" ]]; then
# When using a branch rather than a hash or version tag, reset to the
# upstream branch rather than using pull, since the base image can sometimes
# be in a state where it has diverged from upstream (!).
- if [[ "$TARGET_TREEISH" == "$CHANNEL" ]] && [[ "$CHANNEL" != *"."* ]]; then
- git reset --hard @{u}
- fi
# Run doctor to allow auditing of what version of Flutter the run is using.
Expand All @@ -55,8 +55,23 @@ task:
always:
format_script: ./script/tool_runner.sh format --fail-on-change
license_script: dart pub global run flutter_plugin_tools license-check
analyze_script: ./script/tool_runner.sh analyze --custom-analysis=web_benchmarks/testing/test_app,flutter_lints/example,rfw/example,metrics_center
analyze_script: ./script/tool_runner.sh analyze --custom-analysis=script/configs/custom_analysis.yaml
pubspec_script: ./script/tool_runner.sh pubspec-check
# Does a sanity check that packages at least pass analysis on the N-1 and N-2
# versions of Flutter stable if the package claims to support that version.
# This is to minimize accidentally making changes that break old versions
# (which we don't commit to supporting, but don't want to actively break)
# without updating the constraints.
# Note: The versions below should be manually updated after a new stable
# version comes out.
- name: legacy-version-analyze
depends_on: format+analyze
env:
matrix:
CHANNEL: "2.5.3"
CHANNEL: "2.8.1"
analyze_script:
- ./script/tool_runner.sh analyze --skip-if-not-supporting-flutter-version="$CHANNEL" --custom-analysis=script/configs/custom_analysis.yaml
- name: publishable
env:
# TODO(stuartmorgan): Remove once the fix for https://github.com/dart-lang/pub/issues/3152
Expand Down
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Google
---
Language: Cpp
DerivePointerAlignment: false
PointerAlignment: Left
---
Language: ObjC
DerivePointerAlignment: false
PointerAlignment: Right
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
- name: Set up tools
run: dart pub global activate flutter_plugin_tools 0.7.3
run: dart pub global activate flutter_plugin_tools 0.8.1

# # This workflow should be the last to run. So wait for all the other tests to succeed.
- name: Wait on all tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_markdown/example/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "utils.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
_In_ wchar_t* command_line, _In_ int show_command) {
// Attach to console when present (e.g., 'flutter run') or create a
// new console when running with a debugger.
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

@interface SceneDelegate : UIResponder <UIWindowSceneDelegate>

@property(strong, nonatomic) UIWindow* window;
@property(strong, nonatomic) UIWindow *window;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property(nonatomic, strong) IBOutlet UIImageView* imageView;
@property(nonatomic, strong) IBOutlet UIImageView *imageView;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
NSString* appDelegateClassName;
int main(int argc, char *argv[]) {
NSString *appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
Expand Down
2 changes: 1 addition & 1 deletion packages/palette_generator/example/ios/Runner/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/e2e_tests/test_objc/ios/Runner/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ @interface AllDatatypesTest : XCTestCase
@implementation AllDatatypesTest

- (void)testAllNull {
Everything* everything = [[Everything alloc] init];
EchoBinaryMessenger* binaryMessenger =
Everything *everything = [[Everything alloc] init];
EchoBinaryMessenger *binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:FlutterEverythingGetCodec()];
FlutterEverything* api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
FlutterEverything *api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
[api echoEverything:everything
completion:^(Everything* _Nonnull result, NSError* _Nullable error) {
completion:^(Everything *_Nonnull result, NSError *_Nullable error) {
XCTAssertNil(result.aBool);
XCTAssertNil(result.anInt);
XCTAssertNil(result.aDouble);
Expand All @@ -38,7 +38,7 @@ - (void)testAllNull {
}

- (void)testAllEquals {
Everything* everything = [[Everything alloc] init];
Everything *everything = [[Everything alloc] init];
everything.aBool = @NO;
everything.anInt = @(1);
everything.aDouble = @(2.0);
Expand All @@ -54,12 +54,12 @@ - (void)testAllEquals {
everything.aList = @[ @(1), @(2) ];
everything.aMap = @{@"hello" : @(1234)};
everything.mapWithObject = @{@"hello" : @(1234), @"goodbye" : @"world"};
EchoBinaryMessenger* binaryMessenger =
EchoBinaryMessenger *binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:FlutterEverythingGetCodec()];
FlutterEverything* api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
FlutterEverything *api = [[FlutterEverything alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
[api echoEverything:everything
completion:^(Everything* _Nonnull result, NSError* _Nullable error) {
completion:^(Everything *_Nonnull result, NSError *_Nullable error) {
XCTAssertEqual(result.aBool, everything.aBool);
XCTAssertEqual(result.anInt, everything.anInt);
XCTAssertEqual(result.aDouble, everything.aDouble);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
/// A FlutterBinaryMessenger who replies with the first argument sent to it.
@interface EchoBinaryMessenger : NSObject <FlutterBinaryMessenger>
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithCodec:(NSObject<FlutterMessageCodec>*)codec;
- (instancetype)initWithCodec:(NSObject<FlutterMessageCodec> *)codec;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ @interface EnumTest : XCTestCase
@implementation EnumTest

- (void)testEcho {
ACData* data = [[ACData alloc] init];
ACData *data = [[ACData alloc] init];
data.state = ACStateError;
EchoBinaryMessenger* binaryMessenger =
EchoBinaryMessenger *binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:ACEnumApi2HostGetCodec()];
ACEnumApi2Flutter* api = [[ACEnumApi2Flutter alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
ACEnumApi2Flutter *api = [[ACEnumApi2Flutter alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
[api echoData:data
completion:^(ACData* _Nonnull result, NSError* _Nullable error) {
completion:^(ACData *_Nonnull result, NSError *_Nullable error) {
XCTAssertEqual(data.state, result.state);
[expectation fulfill];
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ @interface ListTest : XCTestCase
@implementation ListTest

- (void)testListInList {
LSTTestMessage* top = [[LSTTestMessage alloc] init];
LSTTestMessage* inside = [[LSTTestMessage alloc] init];
LSTTestMessage *top = [[LSTTestMessage alloc] init];
LSTTestMessage *inside = [[LSTTestMessage alloc] init];
inside.testList = @[ @1, @2, @3 ];
top.testList = @[ inside ];
EchoBinaryMessenger* binaryMessenger =
EchoBinaryMessenger *binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:LSTEchoApiGetCodec()];
LSTEchoApi* api = [[LSTEchoApi alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
LSTEchoApi *api = [[LSTEchoApi alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
[api echoMsg:top
completion:^(LSTTestMessage* _Nonnull result, NSError* _Nullable err) {
completion:^(LSTTestMessage *_Nonnull result, NSError *_Nullable err) {
XCTAssertEqual(1u, result.testList.count);
XCTAssertTrue([result.testList[0] isKindOfClass:[LSTTestMessage class]]);
XCTAssertEqualObjects(inside.testList, [result.testList[0] testList]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @interface NonNullFieldsTest : XCTestCase
@implementation NonNullFieldsTest

- (void)testMake {
NNFSearchRequest* request = [NNFSearchRequest makeWithQuery:@"hello"];
NNFSearchRequest *request = [NNFSearchRequest makeWithQuery:@"hello"];
XCTAssertEqualObjects(@"hello", request.query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
///////////////////////////////////////////////////////////////////////////////////////////
@interface MockNullableArgHostApi : NSObject <NRNullableArgHostApi>
@property(nonatomic, assign) BOOL didCall;
@property(nonatomic, copy) NSNumber* x;
@property(nonatomic, copy) NSNumber *x;
@end

///////////////////////////////////////////////////////////////////////////////////////////
@implementation MockNullableArgHostApi
- (nullable NSNumber*)doitX:(NSNumber* _Nullable)x
error:(FlutterError* _Nullable __autoreleasing* _Nonnull)error {
- (nullable NSNumber *)doitX:(NSNumber *_Nullable)x
error:(FlutterError *_Nullable __autoreleasing *_Nonnull)error {
_didCall = YES;
self.x = x;
return x;
Expand All @@ -32,29 +32,29 @@ @interface NullableReturnsTest : XCTestCase
@implementation NullableReturnsTest

- (void)testNullableParameterWithFlutterApi {
EchoBinaryMessenger* binaryMessenger =
EchoBinaryMessenger *binaryMessenger =
[[EchoBinaryMessenger alloc] initWithCodec:NRNullableArgFlutterApiGetCodec()];
NRNullableArgFlutterApi* api =
NRNullableArgFlutterApi *api =
[[NRNullableArgFlutterApi alloc] initWithBinaryMessenger:binaryMessenger];
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
[api doitX:nil
completion:^(NSNumber* _Nonnull result, NSError* _Nullable error) {
completion:^(NSNumber *_Nonnull result, NSError *_Nullable error) {
XCTAssertNil(result);
[expectation fulfill];
}];
[self waitForExpectations:@[ expectation ] timeout:1.0];
}

- (void)testNullableParameterWithHostApi {
MockNullableArgHostApi* api = [[MockNullableArgHostApi alloc] init];
MockBinaryMessenger* binaryMessenger =
MockNullableArgHostApi *api = [[MockNullableArgHostApi alloc] init];
MockBinaryMessenger *binaryMessenger =
[[MockBinaryMessenger alloc] initWithCodec:NRNullableArgHostApiGetCodec()];
NSString* channel = @"dev.flutter.pigeon.NullableArgHostApi.doit";
NSString *channel = @"dev.flutter.pigeon.NullableArgHostApi.doit";
NRNullableArgHostApiSetup(binaryMessenger, api);
XCTAssertNotNil(binaryMessenger.handlers[channel]);
XCTestExpectation* expectation = [self expectationWithDescription:@"callback"];
NSData* arguments = [NRNullableArgHostApiGetCodec() encode:@[ [NSNull null] ]];
binaryMessenger.handlers[channel](arguments, ^(NSData* data) {
XCTestExpectation *expectation = [self expectationWithDescription:@"callback"];
NSData *arguments = [NRNullableArgHostApiGetCodec() encode:@[ [NSNull null] ]];
binaryMessenger.handlers[channel](arguments, ^(NSData *data) {
[expectation fulfill];
});
XCTAssertTrue(api.didCall);
Expand Down
Loading

0 comments on commit 017d64d

Please sign in to comment.