From 03c2439d8bb5699b03fba8333db72949b2ea1547 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 03:06:06 +0100 Subject: [PATCH 01/28] Converge melos usage and CI scripts * move all scripts to melos and make them available for usage locally * automatically generation coverage information for all Dart tests (vm, chrome, firefox) * print coverage results to CLI for stable SDK --- .github/workflows/publish.yml | 2 +- .github/workflows/tests.yml | 38 ++++++---- .gitignore | 25 +------ dio/.gitignore | 2 + dio/dart_test.yaml | 2 + melos.yaml | 83 ++++++++++++++++++++++ plugins/compatibility_layer/.gitignore | 2 + plugins/compatibility_layer/dart_test.yaml | 3 +- plugins/cookie_manager/.gitignore | 43 +---------- plugins/cookie_manager/dart_test.yaml | 3 +- plugins/http2_adapter/.gitignore | 43 +---------- plugins/http2_adapter/dart_test.yaml | 4 ++ plugins/native_dio_adapter/.gitignore | 2 + scripts/dart_test.sh | 33 --------- 14 files changed, 128 insertions(+), 157 deletions(-) delete mode 100755 scripts/dart_test.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6a3b63504..2a56f4ee5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: if: github.event.issue.number == 1633 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: token: ${{ secrets.CFUG_PUBLISHER }} - uses: dart-lang/setup-dart@v1.3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb0482c90..3d65d6c81 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,9 +25,11 @@ jobs: fail-fast: false matrix: sdk: [ min, stable, beta ] + env: + TEST_PRESET: all steps: - - uses: actions/checkout@v3 - - uses: subosito/flutter-action@v2.8.0 + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 with: cache: true flutter-version: ${{ matrix.sdk == 'min' && '2.8.0' || '' }} @@ -38,7 +40,7 @@ jobs: - name: Install proxy for tests run: sudo apt-get update && sudo apt-get install -y squid - run: dart pub get - - uses: bluefireteam/melos-action@v2 + - uses: bluefireteam/melos-action@v3 with: run-bootstrap: false - name: Patching files for Flutter ${{ matrix.sdk }} @@ -46,22 +48,28 @@ jobs: - name: Check satisfied packages run: | dart ./scripts/melos_ignored_packages.dart - echo $(cat .melos_ignored_packages) >> ~/.bash_profile + IGNORED_PACKAGES=$(cat .melos_ignored_packages) + echo "IGNORED_PACKAGES=$IGNORED_PACKAGES" >> $GITHUB_ENV - name: Bootstrap - run: melos bootstrap $(eval echo $IGNORED_PACKAGES) + run: melos bootstrap --no-select $IGNORED_PACKAGES - name: '[Verify step] Format' - run: melos exec $(eval echo $IGNORED_PACKAGES) -- "dart format --set-exit-if-changed ." - - name: '[Verify step] Analyze Dart packages' - run: melos exec $(eval echo $IGNORED_PACKAGES) --no-flutter -- "dart analyze --fatal-infos" - - name: '[Verify step] Analyze Flutter packages' - run: melos exec $(eval echo $IGNORED_PACKAGES) --flutter -- "flutter analyze --fatal-infos" + run: melos run format --no-select $IGNORED_PACKAGES + - name: '[Verify step] Analyze packages' + run: melos run analyze --no-select $IGNORED_PACKAGES - name: '[Verify step] Publish dry-run' - run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_test" -- "dart pub publish --dry-run" + run: melos run publish-dry-run --no-select $IGNORED_PACKAGES - name: '[Verify step] Test Dart packages [VM]' - run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=vm" + run: melos run test:dart --no-select $IGNORED_PACKAGES - name: '[Verify step] Test Dart packages [Chrome]' - run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="*http2*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=chrome" + run: melos run test:web --no-select $IGNORED_PACKAGES + env: + TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --ignore="*http2*" --ignore="dio_test" --no-flutter -- "MELOS_ROOT_PATH/scripts/dart_test.sh --platform=firefox" + run: melos run test:web --no-select $IGNORED_PACKAGES + env: + TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos exec $(eval echo $IGNORED_PACKAGES) --ignore="*example*" --flutter -- "flutter test" + run: melos run test:flutter --no-select $IGNORED_PACKAGES + - name: '[Verify step] Format & print test coverage' + if: ${{ matrix.sdk == 'stable' }} + run: melos run coverage:show diff --git a/.gitignore b/.gitignore index e3d4391c7..43efb4a52 100644 --- a/.gitignore +++ b/.gitignore @@ -12,32 +12,11 @@ pubspec_overrides.yaml doc/api/ .cookies/ -dio/.packages -dio/.dart_tool/ -dio/.pub/ -dio/.idea/ -dio/.exampl -dio/coverage - -# plugins -plugins/cookie_manager/.packages -plugins/cookie_manager/.dart_tool/ -plugins/cookie_manager/.pub/ -plugins/cookie_manager/.idea/ -plugins/cookie_manager/.exampl - -plugins/http2_adapter/.packages -plugins/http2_adapter/.dart_tool/ -plugins/http2_adapter/.pub/ -plugins/http2_adapter/.idea/ -plugins/http2_adapter/.exampl -plugins/http2_adapter/test/*_pinning.txt - .vscode/ # FVM .fvm -.fmvrc +.fvmrc # Miscellaneous .DS_Store @@ -47,3 +26,5 @@ plugins/http2_adapter/test/*_pinning.txt /.idea/* !/.idea/dio.iml !/.idea/modules.xml + +coverage diff --git a/dio/.gitignore b/dio/.gitignore index 9b76a7f71..45c92d6b1 100644 --- a/dio/.gitignore +++ b/dio/.gitignore @@ -33,3 +33,5 @@ build/ # Project related. test/*_pinning.txt + +coverage diff --git a/dio/dart_test.yaml b/dio/dart_test.yaml index 52cfb59fa..4e6cd51e3 100644 --- a/dio/dart_test.yaml +++ b/dio/dart_test.yaml @@ -7,6 +7,8 @@ tags: presets: all: skip: false + default: + skip: true override_platforms: chrome: diff --git a/melos.yaml b/melos.yaml index 390924fd0..7498b3d08 100644 --- a/melos.yaml +++ b/melos.yaml @@ -16,3 +16,86 @@ ide: command: bootstrap: runPubGetInParallel: false + hooks: + post: | + dart pub global activate coverage + dart pub global activate combine_coverage + dart pub global activate cobertura + clean: + hooks: + post: | + # Clean all flutter projects + melos exec --flutter -- "flutter clean" + # Clean coverage files + rm -rf coverage + melos exec --dir-exists coverage -- "rm -rf coverage" + +scripts: + analyze: + description: Analyze all packages + exec: dart analyze --fatal-infos + format: + description: Format check all packages + exec: dart format --set-exit-if-changed . + format:fix: + description: Format all packages + exec: dart format . + publish-dry-run: + description: Publish dry-run all packages + exec: dart pub publish --dry-run + ignore: + - 'dio_test' + - '*example*' + test: + name: All tests + run: | + melos run test:dart --no-select + TEST_PLATFORM=chrome melos run test:web --no-select + TEST_PLATFORM=firefox melos run test:web --no-select + melos run test:flutter --no-select + test:dart: + name: Dart VM tests + exec: dart test --preset ${TEST_PRESET:-default} --coverage coverage/vm --chain-stack-traces + packageFilters: + flutter: false + dirExists: test + test:web: + name: Dart Web tests + exec: dart test --platform ${TEST_PLATFORM:-chrome} --coverage coverage/${TEST_PLATFORM:-chrome} --preset ${TEST_PRESET:-default} --chain-stack-traces + packageFilters: + flutter: false + dirExists: test + ignore: + - '*http2*' + - '*cookie*' + test:flutter: + name: Flutter tests + exec: flutter test + packageFilters: + flutter: true + dirExists: test + test:coverage: + name: Run all tests and display coverage + run: | + melos run test + melos run coverage:format --no-select + melos run coverage:show + coverage:format: + name: Format coverage + exec: dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib + concurrency: 1 + packageFilters: + flutter: false + dirExists: coverage + coverage:combine: + name: Combine & convert coverage report + run: | + rm -rf coverage + melos run coverage:format --no-select + dart pub global run combine_coverage --repo-path=$pwd + dart pub global run cobertura convert --pubspec dio/pubspec.yaml + coverage:show: + name: Show coverage report + run: | + melos run coverage:combine + dart pub global run cobertura show diff --git a/plugins/compatibility_layer/.gitignore b/plugins/compatibility_layer/.gitignore index 3cceda557..7cbf61702 100644 --- a/plugins/compatibility_layer/.gitignore +++ b/plugins/compatibility_layer/.gitignore @@ -5,3 +5,5 @@ # Avoid committing pubspec.lock for library packages; see # https://dart.dev/guides/libraries/private-files#pubspeclock. pubspec.lock + +coverage diff --git a/plugins/compatibility_layer/dart_test.yaml b/plugins/compatibility_layer/dart_test.yaml index dbc48f42c..454e43c22 100644 --- a/plugins/compatibility_layer/dart_test.yaml +++ b/plugins/compatibility_layer/dart_test.yaml @@ -1,6 +1,7 @@ presets: - # empty placeholder required in CI scripts + # empty placeholders required in CI scripts all: + default: override_platforms: chrome: diff --git a/plugins/cookie_manager/.gitignore b/plugins/cookie_manager/.gitignore index 54bb7b7a9..e2d3f95cc 100644 --- a/plugins/cookie_manager/.gitignore +++ b/plugins/cookie_manager/.gitignore @@ -28,45 +28,4 @@ .pub/ build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +coverage diff --git a/plugins/cookie_manager/dart_test.yaml b/plugins/cookie_manager/dart_test.yaml index 6633e2f9e..e8a1dc06d 100644 --- a/plugins/cookie_manager/dart_test.yaml +++ b/plugins/cookie_manager/dart_test.yaml @@ -2,5 +2,6 @@ file_reporters: json: build/reports/test-results.json presets: - # empty placeholder required in CI scripts + # empty placeholders required in CI scripts all: + default: diff --git a/plugins/http2_adapter/.gitignore b/plugins/http2_adapter/.gitignore index 870a7de62..c7707906d 100644 --- a/plugins/http2_adapter/.gitignore +++ b/plugins/http2_adapter/.gitignore @@ -28,47 +28,6 @@ .pub/ build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +coverage test/_pinning_http2.txt diff --git a/plugins/http2_adapter/dart_test.yaml b/plugins/http2_adapter/dart_test.yaml index 6b6bceba3..5e49832eb 100644 --- a/plugins/http2_adapter/dart_test.yaml +++ b/plugins/http2_adapter/dart_test.yaml @@ -7,8 +7,12 @@ tags: presets: all: skip: false + default: + skip: true proxy: skip: "Skipping proxy test with specific setup requirements by default. Use '-P all' to run all tests." presets: all: skip: false + default: + skip: true diff --git a/plugins/native_dio_adapter/.gitignore b/plugins/native_dio_adapter/.gitignore index 9fecad6d2..c312a3d6b 100644 --- a/plugins/native_dio_adapter/.gitignore +++ b/plugins/native_dio_adapter/.gitignore @@ -18,3 +18,5 @@ # https://dart.dev/guides/libraries/private-files#pubspeclock. pubspec.lock .DS_Store + +coverage diff --git a/scripts/dart_test.sh b/scripts/dart_test.sh deleted file mode 100755 index e5e9c201b..000000000 --- a/scripts/dart_test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/bash - -while [[ "$1" == -* ]]; do - case "$1" in - --platform=*) PLATFORM="${1#*=}"; shift;; - --help|-h) echo "" - echo "Run Dart tests on the specific platform." - echo "" - echo "Usage: $(basename $0) [options]" - echo "" - echo " --platform Run tests on the specific platform" - echo " -h, --help Print this usage information" - echo ""; - exit 0;; - *) echo "Unrecognized option: $1. Use --help for usage."; exit 0;; - esac -done - -if [ -z "$PLATFORM" ]; then - echo "--platform is required." - exit 1 -fi - -dart test --chain-stack-traces --platform="$PLATFORM" -P all - -exit_code=$? - -## Escape 79 which means no tests run on the specific platform. -if [ $exit_code -eq 79 ]; then - exit 0 -else - exit $exit_code -fi From 058c41bad9b34ade557b9d9c37241611edcbab23 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 12:59:47 +0100 Subject: [PATCH 02/28] Bootstrap has no no-select flag --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3d65d6c81..e08c245d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,7 +51,7 @@ jobs: IGNORED_PACKAGES=$(cat .melos_ignored_packages) echo "IGNORED_PACKAGES=$IGNORED_PACKAGES" >> $GITHUB_ENV - name: Bootstrap - run: melos bootstrap --no-select $IGNORED_PACKAGES + run: melos bootstrap $IGNORED_PACKAGES - name: '[Verify step] Format' run: melos run format --no-select $IGNORED_PACKAGES - name: '[Verify step] Analyze packages' From 597aad1d018a2c4538290436bd9692eaadfe6972 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:04:24 +0100 Subject: [PATCH 03/28] Only run format/analyze/publish on stable SDK --- .github/workflows/tests.yml | 9 +++++---- scripts/files_patch.dart | 33 --------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 scripts/files_patch.dart diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e08c245d8..a7d8927a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,8 +43,6 @@ jobs: - uses: bluefireteam/melos-action@v3 with: run-bootstrap: false - - name: Patching files for Flutter ${{ matrix.sdk }} - run: dart ./scripts/files_patch.dart - name: Check satisfied packages run: | dart ./scripts/melos_ignored_packages.dart @@ -53,10 +51,13 @@ jobs: - name: Bootstrap run: melos bootstrap $IGNORED_PACKAGES - name: '[Verify step] Format' - run: melos run format --no-select $IGNORED_PACKAGES + if: ${{ matrix.sdk == 'stable' }} + run: melos run format --no-select - name: '[Verify step] Analyze packages' - run: melos run analyze --no-select $IGNORED_PACKAGES + if: ${{ matrix.sdk == 'stable' }} + run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' + if: ${{ matrix.sdk == 'stable' }} run: melos run publish-dry-run --no-select $IGNORED_PACKAGES - name: '[Verify step] Test Dart packages [VM]' run: melos run test:dart --no-select $IGNORED_PACKAGES diff --git a/scripts/files_patch.dart b/scripts/files_patch.dart deleted file mode 100644 index 973f899da..000000000 --- a/scripts/files_patch.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'dart:io'; - -void main() { - final v = RegExp(r'(\d*\.\d*)\.\d*').firstMatch(Platform.version)!.group(1)!; - final patches = patchesForVersions[v]; - if (patches != null && patches.isNotEmpty) { - print('Found file patches for Dart $v.'); - for (final patch in patches) { - print('Applying patch for ${patch.path}'); - final before = File(patch.path).readAsStringSync(); - final after = before.replaceAll(patch.before, patch.after); - File(patch.path).writeAsStringSync(after); - } - } -} - -class Patch { - const Patch(this.path, this.before, this.after); - - final String path; - final String before; - final String after; -} - -final patchesForVersions = >{ - '2.15': [ - Patch( - 'dio/lib/src/adapters/io_adapter.dart', - ' this.onHttpClientCreate', - ' this.onHttpClientCreate', - ), - ], -}; From 47d5650d379bf896f1ab851291dfe5e4f533d786 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:18:36 +0100 Subject: [PATCH 04/28] Fix ignore packages env variable --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7d8927a2..0f6fca337 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -46,8 +46,8 @@ jobs: - name: Check satisfied packages run: | dart ./scripts/melos_ignored_packages.dart - IGNORED_PACKAGES=$(cat .melos_ignored_packages) - echo "IGNORED_PACKAGES=$IGNORED_PACKAGES" >> $GITHUB_ENV + IGNORED=$(cat .melos_ignored_packages) + echo "IGNORED_PACKAGES=$IGNORED" >> $GITHUB_ENV - name: Bootstrap run: melos bootstrap $IGNORED_PACKAGES - name: '[Verify step] Format' From ab20bd7c42388c3790bc7616ef7b91e5d4d80d25 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:24:20 +0100 Subject: [PATCH 05/28] Squid seems to be unused --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0f6fca337..0cc77ee83 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,8 +37,6 @@ jobs: - run: | chmod +x ./scripts/prepare_pinning_certs.sh ./scripts/prepare_pinning_certs.sh - - name: Install proxy for tests - run: sudo apt-get update && sudo apt-get install -y squid - run: dart pub get - uses: bluefireteam/melos-action@v3 with: From eabf92247673d0355679e98cc3df5e52b3a512a2 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:24:31 +0100 Subject: [PATCH 06/28] Fix ignored packages env variable --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0cc77ee83..3f83c2424 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,8 +44,7 @@ jobs: - name: Check satisfied packages run: | dart ./scripts/melos_ignored_packages.dart - IGNORED=$(cat .melos_ignored_packages) - echo "IGNORED_PACKAGES=$IGNORED" >> $GITHUB_ENV + echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - name: Bootstrap run: melos bootstrap $IGNORED_PACKAGES - name: '[Verify step] Format' From 34830456752a2404913962493b74a205f800a1be Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:36:50 +0100 Subject: [PATCH 07/28] Improve generated ignored package env variable --- scripts/melos_ignored_packages.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/melos_ignored_packages.dart b/scripts/melos_ignored_packages.dart index 595781cfd..2c895f55c 100644 --- a/scripts/melos_ignored_packages.dart +++ b/scripts/melos_ignored_packages.dart @@ -26,10 +26,11 @@ void main() async { final ignoredPackages = packages .where((e) => !e.pubSpec.environment!.sdkConstraint!.allows(current)) .map((e) => e.name); - File('$root/.melos_ignored_packages').writeAsStringSync( - 'IGNORED_PACKAGES=' - "'${ignoredPackages.map((e) => '--ignore="$e"').join(' ')}'", - ); + final content = StringBuffer('IGNORED_PACKAGES='); + if (ignoredPackages.isNotEmpty) { + content.write(ignoredPackages.map((e) => '--ignore="$e"').join(' ')); + } + File('$root/.melos_ignored_packages').writeAsStringSync(content.toString()); } extension YamlUtils on YamlNode { From 7a1a9ee6be6020e793f47937cf4b08fa3449ded5 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:41:46 +0100 Subject: [PATCH 08/28] Fix package filter for publish dry-run step --- melos.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/melos.yaml b/melos.yaml index 7498b3d08..3e7329c5a 100644 --- a/melos.yaml +++ b/melos.yaml @@ -43,9 +43,10 @@ scripts: publish-dry-run: description: Publish dry-run all packages exec: dart pub publish --dry-run - ignore: - - 'dio_test' - - '*example*' + packageFilters: + ignore: + - 'dio_test' + - '*example*' test: name: All tests run: | From 3d952b5b2e13ed5de0f1632fe4ba2b433fa25e3d Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:44:38 +0100 Subject: [PATCH 09/28] More fixes for ignored packages --- .github/workflows/tests.yml | 2 +- scripts/melos_ignored_packages.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3f83c2424..c0e73bc51 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: run: | dart ./scripts/melos_ignored_packages.dart echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - - name: Bootstrap + - name: Melos Bootstrap run: melos bootstrap $IGNORED_PACKAGES - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} diff --git a/scripts/melos_ignored_packages.dart b/scripts/melos_ignored_packages.dart index 2c895f55c..29188f7a2 100644 --- a/scripts/melos_ignored_packages.dart +++ b/scripts/melos_ignored_packages.dart @@ -28,7 +28,7 @@ void main() async { .map((e) => e.name); final content = StringBuffer('IGNORED_PACKAGES='); if (ignoredPackages.isNotEmpty) { - content.write(ignoredPackages.map((e) => '--ignore="$e"').join(' ')); + content.write("'${ignoredPackages.map((e) => '--ignore="$e"').join(' ')}'"); } File('$root/.melos_ignored_packages').writeAsStringSync(content.toString()); } From 268b9c43b889b3921c4d058a09b6c8baff2d9b1a Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:45:35 +0100 Subject: [PATCH 10/28] Revert "Squid seems to be unused" This reverts commit ab20bd7c42388c3790bc7616ef7b91e5d4d80d25. --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c0e73bc51..cdd3ccc9c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,6 +37,8 @@ jobs: - run: | chmod +x ./scripts/prepare_pinning_certs.sh ./scripts/prepare_pinning_certs.sh + - name: Install proxy for tests + run: sudo apt-get update && sudo apt-get install -y squid - run: dart pub get - uses: bluefireteam/melos-action@v3 with: From e790e0bb154082e966df66b01db700c3558fdef1 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:48:23 +0100 Subject: [PATCH 11/28] Cancel in progress workflow runs for new pushes --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cdd3ccc9c..aa28f6bde 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,11 @@ on: paths-ignore: - "**.md" +# Ensure that new pushes/updates cancel running jobs +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + defaults: run: shell: bash -leo pipefail {0} From 1a6ca249f48616d7db4b0dfd596124e071c71c82 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 13:54:28 +0100 Subject: [PATCH 12/28] More fixes to ignored packages --- .github/workflows/tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa28f6bde..ad61eeddf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,7 @@ jobs: dart ./scripts/melos_ignored_packages.dart echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - name: Melos Bootstrap - run: melos bootstrap $IGNORED_PACKAGES + run: melos bootstrap $(eval echo $IGNORED_PACKAGES) - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} run: melos run format --no-select @@ -62,19 +62,19 @@ jobs: run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select $IGNORED_PACKAGES + run: melos run publish-dry-run --no-select $(eval echo $IGNORED_PACKAGES) - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select $IGNORED_PACKAGES + run: melos run test:dart --no-select $(eval echo $IGNORED_PACKAGES) - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select $IGNORED_PACKAGES + run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) env: TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web --no-select $IGNORED_PACKAGES + run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) env: TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select $IGNORED_PACKAGES + run: melos run test:flutter --no-select $(eval echo $IGNORED_PACKAGES) - name: '[Verify step] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show From 52e314e864e7374de84fc50aa431c1f6e082478b Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 14:24:47 +0100 Subject: [PATCH 13/28] New try --- .github/workflows/tests.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ad61eeddf..b90de9a74 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,9 @@ jobs: dart ./scripts/melos_ignored_packages.dart echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - name: Melos Bootstrap - run: melos bootstrap $(eval echo $IGNORED_PACKAGES) + run: melos bootstrap $IGNORED_PACKAGES + env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} run: melos run format --no-select @@ -62,19 +64,27 @@ jobs: run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run publish-dry-run --no-select $IGNORED_PACKAGES + env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run test:dart --no-select $IGNORED_PACKAGES + env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run test:web --no-select $IGNORED_PACKAGES env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run test:web --no-select $IGNORED_PACKAGES env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run test:flutter --no-select $IGNORED_PACKAGES + env: + IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show From cd06df4898ddb1272ffefb374f3cc6cb0c8efba0 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 14:55:02 +0100 Subject: [PATCH 14/28] Improve coverage setup & flow --- .github/workflows/tests.yml | 10 +++++----- melos.yaml | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b90de9a74..aa1740516 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,7 @@ jobs: dart ./scripts/melos_ignored_packages.dart echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - name: Melos Bootstrap - run: melos bootstrap $IGNORED_PACKAGES + run: melos bootstrap $(eval echo $IGNORED_PACKAGES) env: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format' @@ -64,15 +64,15 @@ jobs: run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select $IGNORED_PACKAGES + run: melos run publish-dry-run --no-select $(eval echo $IGNORED_PACKAGES) env: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select $IGNORED_PACKAGES + run: melos run test:dart --no-select $(eval echo $IGNORED_PACKAGES) env: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select $IGNORED_PACKAGES + run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) env: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: chrome @@ -82,7 +82,7 @@ jobs: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select $IGNORED_PACKAGES + run: melos run test:flutter --no-select $(eval echo $IGNORED_PACKAGES) env: IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format & print test coverage' diff --git a/melos.yaml b/melos.yaml index 3e7329c5a..47298b984 100644 --- a/melos.yaml +++ b/melos.yaml @@ -16,11 +16,6 @@ ide: command: bootstrap: runPubGetInParallel: false - hooks: - post: | - dart pub global activate coverage - dart pub global activate combine_coverage - dart pub global activate cobertura clean: hooks: post: | @@ -51,8 +46,8 @@ scripts: name: All tests run: | melos run test:dart --no-select - TEST_PLATFORM=chrome melos run test:web --no-select - TEST_PLATFORM=firefox melos run test:web --no-select + TEST_PLATFORM=chrome melos run test:web + TEST_PLATFORM=firefox melos run test:web melos run test:flutter --no-select test:dart: name: Dart VM tests @@ -79,12 +74,16 @@ scripts: name: Run all tests and display coverage run: | melos run test - melos run coverage:format --no-select + melos run coverage:format melos run coverage:show coverage:format: name: Format coverage + run: | + dart pub global activate coverage + melos run coverage:format:package + coverage:format:package: + name: Format coverage for each package exec: dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib - concurrency: 1 packageFilters: flutter: false dirExists: coverage @@ -92,7 +91,9 @@ scripts: name: Combine & convert coverage report run: | rm -rf coverage - melos run coverage:format --no-select + dart pub global activate combine_coverage + dart pub global activate cobertura + melos run coverage:format dart pub global run combine_coverage --repo-path=$pwd dart pub global run cobertura convert --pubspec dio/pubspec.yaml coverage:show: From fa634c8552d59aa85581a7f6c08aa02df8965246 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 15:00:07 +0100 Subject: [PATCH 15/28] .....!! --- .github/workflows/tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa1740516..15e8ea69e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,9 +53,7 @@ jobs: dart ./scripts/melos_ignored_packages.dart echo $(cat .melos_ignored_packages) >> $GITHUB_ENV - name: Melos Bootstrap - run: melos bootstrap $(eval echo $IGNORED_PACKAGES) - env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} + run: melos bootstrap ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} run: melos run format --no-select From 6246483090ba259e5a093c4af1390e42269c56aa Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 15:02:38 +0100 Subject: [PATCH 16/28] More env variable tries --- scripts/melos_ignored_packages.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/melos_ignored_packages.dart b/scripts/melos_ignored_packages.dart index 29188f7a2..2c895f55c 100644 --- a/scripts/melos_ignored_packages.dart +++ b/scripts/melos_ignored_packages.dart @@ -28,7 +28,7 @@ void main() async { .map((e) => e.name); final content = StringBuffer('IGNORED_PACKAGES='); if (ignoredPackages.isNotEmpty) { - content.write("'${ignoredPackages.map((e) => '--ignore="$e"').join(' ')}'"); + content.write(ignoredPackages.map((e) => '--ignore="$e"').join(' ')); } File('$root/.melos_ignored_packages').writeAsStringSync(content.toString()); } From ae756997a6496c2a69ce514558e7113341814ba0 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 15:07:39 +0100 Subject: [PATCH 17/28] This seems to work... --- .github/workflows/tests.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 15e8ea69e..81d733d0d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,27 +62,19 @@ jobs: run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select $(eval echo $IGNORED_PACKAGES) - env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} + run: melos run publish-dry-run --no-select ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select $(eval echo $IGNORED_PACKAGES) - env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} + run: melos run test:dart --no-select ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select $(eval echo $IGNORED_PACKAGES) + run: melos run test:web --no-select ${{ env.IGNORED_PACKAGES }} env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web --no-select $IGNORED_PACKAGES + run: melos run test:web --no-select ${{ env.IGNORED_PACKAGES }} env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select $(eval echo $IGNORED_PACKAGES) - env: - IGNORED_PACKAGES: ${{ env.IGNORED_PACKAGES }} + run: melos run test:flutter --no-select ${{ env.IGNORED_PACKAGES }} - name: '[Verify step] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show From c1ee5d900dd3b920b929ad02343309fe720140b7 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 15:33:23 +0100 Subject: [PATCH 18/28] Invert melos packages step by using the official MELOS_PACKAGES variable --- .github/workflows/tests.yml | 16 ++++++++-------- ...ored_packages.dart => melos_packages.dart} | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) rename scripts/{melos_ignored_packages.dart => melos_packages.dart} (72%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 81d733d0d..6dc8c4631 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,10 +50,10 @@ jobs: run-bootstrap: false - name: Check satisfied packages run: | - dart ./scripts/melos_ignored_packages.dart - echo $(cat .melos_ignored_packages) >> $GITHUB_ENV + dart ./scripts/melos_packages.dart + echo $(cat .melos_packages) >> $GITHUB_ENV - name: Melos Bootstrap - run: melos bootstrap ${{ env.IGNORED_PACKAGES }} + run: melos bootstrap - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} run: melos run format --no-select @@ -62,19 +62,19 @@ jobs: run: melos run analyze --no-select - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select ${{ env.IGNORED_PACKAGES }} + run: melos run publish-dry-run --no-select - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select ${{ env.IGNORED_PACKAGES }} + run: melos run test:dart --no-select - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select ${{ env.IGNORED_PACKAGES }} + run: melos run test:web --no-select env: TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web --no-select ${{ env.IGNORED_PACKAGES }} + run: melos run test:web --no-select env: TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select ${{ env.IGNORED_PACKAGES }} + run: melos run test:flutter --no-select - name: '[Verify step] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show diff --git a/scripts/melos_ignored_packages.dart b/scripts/melos_packages.dart similarity index 72% rename from scripts/melos_ignored_packages.dart rename to scripts/melos_packages.dart index 2c895f55c..2a28040bd 100644 --- a/scripts/melos_ignored_packages.dart +++ b/scripts/melos_packages.dart @@ -6,6 +6,10 @@ import 'package:melos/melos.dart' import 'package:pub_semver/pub_semver.dart'; import 'package:yaml/yaml.dart'; +/// Writes a `.melos_packages` file to the root of the workspace with the +/// packages that are compatible with the current Dart SDK version. +/// This is useful for CI scripts that need to know which packages to run +/// melos for ny using the `MELOS_PACKAGES` environment variable. void main() async { final root = Platform.environment['MELOS_ROOT_PATH'] ?? Directory.current.path; @@ -23,14 +27,13 @@ void main() async { final current = Version.parse( RegExp(r'\d*\.\d*\.\d*').firstMatch(Platform.version)!.group(0)!, ); - final ignoredPackages = packages - .where((e) => !e.pubSpec.environment!.sdkConstraint!.allows(current)) - .map((e) => e.name); - final content = StringBuffer('IGNORED_PACKAGES='); - if (ignoredPackages.isNotEmpty) { - content.write(ignoredPackages.map((e) => '--ignore="$e"').join(' ')); - } - File('$root/.melos_ignored_packages').writeAsStringSync(content.toString()); + final String validPackages = packages + .where((e) => e.pubSpec.environment!.sdkConstraint!.allows(current)) + .map((e) => e.name) + .join(','); + + File('$root/.melos_packages') + .writeAsStringSync('MELOS_PACKAGES=$validPackages'); } extension YamlUtils on YamlNode { From 4ef7d918ab013f2403388df0e7b3dc9645c2120f Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 15:41:37 +0100 Subject: [PATCH 19/28] Work around old melos version constraints --- melos.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/melos.yaml b/melos.yaml index 47298b984..f84f02303 100644 --- a/melos.yaml +++ b/melos.yaml @@ -55,6 +55,11 @@ scripts: packageFilters: flutter: false dirExists: test + # dirExists doesn't seem to be supported in the min SDK version, + # so we have to use the ignore filter instead for now. + ignore: + - '*example*' + - 'dio_test' test:web: name: Dart Web tests exec: dart test --platform ${TEST_PLATFORM:-chrome} --coverage coverage/${TEST_PLATFORM:-chrome} --preset ${TEST_PRESET:-default} --chain-stack-traces @@ -64,12 +69,18 @@ scripts: ignore: - '*http2*' - '*cookie*' + # dirExists doesn't seem to be supported in the min SDK version, + # so we have to use the ignore filter instead for now. + - '*example*' + - 'dio_test' test:flutter: name: Flutter tests exec: flutter test packageFilters: flutter: true dirExists: test + ignore: + - '*example*' test:coverage: name: Run all tests and display coverage run: | From b781212563c0868e60598c2dbc62ea076937a626 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 16:22:07 +0100 Subject: [PATCH 20/28] Configure melos 2.9.0 which is the latest available on SDK 2.15.0 --- melos.yaml | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/melos.yaml b/melos.yaml index f84f02303..30c05b8a1 100644 --- a/melos.yaml +++ b/melos.yaml @@ -23,6 +23,7 @@ command: melos exec --flutter -- "flutter clean" # Clean coverage files rm -rf coverage + rm -rf pubspec.lock melos exec --dir-exists coverage -- "rm -rf coverage" scripts: @@ -39,27 +40,27 @@ scripts: description: Publish dry-run all packages exec: dart pub publish --dry-run packageFilters: - ignore: - - 'dio_test' - - '*example*' + noPrivate: true test: name: All tests run: | - melos run test:dart --no-select + melos run test:dart TEST_PLATFORM=chrome melos run test:web TEST_PLATFORM=firefox melos run test:web - melos run test:flutter --no-select + melos run test:flutter test:dart: name: Dart VM tests exec: dart test --preset ${TEST_PRESET:-default} --coverage coverage/vm --chain-stack-traces packageFilters: flutter: false dirExists: test - # dirExists doesn't seem to be supported in the min SDK version, - # so we have to use the ignore filter instead for now. + # Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK. + select-package: + flutter: false + dir-exists: test ignore: - - '*example*' - - 'dio_test' + - 'dio_compatibility_layer' + - 'dio_http2_adapter' test:web: name: Dart Web tests exec: dart test --platform ${TEST_PLATFORM:-chrome} --coverage coverage/${TEST_PLATFORM:-chrome} --preset ${TEST_PRESET:-default} --chain-stack-traces @@ -69,10 +70,14 @@ scripts: ignore: - '*http2*' - '*cookie*' - # dirExists doesn't seem to be supported in the min SDK version, - # so we have to use the ignore filter instead for now. - - '*example*' - - 'dio_test' + # Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK. + select-package: + flutter: false + dir-exists: test + ignore: + - 'dio_compatibility_layer' + - '*http2*' + - '*cookie*' test:flutter: name: Flutter tests exec: flutter test @@ -81,6 +86,13 @@ scripts: dirExists: test ignore: - '*example*' + # Old syntax for melos <= 2.9.0 - this can be removed once we bump the minimum Dart SDK. + # There is no packages to run on min SDK for this command. + select-package: + flutter: true + dir-exists: test + ignore: + - '*' test:coverage: name: Run all tests and display coverage run: | From be2ecc412fdf8a57ee3840328c4c3a6e56903050 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 16:40:41 +0100 Subject: [PATCH 21/28] Attempt to generate coverage report --- .github/workflows/tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6dc8c4631..9b3a770be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,6 +75,11 @@ jobs: TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' run: melos run test:flutter --no-select - - name: '[Verify step] Format & print test coverage' + - name: '[Coverage] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show + - name: '[Coverage] Coverage Report' + uses: clearlyip/code-coverage-report-action@v4 + if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}} + with: + filename: 'coverage/cobertura.xml' From 94f24603e0c97d62a77193be41115886801bd5c6 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 17:03:08 +0100 Subject: [PATCH 22/28] Add coverage for Flutter tests --- .github/workflows/tests.yml | 14 +++++++------- melos.yaml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b3a770be..4946ab837 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,25 +56,25 @@ jobs: run: melos bootstrap - name: '[Verify step] Format' if: ${{ matrix.sdk == 'stable' }} - run: melos run format --no-select + run: melos run format - name: '[Verify step] Analyze packages' if: ${{ matrix.sdk == 'stable' }} - run: melos run analyze --no-select + run: melos run analyze - name: '[Verify step] Publish dry-run' if: ${{ matrix.sdk == 'stable' }} - run: melos run publish-dry-run --no-select + run: melos run publish-dry-run - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart --no-select + run: melos run test:dart - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web --no-select + run: melos run test:web env: TEST_PLATFORM: chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web --no-select + run: melos run test:web env: TEST_PLATFORM: firefox - name: '[Verify step] Test Flutter packages' - run: melos run test:flutter --no-select + run: melos run test:flutter - name: '[Coverage] Format & print test coverage' if: ${{ matrix.sdk == 'stable' }} run: melos run coverage:show diff --git a/melos.yaml b/melos.yaml index 30c05b8a1..01b4cd139 100644 --- a/melos.yaml +++ b/melos.yaml @@ -80,7 +80,7 @@ scripts: - '*cookie*' test:flutter: name: Flutter tests - exec: flutter test + exec: flutter test --coverage packageFilters: flutter: true dirExists: test From 3fa6c9a8fee6071a002ee904ca0703060c153e5b Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 13 Mar 2024 17:11:31 +0100 Subject: [PATCH 23/28] Add workflow that generates the coverage baseline --- .github/workflows/coverage_base.yml | 52 +++++++++++++++++++++++++++++ .github/workflows/tests.yml | 1 + 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/coverage_base.yml diff --git a/.github/workflows/coverage_base.yml b/.github/workflows/coverage_base.yml new file mode 100644 index 000000000..317cba665 --- /dev/null +++ b/.github/workflows/coverage_base.yml @@ -0,0 +1,52 @@ +name: 'coverage_baseline' + +# The code-coverage-report-action uses workflow artifacts to store the coverage report. +# The action will upload the coverage report as an artifact, +# and the action will also download the coverage report from the artifact in PRs. +# The action will then compare the coverage report from the PR with the coverage report from the base branch. +# For this to work, the action needs to be run on the base branch after each pushed commit +# or at least once before the artifact retention period ends. + +on: + # Allow for manual runs + workflow_dispatch: + # Runs at 00:00, on day 1 of the month (every ~30 days) + schedule: + - cron: '0 0 1 * *' + push: + branches: + - main + +jobs: + cron: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: subosito/flutter-action@v2 + with: + cache: true + channel: stable + - run: | + chmod +x ./scripts/prepare_pinning_certs.sh + ./scripts/prepare_pinning_certs.sh + - name: Install proxy for tests + run: sudo apt-get update && sudo apt-get install -y squid + - run: dart pub get + - uses: bluefireteam/melos-action@v3 + - name: '[Verify step] Test Dart packages [VM]' + run: melos run test:dart + - name: '[Verify step] Test Dart packages [Chrome]' + run: melos run test:web + env: + TEST_PLATFORM: chrome + - name: '[Verify step] Test Dart packages [Firefox]' + run: melos run test:web + env: + TEST_PLATFORM: firefox + - name: '[Verify step] Test Flutter packages' + run: melos run test:flutter + - name: '[Coverage] Generate report' + run: melos run coverage:combine + - uses: clearlyip/code-coverage-report-action@v4 + with: + filename: 'coverage/cobertura.xml' \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4946ab837..ef3a7e025 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,4 +82,5 @@ jobs: uses: clearlyip/code-coverage-report-action@v4 if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}} with: + artifact_download_workflow_names: 'tests,coverage_base' filename: 'coverage/cobertura.xml' From 0ed2802bd8c78c85fd3dbd15a637e7aed79ccc9d Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sun, 17 Mar 2024 18:59:44 +0100 Subject: [PATCH 24/28] Simplify and name web test scripts --- .github/workflows/coverage_base.yml | 14 +++++--------- .github/workflows/tests.yml | 10 +++------- melos.yaml | 21 ++++++++++++++++++--- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/coverage_base.yml b/.github/workflows/coverage_base.yml index 317cba665..9ff7d2312 100644 --- a/.github/workflows/coverage_base.yml +++ b/.github/workflows/coverage_base.yml @@ -18,7 +18,7 @@ on: - main jobs: - cron: + generate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -34,19 +34,15 @@ jobs: - run: dart pub get - uses: bluefireteam/melos-action@v3 - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart + run: melos run test:vm - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web - env: - TEST_PLATFORM: chrome + run: melos run test:web:chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web - env: - TEST_PLATFORM: firefox + run: melos run test:web:firefox - name: '[Verify step] Test Flutter packages' run: melos run test:flutter - name: '[Coverage] Generate report' run: melos run coverage:combine - uses: clearlyip/code-coverage-report-action@v4 with: - filename: 'coverage/cobertura.xml' \ No newline at end of file + filename: 'coverage/cobertura.xml' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef3a7e025..8fabf94fe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,15 +64,11 @@ jobs: if: ${{ matrix.sdk == 'stable' }} run: melos run publish-dry-run - name: '[Verify step] Test Dart packages [VM]' - run: melos run test:dart + run: melos run test:vm - name: '[Verify step] Test Dart packages [Chrome]' - run: melos run test:web - env: - TEST_PLATFORM: chrome + run: melos run test:web:chrome - name: '[Verify step] Test Dart packages [Firefox]' - run: melos run test:web - env: - TEST_PLATFORM: firefox + run: melos run test:web:firefox - name: '[Verify step] Test Flutter packages' run: melos run test:flutter - name: '[Coverage] Format & print test coverage' diff --git a/melos.yaml b/melos.yaml index 01b4cd139..da6a60073 100644 --- a/melos.yaml +++ b/melos.yaml @@ -44,11 +44,11 @@ scripts: test: name: All tests run: | - melos run test:dart + melos run test:vm TEST_PLATFORM=chrome melos run test:web TEST_PLATFORM=firefox melos run test:web melos run test:flutter - test:dart: + test:vm: name: Dart VM tests exec: dart test --preset ${TEST_PRESET:-default} --coverage coverage/vm --chain-stack-traces packageFilters: @@ -63,7 +63,22 @@ scripts: - 'dio_http2_adapter' test:web: name: Dart Web tests - exec: dart test --platform ${TEST_PLATFORM:-chrome} --coverage coverage/${TEST_PLATFORM:-chrome} --preset ${TEST_PRESET:-default} --chain-stack-traces + run: | + melos run test:web:chrome + melos run test:web:firefox + test:web:chrome: + name: Dart Web tests in chrome + run: melos run test:web:single + env: + TEST_PLATFORM: chrome + test:web:firefox: + name: Dart Web tests in firefox + run: melos run test:web:single + env: + TEST_PLATFORM: firefox + test:web:single: + name: Dart Web tests in a browser + exec: dart test --platform ${TEST_PLATFORM} --coverage coverage/${TEST_PLATFORM} --preset ${TEST_PRESET:-default} --chain-stack-traces packageFilters: flutter: false dirExists: test From aa392080b45c20f296232d5e4904821c7be9c0a0 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sun, 17 Mar 2024 19:16:20 +0100 Subject: [PATCH 25/28] Fix typo --- scripts/melos_packages.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/melos_packages.dart b/scripts/melos_packages.dart index 2a28040bd..423b38a0a 100644 --- a/scripts/melos_packages.dart +++ b/scripts/melos_packages.dart @@ -9,7 +9,7 @@ import 'package:yaml/yaml.dart'; /// Writes a `.melos_packages` file to the root of the workspace with the /// packages that are compatible with the current Dart SDK version. /// This is useful for CI scripts that need to know which packages to run -/// melos for ny using the `MELOS_PACKAGES` environment variable. +/// melos for using the `MELOS_PACKAGES` environment variable. void main() async { final root = Platform.environment['MELOS_ROOT_PATH'] ?? Directory.current.path; From ee0ecccd1b7dff4517b5154dc869f21fc195fa60 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sun, 17 Mar 2024 19:52:43 +0100 Subject: [PATCH 26/28] Add a CONTRIBUTING doc --- CONTRIBUTING.md | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..45cf1da31 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,98 @@ +# Contributing Guidelines + +First of all, thank you for considering contributing to the `dio` project! Open source projects like this one grow and thrive thanks to the contributions from people like you. Whether you're fixing bugs, adding new features, improving the documentation, or even reporting issues, every contribution is valuable and appreciated. + +This document provides some guidelines to help ensure that your contributions are as effective as possible. Please take a moment to read through these guidelines before submitting your contribution. + +Remember, everyone contributing to this project is expected to follow our code of conduct. This helps ensure a positive and inclusive environment for all contributors. + +Thank you again for your contributions, and we look forward to seeing what you will bring to the `dio` project! + +## Creating Good Tickets + +> [!TIP] +> Before creating a new issue, it's a good practice to search for open tickets and pull requests to avoid duplicates. + +### Bug Reports + +When reporting a bug, please include the following information: + +1. **Title**: A brief, descriptive title for the bug. +2. **Package**: Specify which package has the problem. +3. **Version**: The version of the package you are using. +4. **Operating System**: The OS on which the problem occurs. +5. **Adapter**: Specify which adapter(s) are used. +6. **Output of `flutter doctor -v`**: Required when used with Flutter. +7. **Dart Version**: The version of Dart you are using. +8. **Steps to Reproduce**: Detailed steps on how to reproduce the bug. +9. **Expected Result**: What you expected to happen. +10. **Actual Result**: What actually happened. Include logs, screenshots, or any other relevant information. + +### Feature Requests + +When requesting a new feature, please include the following information: + +1. **Title**: A brief, descriptive title for the feature request. +2. **Request Statement**: Describe the problem that you believe the `dio` project could solve but currently doesn't. +3. **Solution Brainstorm**: Share your ideas on how the problem could be solved. If you don't have a specific solution in mind, that's okay too! + +> [!TIP] +> Remember, the more information you provide, the easier it is for us to understand and address the issue. Thank you for your contributions! + +# Contributing Guidelines + +... + +## Development + +This project uses [Melos](https://github.com/invertase/melos) to manage the mono-repo and most tasks. Melos is a tool that optimizes the workflow for multi-package Dart and Flutter projects. For more information on how to use Melos, please refer to the [Melos documentation](https://melos.invertase.dev). + + +### Setup + +To get started, you'll need to install Melos globally: + +```bash +dart pub global activate melos +``` + +After installing Melos, you can clone the repository and install the dependencies: + +```bash +git clone +cd dio +melos bootstrap +``` + +## Submitting changes + +Before submitting your changes as a pull request, please make sure to format and analyze your and run the all tests. Here are the main melos scripts you should be aware of: + +### Code quality + +To format (and fix) all packages, run: +```bash +melos run format +# OR +melos run format:fix +``` + +To analyze all packages, run: +```bash +melos run analyze +``` + +### Testing + +To run all tests, use: +```bash +melos run test +``` + +Individual test targets can be run with the appropriate scripts: +```bash +melos run test:vm +melos run test:web +melos run test:web:chrome +melos run test:web:firefox +``` From b7c7000aca696d5e332b7db1c52ba62aba52b50b Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Sun, 17 Mar 2024 19:56:14 +0100 Subject: [PATCH 27/28] Improve doc --- CONTRIBUTING.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 45cf1da31..1451c6c0f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,10 +38,7 @@ When requesting a new feature, please include the following information: > [!TIP] > Remember, the more information you provide, the easier it is for us to understand and address the issue. Thank you for your contributions! - -# Contributing Guidelines - -... +> Please refrain from commenting on old, closed tickets. If an old issue seems related but doesn't fully address your problem, it's best to open a new ticket and reference the old one instead. ## Development @@ -59,7 +56,7 @@ dart pub global activate melos After installing Melos, you can clone the repository and install the dependencies: ```bash -git clone +git clone https://github.com/cfug/dio.git cd dio melos bootstrap ``` From ec42167d883fa2a3ec809895b059d36d209f0cff Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Mon, 18 Mar 2024 18:20:13 +0100 Subject: [PATCH 28/28] Add Chinese contribution guidelines --- CONTRIBUTING-ZH.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 2 + 2 files changed, 98 insertions(+) create mode 100644 CONTRIBUTING-ZH.md diff --git a/CONTRIBUTING-ZH.md b/CONTRIBUTING-ZH.md new file mode 100644 index 000000000..daa3f683f --- /dev/null +++ b/CONTRIBUTING-ZH.md @@ -0,0 +1,96 @@ +# 贡献指南 + +Language: [English](CONTRIBUTING.md) | 简体中文 + +首先,感谢您考虑为 `dio` 项目做出贡献!像这样的开源项目得以成长和繁荣,多亏了像您这样的贡献者。无论您是在修复错误、添加新功能、改进文档还是报告问题,每一份贡献都是宝贵和值得赞赏的。 + +本文档提供了一些指南,以帮助确保您的贡献尽可能有效。在提交您的贡献之前,请花一点时间阅读这些指南。 + +请记住,每个为这个项目做出贡献的人都需要遵循我们的行为准则。这有助于确保所有贡献者的积极和包容环境。 + +再次感谢您的贡献,我们期待看到您将为 `dio` 项目带来什么! + +## 创建好的工单 + +> [!TIP] +> 在创建新问题之前,搜索已有的工单和拉取请求以避免重复是一个好习惯。 + +### 错误报告 + +报告错误时,请包括以下信息: + +1. **标题**:简短描述性的错误标题。 +2. **包**:指定有问题的包。 +3. **版本**:您正在使用的包版本。 +4. **操作系统**:出现问题的操作系统。 +5. **适配器**:指定使用的适配器。 +6. **`flutter doctor -v` 的输出**:使用 Flutter 时需要。 +7. **Dart 版本**:您使用的 Dart 版本。 +8. **重现步骤**:详细步骤说明如何重现错误。 +9. **预期结果**:您期望发生的事情。 +10. **实际结果**:实际发生的事情。包括日志、屏幕截图或任何其他相关信息。 + +### 功能请求 + +请求新功能时,请包括以下信息: + +1. **标题**:功能请求的简短描述性标题。 +2. **请求声明**:描述您认为 `dio` 项目能解决但目前没有解决的问题。 +3. **解决方案头脑风暴**:分享您的想法,关于如何解决问题。如果您没有特定的解决方案,那也没关系! + +> [!TIP] +> 记住,您提供的信息越多,我们就越容易理解和解决问题。感谢您的贡献! +> 请避免评论旧的、已关闭的工单。如果旧问题似乎与您的问题有关但并未完全解决您的问题,最好开一个新工单并引用旧的。 + +## 开发 + +此项目使用 [Melos](https://github.com/invertase/melos) 管理单体仓库和大多数任务。Melos 是一个为 Dart 和 Flutter 的多包项目优化工作流的工具。有关如何使用 Melos 的更多信息,请参阅 [Melos 文档](https://melos.invertase.dev)。 + +### 设置 + +开始之前,您需要全局安装 Melos: + +```bash +dart pub global activate melos +``` + +在安装 Melos 后,可以克隆仓库并安装依赖项: + +```bash +git clone https://github.com/cfug/dio.git +cd dio +melos bootstrap +``` + +## 提交更改 + +在以拉取请求提交您的更改之前,请确保格式化和分析您的代码并运行所有测试。以下是您应该了解的主要 melos 脚本: + +### 代码质量 + +要格式化(和修复)所有包,请运行: +```bash +melos run format +# 或者 +melos run format:fix +``` + +要分析所有包,请运行: +```bash +melos run analyze +``` + +### 测试 + +要运行所有测试,请使用: +```bash +melos run test +``` + +可以使用适当的脚本运行单个测试目标: +```bash +melos run test:vm +melos run test:web +melos run test:web:chrome +melos run test:web:firefox +``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1451c6c0f..241d6e791 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,7 @@ # Contributing Guidelines +Language: English | [简体中文](CONTRIBUTING-ZH.md) + First of all, thank you for considering contributing to the `dio` project! Open source projects like this one grow and thrive thanks to the contributions from people like you. Whether you're fixing bugs, adding new features, improving the documentation, or even reporting issues, every contribution is valuable and appreciated. This document provides some guidelines to help ensure that your contributions are as effective as possible. Please take a moment to read through these guidelines before submitting your contribution.