| name: ffigen | |
| on: | |
| # Run on PRs and pushes to the default branch, in either the ffigen directory, | |
| # or the objective_c directory. | |
| push: | |
| # No `branches:` to enable stacked PRs on GitHub. | |
| paths: | |
| - '.github/workflows/ffigen.yml' | |
| - 'pkgs/ffigen/**' | |
| - 'pkgs/objective_c/**' | |
| - 'pkgs/snippet_tool/**' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - '.github/workflows/ffigen.yml' | |
| - 'pkgs/ffigen/**' | |
| - 'pkgs/objective_c/**' | |
| - 'pkgs/snippet_tool/**' | |
| schedule: | |
| - cron: "0 0 * * 0" | |
| env: | |
| PUB_ENVIRONMENT: bot.github | |
| jobs: | |
| # Check code formatting and static analysis on a single OS (macos). | |
| analyze: | |
| runs-on: macos-latest | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - id: install | |
| name: Install dependencies | |
| run: dart pub get && dart pub get --directory="example/shared_bindings" && dart pub get --directory="../objective_c" && dart pub get --directory="example/add" && dart pub get --directory="../.." | |
| - name: Check formatting | |
| run: dart format --output=none --set-exit-if-changed . | |
| if: always() && steps.install.outcome == 'success' | |
| - name: Analyze code | |
| run: dart analyze --fatal-infos | |
| - name: Check snippets | |
| run: dart run ../snippet_tool/bin/snippet_tool.dart --set-exit-if-changed . | |
| test-linux: | |
| needs: analyze | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: dart pub get && flutter pub get --directory="../jni" | |
| - name: Install libclang-18-dev | |
| run: sudo apt-get update && sudo apt-get install libclang-18-dev | |
| - name: Run VM tests | |
| run: dart test | |
| - name: Generate package:jni bindings | |
| run: dart --enable-asserts run tool/generate_ffi_bindings.dart | |
| working-directory: pkgs/jni/ | |
| test-mac: | |
| needs: analyze | |
| runs-on: macos-latest | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" | |
| - name: Install clang-format | |
| uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 | |
| with: | |
| brew: clang-format | |
| - name: Install coverage | |
| run: dart pub global activate coverage | |
| - name: Run VM tests and collect coverage | |
| run: dart test --coverage-path=./coverage/lcov.info | |
| - name: Generate package:jni bindings | |
| run: dart --enable-asserts run tool/generate_ffi_bindings.dart | |
| working-directory: pkgs/jni/ | |
| - name: Upload coverage | |
| uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 | |
| with: | |
| files: pkgs/ffigen/coverage/lcov.info | |
| flags: ffigen | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| test-mac-intel: | |
| needs: analyze | |
| runs-on: macos-15-intel | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" | |
| - name: Install clang-format | |
| uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30 | |
| with: | |
| brew: clang-format | |
| - name: Run VM tests | |
| run: dart test | |
| test-mac-flutter: | |
| needs: analyze | |
| runs-on: 'macos-latest' | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: dart pub get && dart pub get --directory="../objective_c" | |
| - name: Run Flutter tests | |
| run: dart test | |
| # TODO(https://github.com/dart-lang/native/issues/3366): Reenable this. | |
| # test-mac-aot: | |
| # needs: analyze | |
| # runs-on: 'macos-latest' | |
| # permissions: | |
| # contents: read | |
| # defaults: | |
| # run: | |
| # working-directory: pkgs/ffigen/ | |
| # steps: | |
| # - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| # with: | |
| # persist-credentials: false | |
| # - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| # with: | |
| # channel: stable | |
| # - name: Install dependencies | |
| # run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni" | |
| # - name: Build dylibs | |
| # run: dart test --name non_existent_test || true | |
| # - name: Copy dylibs to expected location | |
| # run: cp $GITHUB_WORKSPACE/pkgs/ffigen/.dart_tool/hooks_runner/shared/*/build/*/*.dylib $GITHUB_WORKSPACE/pkgs/ffigen/.dart_tool/lib | |
| # - name: Run all_tests in AOT | |
| # run: > | |
| # PACKAGE_ROOT=$GITHUB_WORKSPACE/pkgs/ffigen | |
| # DYLD_INSERT_LIBRARIES=$(ls $GITHUB_WORKSPACE/pkgs/ffigen/.dart_tool/lib/*.dylib | paste -sd ':' -) | |
| # dart test -c exe | |
| test-windows: | |
| needs: analyze | |
| runs-on: windows-latest | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: dart pub get && flutter pub get --directory="../jni" | |
| - name: Run VM tests | |
| run: dart test | |
| - name: Generate package:jni bindings | |
| run: dart --enable-asserts run tool/generate_ffi_bindings.dart | |
| working-directory: pkgs/jni/ | |
| # Sanity check the latest `flutter create --template plugin_ffi`. | |
| # This will break if we change the Flutter template or the generated code. | |
| # But, getting libclang on the LUCI infrastructure has proven to be | |
| # non-trivial. See discussion on | |
| # https://github.com/flutter/flutter/issues/105513. | |
| # If we need to change the generated code, we should temporarily disable this | |
| # test, or temporarily disable the requirement for all bots to be green to | |
| # 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 | |
| permissions: | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: pkgs/ffigen/ | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 | |
| with: | |
| persist-credentials: false | |
| - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 | |
| with: | |
| channel: stable | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Run VM tests | |
| run: dart test test_flutter/ |