From a0949f55a0637b1f35094b51e3cad9a5acac5b9d Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 5 Dec 2023 17:54:50 +0100 Subject: [PATCH] Workflow cleanups (#846) * Add pubspec overrides * Remove tool to change deps * Fix override * Add health workflow * Do not test breaking changes * Remove health workflow * Switch to dart script * Fix path * Add newlines * Fixes --- .github/workflows/native.yaml | 7 +-- .../pubspec_overrides.yaml | 3 ++ .../cyclic_package_1/pubspec_overrides.yaml | 3 ++ .../cyclic_package_2/pubspec_overrides.yaml | 3 ++ .../test/data/manifest.yaml | 10 ++++ .../test/data/native_add/manifest.yaml | 1 + .../data/native_add/pubspec_overrides.yaml | 5 ++ .../pubspec_overrides.yaml | 5 ++ .../native_subtract/pubspec_overrides.yaml | 5 ++ .../pubspec_overrides.yaml | 3 ++ .../pubspec_overrides.yaml | 3 ++ .../wrong_build_output/pubspec_overrides.yaml | 3 ++ .../pubspec_overrides.yaml | 3 ++ .../pubspec_overrides.yaml | 3 ++ .../pubspec_overrides.yaml | 3 ++ pkgs/native_assets_builder/test/helpers.dart | 13 +++-- .../native_add_library/pubspec_overrides.yaml | 5 ++ .../native_toolchain_c/pubspec_overrides.yaml | 3 ++ tools/.gitignore | 9 ---- tools/bin/change_dependencies.dart | 52 ------------------- tools/delete_pubspec_overrides.dart | 6 +++ tools/pubspec.yaml | 14 ----- 22 files changed, 78 insertions(+), 84 deletions(-) create mode 100644 pkgs/native_assets_builder/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/native_add/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/native_add_add_source/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/native_subtract/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/package_with_metadata/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/wrong_build_output/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec_overrides.yaml create mode 100644 pkgs/native_assets_cli/example/native_add_library/pubspec_overrides.yaml create mode 100644 pkgs/native_toolchain_c/pubspec_overrides.yaml delete mode 100644 tools/.gitignore delete mode 100644 tools/bin/change_dependencies.dart create mode 100644 tools/delete_pubspec_overrides.dart delete mode 100644 tools/pubspec.yaml diff --git a/.github/workflows/native.yaml b/.github/workflows/native.yaml index 61ffdc247..3b6f0d613 100644 --- a/.github/workflows/native.yaml +++ b/.github/workflows/native.yaml @@ -63,11 +63,8 @@ jobs: ndk-version: r26b if: ${{ matrix.sdk == 'stable' }} - - run: dart pub get -C ../../tools/ - if: ${{ matrix.dependencies == 'path' }} - - - run: dart ../../tools/bin/change_dependencies.dart - if: ${{ matrix.dependencies == 'path' }} + - run: dart run ../../tools/delete_pubspec_overrides.dart + if: ${{ matrix.dependencies == 'published' }} - run: dart pub get diff --git a/pkgs/native_assets_builder/pubspec_overrides.yaml b/pkgs/native_assets_builder/pubspec_overrides.yaml new file mode 100644 index 000000000..0c523c6f3 --- /dev/null +++ b/pkgs/native_assets_builder/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/cyclic_package_1/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/cyclic_package_2/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/manifest.yaml b/pkgs/native_assets_builder/test/data/manifest.yaml index 04649be33..7ae8b9e14 100644 --- a/pkgs/native_assets_builder/test/data/manifest.yaml +++ b/pkgs/native_assets_builder/test/data/manifest.yaml @@ -2,8 +2,10 @@ # a completely clean setup. - cyclic_package_1/build.dart - cyclic_package_1/pubspec.yaml +- cyclic_package_1/pubspec_overrides.yaml - cyclic_package_2/build.dart - cyclic_package_2/pubspec.yaml +- cyclic_package_2/pubspec_overrides.yaml - dart_app/bin/dart_app.dart - dart_app/pubspec.yaml - native_add/build.dart @@ -12,6 +14,7 @@ - native_add/lib/src/native_add_bindings_generated.dart - native_add/lib/src/native_add.dart - native_add/pubspec.yaml +- native_add/pubspec_overrides.yaml - native_add/src/native_add.c - native_add/src/native_add.h - native_add/test/native_add_test.dart @@ -21,19 +24,26 @@ - native_subtract/lib/src/native_subtract_bindings_generated.dart - native_subtract/lib/src/native_subtract.dart - native_subtract/pubspec.yaml +- native_subtract/pubspec_overrides.yaml - native_subtract/src/native_subtract.c - native_subtract/src/native_subtract.h - package_reading_metadata/build.dart - package_reading_metadata/pubspec.yaml +- package_reading_metadata/pubspec_overrides.yaml - package_with_metadata/build.dart - package_with_metadata/pubspec.yaml +- package_with_metadata/pubspec_overrides.yaml - some_dev_dep/bin/some_dev_dep.dart - some_dev_dep/pubspec.yaml - wrong_build_output/build.dart - wrong_build_output/pubspec.yaml +- wrong_build_output/pubspec_overrides.yaml - wrong_build_output_2/build.dart - wrong_build_output_2/pubspec.yaml +- wrong_build_output_2/pubspec_overrides.yaml - wrong_build_output_3/build.dart - wrong_build_output_3/pubspec.yaml +- wrong_build_output_3/pubspec_overrides.yaml - wrong_namespace_asset/build.dart - wrong_namespace_asset/pubspec.yaml +- wrong_namespace_asset/pubspec_overrides.yaml diff --git a/pkgs/native_assets_builder/test/data/native_add/manifest.yaml b/pkgs/native_assets_builder/test/data/native_add/manifest.yaml index e922db8c1..8360a6bd6 100644 --- a/pkgs/native_assets_builder/test/data/native_add/manifest.yaml +++ b/pkgs/native_assets_builder/test/data/native_add/manifest.yaml @@ -4,6 +4,7 @@ - lib/src/native_add_bindings_generated.dart - lib/src/native_add.dart - pubspec.yaml +- pubspec_overrides.yaml - src/native_add.c - src/native_add.h - test/native_add_test.dart diff --git a/pkgs/native_assets_builder/test/data/native_add/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/native_add/pubspec_overrides.yaml new file mode 100644 index 000000000..8e850de76 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/native_add/pubspec_overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ + native_toolchain_c: + path: ../../../../native_toolchain_c/ diff --git a/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec_overrides.yaml new file mode 100644 index 000000000..8e850de76 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/native_add_add_source/pubspec_overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ + native_toolchain_c: + path: ../../../../native_toolchain_c/ diff --git a/pkgs/native_assets_builder/test/data/native_subtract/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/native_subtract/pubspec_overrides.yaml new file mode 100644 index 000000000..8e850de76 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/native_subtract/pubspec_overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ + native_toolchain_c: + path: ../../../../native_toolchain_c/ diff --git a/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/package_reading_metadata/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/package_with_metadata/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/wrong_build_output/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/wrong_build_output_2/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/wrong_build_output_3/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec_overrides.yaml b/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec_overrides.yaml new file mode 100644 index 000000000..c18eed080 --- /dev/null +++ b/pkgs/native_assets_builder/test/data/wrong_namespace_asset/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../../../../native_assets_cli/ diff --git a/pkgs/native_assets_builder/test/helpers.dart b/pkgs/native_assets_builder/test/helpers.dart index 522aa97f9..56d310b24 100644 --- a/pkgs/native_assets_builder/test/helpers.dart +++ b/pkgs/native_assets_builder/test/helpers.dart @@ -123,10 +123,15 @@ Future copyTestProjects({ for (final path in manifestYaml.contents as YamlList) Uri(path: path as String) ]; - final filesToCopy = - manifest.where((e) => e.pathSegments.last != 'pubspec.yaml').toList(); - final filesToModify = - manifest.where((e) => e.pathSegments.last == 'pubspec.yaml').toList(); + final filesToCopy = manifest + .where((e) => !(e.pathSegments.last.startsWith('pubspec') && + e.pathSegments.last.endsWith('.yaml'))) + .toList(); + final filesToModify = manifest + .where((e) => + e.pathSegments.last.startsWith('pubspec') && + e.pathSegments.last.endsWith('.yaml')) + .toList(); for (final pathToCopy in filesToCopy) { final sourceFile = File.fromUri(sourceUri.resolveUri(pathToCopy)); diff --git a/pkgs/native_assets_cli/example/native_add_library/pubspec_overrides.yaml b/pkgs/native_assets_cli/example/native_add_library/pubspec_overrides.yaml new file mode 100644 index 000000000..272d61ecc --- /dev/null +++ b/pkgs/native_assets_cli/example/native_add_library/pubspec_overrides.yaml @@ -0,0 +1,5 @@ +dependency_overrides: + native_assets_cli: + path: ../../../native_assets_cli/ + native_toolchain_c: + path: ../../../native_toolchain_c/ diff --git a/pkgs/native_toolchain_c/pubspec_overrides.yaml b/pkgs/native_toolchain_c/pubspec_overrides.yaml new file mode 100644 index 000000000..0c523c6f3 --- /dev/null +++ b/pkgs/native_toolchain_c/pubspec_overrides.yaml @@ -0,0 +1,3 @@ +dependency_overrides: + native_assets_cli: + path: ../native_assets_cli/ diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 0b3e7bc22..000000000 --- a/tools/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Please keep consistent with .pubignore. - -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ - -# Avoid committing pubspec.lock for library packages; see -# https://dart.dev/guides/libraries/private-files#pubspeclock. -pubspec.lock diff --git a/tools/bin/change_dependencies.dart b/tools/bin/change_dependencies.dart deleted file mode 100644 index dd7b93ee4..000000000 --- a/tools/bin/change_dependencies.dart +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2023, 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 'dart:io'; - -import 'package:glob/glob.dart'; -import 'package:glob/list_local_fs.dart'; -import 'package:yaml_edit/yaml_edit.dart'; -import 'package:yaml/yaml.dart'; - -void main(List args) { - final root = Platform.script.resolve('../../'); - final glob = Glob('**pubspec.yaml'); - final files = glob.listSync(root: root.toFilePath()).whereType(); - for (final file in files) { - final yamlEditor = YamlEditor(file.readAsStringSync()); - final yaml = yamlEditor.parseAt([]); - if (yaml is! YamlMap) { - continue; - } - final dependencies = yaml['dependencies']; - if (dependencies is! YamlMap) { - continue; - } - for (final package in dependencies.keys) { - if (!packagesToPin.contains(package)) { - continue; - } - yamlEditor.update( - ['dependencies', package], - { - // Some packages contain full test projects that are copied in unit - // tests. So, use absolute paths. - 'path': - root.resolve('pkgs/$package/').toFilePath().replaceAll(r'\', '/'), - }, - ); - } - if (yamlEditor.edits.isEmpty) { - continue; - } - yamlEditor.update(['publish_to'], 'none'); - file.writeAsStringSync(yamlEditor.toString()); - } -} - -const packagesToPin = { - 'native_assets_builder', - 'native_assets_cli', - 'native_toolchain_c', -}; diff --git a/tools/delete_pubspec_overrides.dart b/tools/delete_pubspec_overrides.dart new file mode 100644 index 000000000..5ae2ff795 --- /dev/null +++ b/tools/delete_pubspec_overrides.dart @@ -0,0 +1,6 @@ +import 'dart:io'; + +void main(List arguments) => Directory.current + .list(recursive: true) + .where((f) => f.path.endsWith('pubspec_overrides.yaml')) + .forEach((f) => f.deleteSync()); diff --git a/tools/pubspec.yaml b/tools/pubspec.yaml deleted file mode 100644 index 396d15afe..000000000 --- a/tools/pubspec.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: tools_for_dart_lang_native -description: >- - Some helper scripts for https://github.com/dart-lang/native. -version: 0.1.0 -repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder - -publish_to: none - -environment: - sdk: '>=3.0.0 <4.0.0' - -dependencies: - glob: ^2.1.2 - yaml_edit: ^2.1.1