Repository navigation
ci(benchmark): skip PR comment on fork PRs, make headline reflect rea… #132
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-flight Checks | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| # Pipeline 1 — Pre-flight (target: < 2 min) | |
| # | |
| # Runs on every push / PR as the fast gate that must pass before any heavy | |
| # job is allowed to start. Three responsibilities: | |
| # | |
| # 1. dart format — code style, fails on any formatting diff | |
| # 2. flutter analyze --fatal-infos — zero errors/warnings/infos enforced | |
| # 3. Changed-path detection — outputs which packages were touched so that | |
| # downstream jobs (test.yml) know what to test | |
| # | |
| # Optimisations vs the old setup: | |
| # • Single runner (ubuntu-22.04), single Flutter version — no duplication | |
| # • Skips ALL checks when only *.md / doc/ / .github/ files changed | |
| # • pub-cache restored from cache before `flutter pub get` | |
| # ───────────────────────────────────────────────────────────────────────────── | |
| env: | |
| FLUTTER_VERSION: "3.41.5" | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| preflight: | |
| name: Format · Analyze · Path-filter | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| # Which packages (or groups) have changed — consumed by test.yml | |
| changed_core: ${{ steps.filter.outputs.core }} | |
| changed_html: ${{ steps.filter.outputs.html }} | |
| changed_markdown: ${{ steps.filter.outputs.markdown }} | |
| changed_highlight: ${{ steps.filter.outputs.highlight }} | |
| changed_clipboard: ${{ steps.filter.outputs.clipboard }} | |
| changed_devtools: ${{ steps.filter.outputs.devtools }} | |
| changed_root: ${{ steps.filter.outputs.root }} | |
| changed_any_dart: ${{ steps.filter.outputs.any_dart }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # ── Detect changed paths ──────────────────────────────────────────────── | |
| - name: Detect changed paths | |
| id: filter | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| core: | |
| - 'packages/hyper_render_core/**' | |
| html: | |
| - 'packages/hyper_render_html/**' | |
| markdown: | |
| - 'packages/hyper_render_markdown/**' | |
| highlight: | |
| - 'packages/hyper_render_highlight/**' | |
| clipboard: | |
| - 'packages/hyper_render_clipboard/**' | |
| devtools: | |
| - 'packages/hyper_render_devtools/**' | |
| root: | |
| - 'lib/**' | |
| - 'test/**' | |
| - 'pubspec.yaml' | |
| - 'pubspec.lock' | |
| any_dart: | |
| - '**/*.dart' | |
| - '**/pubspec.yaml' | |
| - '**/pubspec.lock' | |
| - '**/analysis_options.yaml' | |
| # ── Skip everything if only docs / CI config changed ─────────────────── | |
| - name: Skip if docs-only change | |
| if: steps.filter.outputs.any_dart == 'false' | |
| run: | | |
| echo "✓ Only non-Dart files changed — skipping format & analyze" | |
| echo " (golden.yml and benchmark.yml handle their own triggers)" | |
| # ── Flutter setup (only when Dart files changed) ──────────────────────── | |
| - name: Setup Flutter | |
| if: steps.filter.outputs.any_dart == 'true' | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| channel: stable | |
| cache: true | |
| - name: Restore pub cache | |
| if: steps.filter.outputs.any_dart == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.pub-cache | |
| ${{ env.PUB_CACHE }} | |
| key: pub-ubuntu-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: pub-ubuntu- | |
| - name: flutter pub get | |
| if: steps.filter.outputs.any_dart == 'true' | |
| run: flutter pub get | |
| # ── dart format ───────────────────────────────────────────────────────── | |
| - name: dart format (fail on diff) | |
| if: steps.filter.outputs.any_dart == 'true' | |
| run: dart format --set-exit-if-changed . | |
| # ── flutter analyze ───────────────────────────────────────────────────── | |
| - name: flutter analyze --fatal-infos | |
| if: steps.filter.outputs.any_dart == 'true' | |
| run: | | |
| flutter analyze --no-pub --fatal-warnings --fatal-infos 2>&1 | tee analyze_report.txt | |
| EXIT=${PIPESTATUS[0]} | |
| ERRORS=$(grep -c "error •" analyze_report.txt 2>/dev/null || true) | |
| WARNS=$(grep -c "warning •" analyze_report.txt 2>/dev/null || true) | |
| INFOS=$(grep -c "info •" analyze_report.txt 2>/dev/null || true) | |
| echo "" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| echo " Static Analysis Results" | |
| echo " Errors: $ERRORS" | |
| echo " Warnings: $WARNS" | |
| echo " Infos: $INFOS" | |
| echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" | |
| exit $EXIT | |
| # Sub-packages the root excludes: each one only resolves against its | |
| # own pubspec, so analyze it in place after its own pub get. | |
| - name: flutter analyze sub-packages | |
| if: steps.filter.outputs.any_dart == 'true' | |
| run: | | |
| FAILED="" | |
| for pkg in hyper_render_html hyper_render_markdown hyper_render_highlight \ | |
| hyper_render_math hyper_render_clipboard hyper_render_devtools \ | |
| hyper_render_epub; do | |
| echo "::group::$pkg" | |
| (cd "packages/$pkg" && flutter pub get >/dev/null && \ | |
| flutter analyze --no-pub --fatal-warnings --fatal-infos) || FAILED="$FAILED $pkg" | |
| echo "::endgroup::" | |
| done | |
| if [ -n "$FAILED" ]; then | |
| echo "::error::analyze failed in:$FAILED" | |
| exit 1 | |
| fi | |
| - name: Upload analyze report | |
| if: always() && steps.filter.outputs.any_dart == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: analyze-report-${{ github.run_number }} | |
| path: analyze_report.txt | |
| retention-days: 7 |