From 3c2472946994b5a16249b8eca02cc4421572485c Mon Sep 17 00:00:00 2001 From: Halil Durmus Date: Wed, 24 Jul 2024 16:26:41 +0300 Subject: [PATCH] Add workflow to check code generation --- .github/workflows/code_generation.yml | 49 +++++++++++++++++++ .github/workflows/generator.yml | 2 - examples/explorer/pubspec_overrides.yaml | 2 +- .../pubspec_overrides.yaml | 2 +- examples/task_manager/pubspec_overrides.yaml | 2 +- packages/generator/bin/generate.dart | 2 +- packages/generator/pubspec_overrides.yaml | 2 +- .../test/generator_neutrality_test.dart | 17 ------- 8 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/code_generation.yml delete mode 100644 packages/generator/test/generator_neutrality_test.dart diff --git a/.github/workflows/code_generation.yml b/.github/workflows/code_generation.yml new file mode 100644 index 0000000000..3b7fd7998c --- /dev/null +++ b/.github/workflows/code_generation.yml @@ -0,0 +1,49 @@ +name: Check Code Generation + +on: + pull_request: + branches: [main] + paths: + - '.github/workflows/code_generation.yml' + - 'packages/generator/bin/**' + - 'packages/generator/lib/**' + - 'packages/generator/analysis_options.yaml' + - 'packages/generator/pubspec.yaml' + push: + branches: [main] + paths: + - '.github/workflows/code_generation.yml' + - 'packages/generator/bin/**' + - 'packages/generator/lib/**' + - 'packages/generator/analysis_options.yaml' + - 'packages/generator/pubspec.yaml' + +jobs: + check_generation: + runs-on: windows-2019 + steps: + - name: 📚 Git Checkout + uses: actions/checkout@v4 + + - name: 🎯 Setup Dart + uses: dart-lang/setup-dart@v1 + + - name: 📦 Install Workspace Dependencies + run: dart pub get + + - name: 📦 Install package:win32 Dependencies + run: dart pub get + working-directory: packages/win32 + + - name: 📦 Install package:generator Dependencies + run: dart pub get + working-directory: packages/generator + + - name: 🛠️ Install Melos + run: dart pub global activate melos + + - name: 🚀 Run Code Generation + run: dart pub run melos run generate + + - name: 🔍 Verify Code Generation + run: git diff --exit-code diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml index a1a3e3d99a..cfe6475e87 100644 --- a/.github/workflows/generator.yml +++ b/.github/workflows/generator.yml @@ -45,8 +45,6 @@ jobs: sdk: beta - os: windows-2019 sdk: stable - - os: ubuntu-latest - sdk: stable uses: halildurmus/halildurmus/.github/workflows/dart_package.yml@main with: diff --git a/examples/explorer/pubspec_overrides.yaml b/examples/explorer/pubspec_overrides.yaml index ad2bd14b0a..7383a29671 100644 --- a/examples/explorer/pubspec_overrides.yaml +++ b/examples/explorer/pubspec_overrides.yaml @@ -1,4 +1,4 @@ # melos_managed_dependency_overrides: win32 dependency_overrides: win32: - path: ..\\..\\packages\\win32 + path: ../../packages/win32 diff --git a/examples/service_manager_cli/pubspec_overrides.yaml b/examples/service_manager_cli/pubspec_overrides.yaml index ad2bd14b0a..7383a29671 100644 --- a/examples/service_manager_cli/pubspec_overrides.yaml +++ b/examples/service_manager_cli/pubspec_overrides.yaml @@ -1,4 +1,4 @@ # melos_managed_dependency_overrides: win32 dependency_overrides: win32: - path: ..\\..\\packages\\win32 + path: ../../packages/win32 diff --git a/examples/task_manager/pubspec_overrides.yaml b/examples/task_manager/pubspec_overrides.yaml index ad2bd14b0a..7383a29671 100644 --- a/examples/task_manager/pubspec_overrides.yaml +++ b/examples/task_manager/pubspec_overrides.yaml @@ -1,4 +1,4 @@ # melos_managed_dependency_overrides: win32 dependency_overrides: win32: - path: ..\\..\\packages\\win32 + path: ../../packages/win32 diff --git a/packages/generator/bin/generate.dart b/packages/generator/bin/generate.dart index d71a472453..2c178f11ad 100644 --- a/packages/generator/bin/generate.dart +++ b/packages/generator/bin/generate.dart @@ -275,7 +275,7 @@ void main() async { print('Generating FFI function bindings...'); generateFunctions([wdkScope, win32Scope], functionsToGenerate); - print('Generating COM interfaces and tests...'); + print('Generating COM interfaces...'); final comTypesToGenerate = loadMap('com_types.json'); saveMap(comTypesToGenerate, 'com_types.json'); generateComApis(win32Scope, comTypesToGenerate); diff --git a/packages/generator/pubspec_overrides.yaml b/packages/generator/pubspec_overrides.yaml index 0092be7faf..b73c5f37c4 100644 --- a/packages/generator/pubspec_overrides.yaml +++ b/packages/generator/pubspec_overrides.yaml @@ -1,4 +1,4 @@ # melos_managed_dependency_overrides: win32 dependency_overrides: win32: - path: ..\\win32 + path: ../win32 diff --git a/packages/generator/test/generator_neutrality_test.dart b/packages/generator/test/generator_neutrality_test.dart deleted file mode 100644 index 59f4786b64..0000000000 --- a/packages/generator/test/generator_neutrality_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'dart:ffi'; - -import 'package:ffi/ffi.dart'; -import 'package:test/test.dart'; -import 'package:win32/win32.dart'; - -// This test prevents CI from failing on other platforms (GitHub Actions fails -// unless at least one test is run successfully.) -void main() { - test('Neutral test to give non-Windows platforms something to chew on', () { - final point = calloc() - ..ref.x = 0x10 - ..ref.y = 0x7F; - expect(point.ref.x + point.ref.y, equals(0x8F)); - free(point); - }); -}