diff --git a/.github/workflows/all_plugins.yaml b/.github/workflows/all_plugins.yaml index 89e0d0d7430d..787b9371d414 100644 --- a/.github/workflows/all_plugins.yaml +++ b/.github/workflows/all_plugins.yaml @@ -32,7 +32,10 @@ jobs: with: melos-version: '5.3.0' - name: 'Run Analyze' - run: melos analyze-ci + run: melos analyze-ci > analyze.log || true + - name: 'Summarize analyze failures' + if: ${{ always() }} + run: ./.github/workflows/scripts/summarize_errors.sh "error •" analyze.log # Separated from "analyse" action as pubspec_override file is not being taken into account when running `flutter pub publish --dry-run` # This will fail on CI until this is fixed: https://github.com/invertase/melos/issues/467 @@ -52,7 +55,10 @@ jobs: - name: 'Pub Check' run: | melos exec -c 1 --no-private --ignore="*example*" -- \ - dart pub publish --dry-run + dart pub publish --dry-run > pub_dry_run.log || true + - name: 'Summarize pub dry run failures' + if: ${{ always() }} + run: ./.github/workflows/scripts/summarize_errors.sh "error" pub_dry_run.log pub_get_check: timeout-minutes: 30 @@ -96,15 +102,14 @@ jobs: run: | clang-format --version swiftformat --version - - name: 'Dart, Java and Objective-C ' + - name: 'Format' run: | flutter pub global run flutter_plugin_tools format - ./.github/workflows/scripts/validate-formatting.sh - - name: 'Swift' - if: ${{ success() || failure() }} - run: | swiftformat . - ./.github/workflows/scripts/validate-formatting.sh + ./.github/workflows/scripts/validate-formatting.sh > format.log || true + - name: 'Summarize format failures' + if: ${{ always() }} + run: ./.github/workflows/scripts/summarize_errors.sh "❌ Some files are incorrectly formatted, see above output." format.log build_examples_dart: timeout-minutes: 30 @@ -162,9 +167,12 @@ jobs: with: melos-version: '5.3.0' - name: 'Flutter Test' - run: melos run test --no-select + run: melos run test --no-select > test.log || true - name: 'Flutter Test - Web' - run: melos run test:web --no-select + run: melos run test:web --no-select > test_web.log || true + - name: 'Summarize test failures' + if: ${{ always() }} + run: ./.github/workflows/scripts/summarize_errors.sh "Some tests failed." test.log test_web.log check-files-license-headers: runs-on: ubuntu-latest @@ -187,4 +195,7 @@ jobs: run-bootstrap: false melos-version: '5.3.0' - name: Check license header - run: melos run check-license-header + run: melos run check-license-header > license_header.log || true + - name: 'Summarize license header failures' + if: ${{ always() }} + run: ./.github/workflows/scripts/summarize_errors.sh "failed" license_header.log diff --git a/.github/workflows/scripts/summarize_errors.sh b/.github/workflows/scripts/summarize_errors.sh new file mode 100755 index 000000000000..2bc45e1e56ca --- /dev/null +++ b/.github/workflows/scripts/summarize_errors.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -e + +if [ "$#" -lt 2 ]; then + echo "Usage: $0 [ ...]" + exit 1 +fi + +search_pattern="$1" +shift + +echo "Analyzing test logs for failures with pattern: '$search_pattern'" + +for logfile in "$@"; do + if [ ! -f "$logfile" ]; then + echo "Log file not found: $logfile" + continue + fi + + echo "Checking $logfile..." + + # The awk script is now parameterized with the search_pattern variable. + # We use a flag `failure_found` to indicate if a failure has been detected. + # This is to prevent the script from exiting early if a failure is found. + failure_found=0 + while IFS= read -r line; do + if [[ "$line" == "melos exec"* ]]; then + in_melos_block=true + package_path="" + fi + + if $in_melos_block && [[ "$line" == *"└> CWD:"* ]]; then + package_path=$(echo "$line" | awk '{print $3}') + fi + + if [[ "$line" =~ $search_pattern ]]; then + if [ "$failure_found" -eq 0 ]; then + echo "" + echo "=================================================================" + echo " Error Summary for $logfile" + echo "=================================================================" + failure_found=1 + fi + + if [ -n "$package_path" ]; then + echo "❌ Failure detected in package: $package_path" + else + echo "❌ Failure detected in $logfile" + fi + echo " $line" + echo "" + fi + + if $in_melos_block && [[ "$line" == *"melos exec done"* ]]; then + in_melos_block=false + package_path="" + fi + done < "$logfile" +done + +echo "Analysis complete." diff --git a/melos.yaml b/melos.yaml index 8536c4357c89..bfde35c82b49 100644 --- a/melos.yaml +++ b/melos.yaml @@ -134,7 +134,7 @@ scripts: test: run: | - melos exec -c 6 --fail-fast -- \ + melos exec -c 6 -- \ "flutter test" description: Run `flutter test` for a specific package. packageFilters: @@ -146,7 +146,7 @@ scripts: test:web: run: | - melos exec -c 1 --fail-fast -- \ + melos exec -c 1 -- \ "flutter test --platform=chrome" description: Run `flutter test --platform=chrome` for a specific '*web' package. packageFilters: