From d2678d5cea3beb1b84302632b8483bbc16820b37 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 23 Oct 2024 12:32:51 +1100 Subject: [PATCH 1/8] Still debugging global flake --- .github/workflows/ffigen.yml | 216 +++++++++++++++++------------------ 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index 13d48a1c1..22c151b4d 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -23,52 +23,52 @@ env: jobs: # Check code formatting and static analysis on a single OS (macos). - analyze: - runs-on: macos-latest - defaults: - run: - working-directory: pkgs/ffigen/ - strategy: - fail-fast: false - steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - with: - channel: 'stable' - - id: install - name: Install dependencies - run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" - - name: Check formatting - run: dart format --output=none --set-exit-if-changed . - if: always() && steps.install.outcome == 'success' - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Analyze code - run: flutter analyze --fatal-infos + # analyze: + # runs-on: macos-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # strategy: + # fail-fast: false + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - id: install + # name: Install dependencies + # run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" + # - name: Check formatting + # run: dart format --output=none --set-exit-if-changed . + # if: always() && steps.install.outcome == 'success' + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Analyze code + # run: flutter analyze --fatal-infos - test-linux: - needs: analyze - runs-on: ubuntu-22.04 - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get - - name: Install libclang-14-dev - run: sudo apt-get install libclang-14-dev - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test + # test-linux: + # needs: analyze + # runs-on: ubuntu-22.04 + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get + # - name: Install libclang-14-dev + # run: sudo apt-get install libclang-14-dev + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: dart test # Keep in sync with ffigen_weekly.yaml:test-mac-arm64 test-mac: - needs: analyze + # needs: analyze runs-on: 'macos-latest' defaults: run: @@ -82,57 +82,57 @@ jobs: run: flutter pub get && flutter pub get --directory="../objective_c" - name: Build test dylib and bindings run: dart test/setup.dart - - name: Run VM tests and collect coverage - run: dart run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c - - name: Upload coverage - uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 - with: - flag-name: ffigen - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel: true - path-to-lcov: pkgs/ffigen/coverage/lcov.info - - name: Upload coverage - uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 - with: - carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + - name: Run VM tests + run: fail_count=0; for i in {1..10}; do dart test || ((fail_count++)); done; if ((fail_count > 0)); then echo "There were $fail_count failures"; exit 1; fi + # - name: Upload coverage + # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 + # with: + # flag-name: ffigen + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel: true + # path-to-lcov: pkgs/ffigen/coverage/lcov.info + # - name: Upload coverage + # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 + # with: + # carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel-finished: true - test-mac-flutter: - needs: analyze - runs-on: 'macos-latest' - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" - - name: Build test dylib and bindings - run: dart test/setup.dart --main-thread-dispatcher - - name: Run Flutter tests - run: flutter test + # test-mac-flutter: + # needs: analyze + # runs-on: 'macos-latest' + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get && flutter pub get --directory="../objective_c" + # - name: Build test dylib and bindings + # run: dart test/setup.dart --main-thread-dispatcher + # - name: Run Flutter tests + # run: flutter test - test-windows: - needs: analyze - runs-on: windows-latest - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test + # test-windows: + # needs: analyze + # runs-on: windows-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: dart test # Sanity check the latest `flutter create --template plugin_ffi`. # This will break if we change the Flutter template or the generated code. @@ -144,20 +144,20 @@ jobs: # merge PRs. # Running this sanity check on one OS should be sufficient. Chosing Windows # because it is the most likely to break. - test-windows-flutter: - needs: analyze - runs-on: windows-latest - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - with: - channel: "master" - - name: Install dependencies - run: flutter pub get - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: flutter pub run test test_flutter/ + # test-windows-flutter: + # needs: analyze + # runs-on: windows-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: "master" + # - name: Install dependencies + # run: flutter pub get + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: flutter pub run test test_flutter/ From 8d51e0c519d28ca93d169e1bdc67ccee9a629d4a Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 23 Oct 2024 13:26:30 +1100 Subject: [PATCH 2/8] Fix typo --- pkgs/ffigen/test/native_objc_test/global_native_test.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.m b/pkgs/ffigen/test/native_objc_test/global_native_test.m index f63acc4b6..32d439e0c 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.m +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.m @@ -4,7 +4,7 @@ #import -#include "global_test.h" +#include "global_native_test.h" NSString* globalNativeString = @"Hello World"; NSObject* _Nullable globalNativeObject = nil; From fdc7c0a37223a974f9effa5b1e473463579aae47 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 18 Dec 2024 14:43:39 +1100 Subject: [PATCH 3/8] Unify native code for global_test and global_native_test --- .../global_native_config.yaml | 8 ++--- .../native_objc_test/global_native_test.dart | 29 ++++++++++--------- .../native_objc_test/global_native_test.h | 10 ------- .../native_objc_test/global_native_test.m | 11 ------- .../test/native_objc_test/global_test.dart | 1 + 5 files changed, 20 insertions(+), 39 deletions(-) delete mode 100644 pkgs/ffigen/test/native_objc_test/global_native_test.h delete mode 100644 pkgs/ffigen/test/native_objc_test/global_native_test.m diff --git a/pkgs/ffigen/test/native_objc_test/global_native_config.yaml b/pkgs/ffigen/test/native_objc_test/global_native_config.yaml index f3700c69d..30a4afe22 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_config.yaml +++ b/pkgs/ffigen/test/native_objc_test/global_native_config.yaml @@ -6,11 +6,11 @@ exclude-all-by-default: true ffi-native: globals: include: - - globalNativeString - - globalNativeObject - - globalNativeBlock + - globalString + - globalObject + - globalBlock headers: entry-points: - - 'global_native_test.h' + - 'global_test.h' preamble: | // ignore_for_file: camel_case_types, non_constant_identifier_names, unnecessary_non_null_assertion, unused_element, unused_field diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index db59062a5..5b797a22f 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -26,23 +26,24 @@ void main() { final dylib = File('test/native_objc_test/objc_test.dylib'); verifySetupFile(dylib); DynamicLibrary.open(dylib.absolute.path); - generateBindingsForCoverage('global_native'); + generateBindingsForCoverage('global'); }); test('Global string', () { - expect(globalNativeString.toString(), 'Hello World'); - globalNativeString = 'Something else'.toNSString(); - expect(globalNativeString.toString(), 'Something else'); + expect(globalString.toString(), 'Hello World'); + globalString = 'Something else'.toNSString(); + expect(globalString.toString(), 'Something else'); + globalString = 'Hello World'.toNSString(); }); (Pointer, Pointer) globalObjectRefCountingInner() { final obj1 = NSObject.new1(); - globalNativeObject = obj1; + globalObject = obj1; final obj1raw = obj1.ref.pointer; expect(objectRetainCount(obj1raw), 2); // obj1, and the global variable. final obj2 = NSObject.new1(); - globalNativeObject = obj2; + globalObject = obj2; final obj2raw = obj2.ref.pointer; expect(objectRetainCount(obj2raw), 2); // obj2, and the global variable. expect(objectRetainCount(obj1raw), 1); // Just obj1. @@ -59,28 +60,28 @@ void main() { expect(objectRetainCount(obj2raw), 1); // Just the global variable. expect(objectRetainCount(obj1raw), 0); - globalNativeObject = null; + globalObject = null; expect(objectRetainCount(obj2raw), 0); expect(objectRetainCount(obj1raw), 0); }, skip: !canDoGC); test('Global block', () { - globalNativeBlock = ObjCBlock_Int32_Int32.fromFunction((int x) => x * 10); - expect(globalNativeBlock!(123), 1230); - globalNativeBlock = + globalBlock = ObjCBlock_Int32_Int32.fromFunction((int x) => x * 10); + expect(globalBlock!(123), 1230); + globalBlock = ObjCBlock_Int32_Int32.fromFunction((int x) => x + 1000); - expect(globalNativeBlock!(456), 1456); + expect(globalBlock!(456), 1456); }); (Pointer, Pointer) globalBlockRefCountingInner() { final blk1 = ObjCBlock_Int32_Int32.fromFunction((int x) => x * 10); - globalNativeBlock = blk1; + globalBlock = blk1; final blk1raw = blk1.ref.pointer; expect(blockRetainCount(blk1raw), 2); // blk1, and the global variable. final blk2 = ObjCBlock_Int32_Int32.fromFunction((int x) => x + 1000); - globalNativeBlock = blk2; + globalBlock = blk2; final blk2raw = blk2.ref.pointer; expect(blockRetainCount(blk2raw), 2); // blk2, and the global variable. expect(blockRetainCount(blk1raw), 1); // Just blk1. @@ -97,7 +98,7 @@ void main() { expect(blockRetainCount(blk2raw), 1); // Just the global variable. expect(blockRetainCount(blk1raw), 0); - globalNativeBlock = null; + globalBlock = null; expect(blockRetainCount(blk2raw), 0); expect(blockRetainCount(blk1raw), 0); }, skip: !canDoGC); diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.h b/pkgs/ffigen/test/native_objc_test/global_native_test.h deleted file mode 100644 index 8c60e4989..000000000 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.h +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -#import -#import - -NSString* globalNativeString; -NSObject* _Nullable globalNativeObject; -int32_t (^_Nullable globalNativeBlock)(int32_t); diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.m b/pkgs/ffigen/test/native_objc_test/global_native_test.m deleted file mode 100644 index 32d439e0c..000000000 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.m +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -#import - -#include "global_native_test.h" - -NSString* globalNativeString = @"Hello World"; -NSObject* _Nullable globalNativeObject = nil; -int32_t (^_Nullable globalNativeBlock)(int32_t) = nil; diff --git a/pkgs/ffigen/test/native_objc_test/global_test.dart b/pkgs/ffigen/test/native_objc_test/global_test.dart index 06ba084b1..a875d279e 100644 --- a/pkgs/ffigen/test/native_objc_test/global_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_test.dart @@ -35,6 +35,7 @@ void main() { expect(lib.globalString.toString(), 'Hello World'); lib.globalString = 'Something else'.toNSString(); expect(lib.globalString.toString(), 'Something else'); + lib.globalString = 'Hello World'.toNSString(); }); (Pointer, Pointer) globalObjectRefCountingInner() { From f1c5f43d7020b8ac54fcefb5e8dec0f888ba0e32 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 18 Dec 2024 15:08:42 +1100 Subject: [PATCH 4/8] run whole built/test pipeline 10 times --- .github/workflows/ffigen.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index a5a0cc5f1..ecc312f2a 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -80,10 +80,8 @@ jobs: channel: 'stable' - name: Install dependencies run: flutter pub get && flutter pub get --directory="../objective_c" - - name: Build test dylib and bindings - run: dart test/setup.dart - name: Run VM tests - run: fail_count=0; for i in {1..10}; do dart test || ((fail_count++)); done; if ((fail_count > 0)); then echo "There were $fail_count failures"; exit 1; fi + run: fail_count=0; for i in {1..10}; do dart test/setup.dart && dart test || ((fail_count++)); done; if ((fail_count > 0)); then echo "There were $fail_count failures"; exit 1; fi # - name: Upload coverage # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # with: From ce96aa353d4d8b576155ad2bd473c4327e1da4e0 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 18 Dec 2024 15:45:31 +1100 Subject: [PATCH 5/8] Revert workflow changes --- .github/workflows/ffigen.yml | 218 ++++++++++++++++++----------------- 1 file changed, 110 insertions(+), 108 deletions(-) diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index ecc312f2a..6e1690b92 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -23,52 +23,52 @@ env: jobs: # Check code formatting and static analysis on a single OS (macos). - # analyze: - # runs-on: macos-latest - # defaults: - # run: - # working-directory: pkgs/ffigen/ - # strategy: - # fail-fast: false - # steps: - # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - # with: - # channel: 'stable' - # - id: install - # name: Install dependencies - # run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" - # - name: Check formatting - # run: dart format --output=none --set-exit-if-changed . - # if: always() && steps.install.outcome == 'success' - # - name: Build test dylib and bindings - # run: dart test/setup.dart - # - name: Analyze code - # run: flutter analyze --fatal-infos + analyze: + runs-on: macos-latest + defaults: + run: + working-directory: pkgs/ffigen/ + strategy: + fail-fast: false + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + with: + channel: 'stable' + - id: install + name: Install dependencies + run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Build test dylib and bindings + run: dart test/setup.dart + - name: Analyze code + run: flutter analyze --fatal-infos - # test-linux: - # needs: analyze - # runs-on: ubuntu-22.04 - # defaults: - # run: - # working-directory: pkgs/ffigen/ - # steps: - # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - # with: - # channel: 'stable' - # - name: Install dependencies - # run: flutter pub get - # - name: Install libclang-14-dev - # run: sudo apt-get install libclang-14-dev - # - name: Build test dylib and bindings - # run: dart test/setup.dart - # - name: Run VM tests - # run: dart test + test-linux: + needs: analyze + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: pkgs/ffigen/ + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + with: + channel: 'stable' + - name: Install dependencies + run: flutter pub get + - name: Install libclang-14-dev + run: sudo apt-get install libclang-14-dev + - name: Build test dylib and bindings + run: dart test/setup.dart + - name: Run VM tests + run: dart test # Keep in sync with ffigen_weekly.yaml:test-mac-arm64 test-mac: - # needs: analyze + needs: analyze runs-on: 'macos-latest' defaults: run: @@ -80,57 +80,59 @@ jobs: channel: 'stable' - name: Install dependencies run: flutter pub get && flutter pub get --directory="../objective_c" - - name: Run VM tests - run: fail_count=0; for i in {1..10}; do dart test/setup.dart && dart test || ((fail_count++)); done; if ((fail_count > 0)); then echo "There were $fail_count failures"; exit 1; fi - # - name: Upload coverage - # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 - # with: - # flag-name: ffigen - # github-token: ${{ secrets.GITHUB_TOKEN }} - # parallel: true - # path-to-lcov: pkgs/ffigen/coverage/lcov.info - # - name: Upload coverage - # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 - # with: - # carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" - # github-token: ${{ secrets.GITHUB_TOKEN }} - # parallel-finished: true + - name: Build test dylib and bindings + run: dart test/setup.dart + - name: Run VM tests and collect coverage + run: dart run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c + - name: Upload coverage + uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 + with: + flag-name: ffigen + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel: true + path-to-lcov: pkgs/ffigen/coverage/lcov.info + - name: Upload coverage + uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 + with: + carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true - # test-mac-flutter: - # needs: analyze - # runs-on: 'macos-latest' - # defaults: - # run: - # working-directory: pkgs/ffigen/ - # steps: - # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - # with: - # channel: 'stable' - # - name: Install dependencies - # run: flutter pub get && flutter pub get --directory="../objective_c" - # - name: Build test dylib and bindings - # run: dart test/setup.dart --main-thread-dispatcher - # - name: Run Flutter tests - # run: flutter test + test-mac-flutter: + needs: analyze + runs-on: 'macos-latest' + defaults: + run: + working-directory: pkgs/ffigen/ + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + with: + channel: 'stable' + - name: Install dependencies + run: flutter pub get && flutter pub get --directory="../objective_c" + - name: Build test dylib and bindings + run: dart test/setup.dart --main-thread-dispatcher + - name: Run Flutter tests + run: flutter test - # test-windows: - # needs: analyze - # runs-on: windows-latest - # defaults: - # run: - # working-directory: pkgs/ffigen/ - # steps: - # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 - # with: - # channel: 'stable' - # - name: Install dependencies - # run: flutter pub get - # - name: Build test dylib and bindings - # run: dart test/setup.dart - # - name: Run VM tests - # run: dart test + test-windows: + needs: analyze + runs-on: windows-latest + defaults: + run: + working-directory: pkgs/ffigen/ + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + with: + channel: 'stable' + - name: Install dependencies + run: flutter pub get + - name: Build test dylib and bindings + run: dart test/setup.dart + - name: Run VM tests + run: dart test # Sanity check the latest `flutter create --template plugin_ffi`. # This will break if we change the Flutter template or the generated code. @@ -142,20 +144,20 @@ jobs: # merge PRs. # Running this sanity check on one OS should be sufficient. Chosing Windows # because it is the most likely to break. - # test-windows-flutter: - # needs: analyze - # runs-on: windows-latest - # defaults: - # run: - # working-directory: pkgs/ffigen/ - # steps: - # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - # with: - # channel: "master" - # - name: Install dependencies - # run: flutter pub get - # - name: Build test dylib and bindings - # run: dart test/setup.dart - # - name: Run VM tests - # run: flutter pub run test test_flutter/ + test-windows-flutter: + needs: analyze + runs-on: windows-latest + defaults: + run: + working-directory: pkgs/ffigen/ + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + with: + channel: "master" + - name: Install dependencies + run: flutter pub get + - name: Build test dylib and bindings + run: dart test/setup.dart + - name: Run VM tests + run: flutter pub run test test_flutter/ From 04cf6d41f38891543c8d943e6823a12a89b67270 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 18 Dec 2024 15:54:02 +1100 Subject: [PATCH 6/8] fmt --- pkgs/ffigen/test/native_objc_test/global_native_test.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index 5b797a22f..8e7c8088d 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -68,8 +68,7 @@ void main() { test('Global block', () { globalBlock = ObjCBlock_Int32_Int32.fromFunction((int x) => x * 10); expect(globalBlock!(123), 1230); - globalBlock = - ObjCBlock_Int32_Int32.fromFunction((int x) => x + 1000); + globalBlock = ObjCBlock_Int32_Int32.fromFunction((int x) => x + 1000); expect(globalBlock!(456), 1456); }); From e10f412f55b7deb94d3ea69dec50b1aef376b881 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 19 Dec 2024 13:42:29 +1100 Subject: [PATCH 7/8] Try again --- .github/workflows/ffigen.yml | 218 +++++++++--------- .../native_objc_test/global_native_test.dart | 29 +-- .../test/native_objc_test/global_test.dart | 29 +-- 3 files changed, 122 insertions(+), 154 deletions(-) diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index 6e1690b92..382d975ab 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -23,52 +23,52 @@ env: jobs: # Check code formatting and static analysis on a single OS (macos). - analyze: - runs-on: macos-latest - defaults: - run: - working-directory: pkgs/ffigen/ - strategy: - fail-fast: false - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - with: - channel: 'stable' - - id: install - name: Install dependencies - run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" - - name: Check formatting - run: dart format --output=none --set-exit-if-changed . - if: always() && steps.install.outcome == 'success' - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Analyze code - run: flutter analyze --fatal-infos + # analyze: + # runs-on: macos-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # strategy: + # fail-fast: false + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + # with: + # channel: 'stable' + # - id: install + # name: Install dependencies + # run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c" + # - name: Check formatting + # run: dart format --output=none --set-exit-if-changed . + # if: always() && steps.install.outcome == 'success' + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Analyze code + # run: flutter analyze --fatal-infos - test-linux: - needs: analyze - runs-on: ubuntu-22.04 - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get - - name: Install libclang-14-dev - run: sudo apt-get install libclang-14-dev - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test + # test-linux: + # needs: analyze + # runs-on: ubuntu-22.04 + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get + # - name: Install libclang-14-dev + # run: sudo apt-get install libclang-14-dev + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: dart test # Keep in sync with ffigen_weekly.yaml:test-mac-arm64 test-mac: - needs: analyze + # needs: analyze runs-on: 'macos-latest' defaults: run: @@ -80,59 +80,57 @@ jobs: channel: 'stable' - name: Install dependencies run: flutter pub get && flutter pub get --directory="../objective_c" - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests and collect coverage - run: dart run coverage:test_with_coverage --scope-output=ffigen --scope-output=objective_c - - name: Upload coverage - uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 - with: - flag-name: ffigen - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel: true - path-to-lcov: pkgs/ffigen/coverage/lcov.info - - name: Upload coverage - uses: coverallsapp/github-action@cfd0633edbd2411b532b808ba7a8b5e04f76d2c8 - with: - carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true + - name: Run VM tests + run: fail_count=0; for i in {1..10}; do (dart test/setup.dart && dart test) || ((fail_count++)); done; if ((fail_count > 0)); then echo "There were $fail_count failures"; exit 1; fi + # - name: Upload coverage + # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 + # with: + # flag-name: ffigen + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel: true + # path-to-lcov: pkgs/ffigen/coverage/lcov.info + # - name: Upload coverage + # uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 + # with: + # carryforward: "ffigen,jni,jnigen,native_assets_builder_macos,native_assets_builder_ubuntu,native_assets_builder_windows,native_assets_cli_macos,native_assets_cli_ubuntu,native_assets_cli_windows,native_toolchain_c_macos,native_toolchain_c_ubuntu,native_toolchain_c_windows,objective_c,swift2objc" + # github-token: ${{ secrets.GITHUB_TOKEN }} + # parallel-finished: true - test-mac-flutter: - needs: analyze - runs-on: 'macos-latest' - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get && flutter pub get --directory="../objective_c" - - name: Build test dylib and bindings - run: dart test/setup.dart --main-thread-dispatcher - - name: Run Flutter tests - run: flutter test + # test-mac-flutter: + # needs: analyze + # runs-on: 'macos-latest' + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get && flutter pub get --directory="../objective_c" + # - name: Build test dylib and bindings + # run: dart test/setup.dart --main-thread-dispatcher + # - name: Run Flutter tests + # run: flutter test - test-windows: - needs: analyze - runs-on: windows-latest - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - with: - channel: 'stable' - - name: Install dependencies - run: flutter pub get - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: dart test + # test-windows: + # needs: analyze + # runs-on: windows-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + # - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 + # with: + # channel: 'stable' + # - name: Install dependencies + # run: flutter pub get + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: dart test # Sanity check the latest `flutter create --template plugin_ffi`. # This will break if we change the Flutter template or the generated code. @@ -144,20 +142,20 @@ jobs: # merge PRs. # Running this sanity check on one OS should be sufficient. Chosing Windows # because it is the most likely to break. - test-windows-flutter: - needs: analyze - runs-on: windows-latest - defaults: - run: - working-directory: pkgs/ffigen/ - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 - with: - channel: "master" - - name: Install dependencies - run: flutter pub get - - name: Build test dylib and bindings - run: dart test/setup.dart - - name: Run VM tests - run: flutter pub run test test_flutter/ + # test-windows-flutter: + # needs: analyze + # runs-on: windows-latest + # defaults: + # run: + # working-directory: pkgs/ffigen/ + # steps: + # - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + # - uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3 + # with: + # channel: "master" + # - name: Install dependencies + # run: flutter pub get + # - name: Build test dylib and bindings + # run: dart test/setup.dart + # - name: Run VM tests + # run: flutter pub run test test_flutter/ diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index 8e7c8088d..2f1d0b9d1 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -36,32 +36,17 @@ void main() { globalString = 'Hello World'.toNSString(); }); - (Pointer, Pointer) globalObjectRefCountingInner() { - final obj1 = NSObject.new1(); - globalObject = obj1; - final obj1raw = obj1.ref.pointer; - expect(objectRetainCount(obj1raw), 2); // obj1, and the global variable. - - final obj2 = NSObject.new1(); - globalObject = obj2; - final obj2raw = obj2.ref.pointer; - expect(objectRetainCount(obj2raw), 2); // obj2, and the global variable. - expect(objectRetainCount(obj1raw), 1); // Just obj1. - expect(obj1, isNotNull); // Force obj1 to stay in scope. - expect(obj2, isNotNull); // Force obj2 to stay in scope. - - return (obj1raw, obj2raw); + Pointer globalObjectRefCountingInner() { + globalObject = NSObject.new1(); + final obj1raw = globalObject.ref.pointer; + expect(objectRetainCount(obj1raw), greaterThan(0)); + return obj1raw; } test('Global object ref counting', () { - final (obj1raw, obj2raw) = globalObjectRefCountingInner(); - doGC(); - - expect(objectRetainCount(obj2raw), 1); // Just the global variable. - expect(objectRetainCount(obj1raw), 0); - + final obj1raw = globalObjectRefCountingInner(); globalObject = null; - expect(objectRetainCount(obj2raw), 0); + doGC(); expect(objectRetainCount(obj1raw), 0); }, skip: !canDoGC); diff --git a/pkgs/ffigen/test/native_objc_test/global_test.dart b/pkgs/ffigen/test/native_objc_test/global_test.dart index a875d279e..0a2527f29 100644 --- a/pkgs/ffigen/test/native_objc_test/global_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_test.dart @@ -38,32 +38,17 @@ void main() { lib.globalString = 'Hello World'.toNSString(); }); - (Pointer, Pointer) globalObjectRefCountingInner() { - final obj1 = NSObject.new1(); - lib.globalObject = obj1; - final obj1raw = obj1.ref.pointer; - expect(objectRetainCount(obj1raw), 2); // obj1, and the global variable. - - final obj2 = NSObject.new1(); - lib.globalObject = obj2; - final obj2raw = obj2.ref.pointer; - expect(objectRetainCount(obj2raw), 2); // obj2, and the global variable. - expect(objectRetainCount(obj1raw), 1); // Just obj1. - expect(obj1, isNotNull); // Force obj1 to stay in scope. - expect(obj2, isNotNull); // Force obj2 to stay in scope. - - return (obj1raw, obj2raw); + Pointer globalObjectRefCountingInner() { + lib.globalObject = NSObject.new1(); + final obj1raw = lib.globalObject.ref.pointer; + expect(objectRetainCount(obj1raw), greaterThan(0)); + return obj1raw; } test('Global object ref counting', () { - final (obj1raw, obj2raw) = globalObjectRefCountingInner(); - doGC(); - - expect(objectRetainCount(obj2raw), 1); // Just the global variable. - expect(objectRetainCount(obj1raw), 0); - + final obj1raw = globalObjectRefCountingInner(); lib.globalObject = null; - expect(objectRetainCount(obj2raw), 0); + doGC(); expect(objectRetainCount(obj1raw), 0); }, skip: !canDoGC); From 02de1893e4ff30d71879ce9723769045c8652721 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 19 Dec 2024 14:24:13 +1100 Subject: [PATCH 8/8] fix --- pkgs/ffigen/test/native_objc_test/global_native_test.dart | 2 +- pkgs/ffigen/test/native_objc_test/global_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/ffigen/test/native_objc_test/global_native_test.dart b/pkgs/ffigen/test/native_objc_test/global_native_test.dart index 2f1d0b9d1..7a5949a94 100644 --- a/pkgs/ffigen/test/native_objc_test/global_native_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_native_test.dart @@ -38,7 +38,7 @@ void main() { Pointer globalObjectRefCountingInner() { globalObject = NSObject.new1(); - final obj1raw = globalObject.ref.pointer; + final obj1raw = globalObject!.ref.pointer; expect(objectRetainCount(obj1raw), greaterThan(0)); return obj1raw; } diff --git a/pkgs/ffigen/test/native_objc_test/global_test.dart b/pkgs/ffigen/test/native_objc_test/global_test.dart index 0a2527f29..4bdd3180e 100644 --- a/pkgs/ffigen/test/native_objc_test/global_test.dart +++ b/pkgs/ffigen/test/native_objc_test/global_test.dart @@ -40,7 +40,7 @@ void main() { Pointer globalObjectRefCountingInner() { lib.globalObject = NSObject.new1(); - final obj1raw = lib.globalObject.ref.pointer; + final obj1raw = lib.globalObject!.ref.pointer; expect(objectRetainCount(obj1raw), greaterThan(0)); return obj1raw; }