|
| 1 | +name: Bench Opt |
| 2 | + |
| 3 | +on: |
| 4 | + # Manual trigger with configurable parameters |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + split: |
| 8 | + description: "Evaluation split (train, validation, holdout)" |
| 9 | + required: false |
| 10 | + default: "validation" |
| 11 | + type: choice |
| 12 | + options: |
| 13 | + - train |
| 14 | + - validation |
| 15 | + - holdout |
| 16 | + dry-run: |
| 17 | + description: "Dry-run mode (skip real execution)" |
| 18 | + required: false |
| 19 | + default: true |
| 20 | + type: boolean |
| 21 | + allow-promotion: |
| 22 | + description: "Allow promotion if gates pass" |
| 23 | + required: false |
| 24 | + default: false |
| 25 | + type: boolean |
| 26 | + |
| 27 | + # Scheduled: daily at 04:00 UTC, weekly full run on Sundays |
| 28 | + schedule: |
| 29 | + - cron: "0 4 * * *" # daily |
| 30 | + - cron: "0 6 * * 0" # weekly (Sunday) |
| 31 | + |
| 32 | + # PR-triggered when labeled with bench-opt |
| 33 | + pull_request: |
| 34 | + types: [labeled] |
| 35 | + |
| 36 | +permissions: |
| 37 | + contents: read |
| 38 | + |
| 39 | +concurrency: |
| 40 | + group: bench-opt-${{ github.ref }} |
| 41 | + cancel-in-progress: true |
| 42 | + |
| 43 | +jobs: |
| 44 | + bench-opt: |
| 45 | + # Only run on manual/schedule, or when the bench-opt label is applied |
| 46 | + if: >- |
| 47 | + github.event_name == 'workflow_dispatch' || |
| 48 | + github.event_name == 'schedule' || |
| 49 | + (github.event_name == 'pull_request' && github.event.label.name == 'bench-opt') |
| 50 | + runs-on: ubuntu-latest |
| 51 | + timeout-minutes: 30 |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Setup pnpm |
| 58 | + uses: pnpm/action-setup@v4 |
| 59 | + with: |
| 60 | + version: 10 |
| 61 | + |
| 62 | + - name: Setup Node.js |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 22 |
| 66 | + cache: pnpm |
| 67 | + |
| 68 | + - name: Install dependencies |
| 69 | + run: pnpm install --frozen-lockfile |
| 70 | + |
| 71 | + - name: Type check |
| 72 | + run: pnpm type-check |
| 73 | + |
| 74 | + - name: Run bench-opt tests |
| 75 | + run: pnpm test -- --reporter=verbose bench-opt/ |
| 76 | + |
| 77 | + - name: Run bench-opt optimizer |
| 78 | + run: pnpm bench:opt |
| 79 | + env: |
| 80 | + BENCH_OPT_SPLIT: ${{ github.event.inputs.split || 'validation' }} |
| 81 | + BENCH_OPT_DRY_RUN: ${{ github.event.inputs.dry-run || 'true' }} |
| 82 | + BENCH_OPT_ALLOW_PROMOTION: ${{ github.event.inputs.allow-promotion || 'false' }} |
| 83 | + |
| 84 | + - name: Install Playwright browsers |
| 85 | + run: npx playwright install chromium --with-deps |
| 86 | + |
| 87 | + - name: Run live smoke scenarios |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + echo "Running live smoke scenarios..." |
| 91 | + pnpm bench:live -- --scenario bench-live/page-translation-article-basic-source-bilingual |
| 92 | + pnpm bench:live -- --scenario bench-live/interaction-priority-basic |
| 93 | + pnpm bench:live -- --scenario bench-live/input-translation-basic |
| 94 | + pnpm bench:live -- --scenario bench-live/frame-coordination-basic |
| 95 | + echo "Live smoke scenarios complete." |
| 96 | + env: |
| 97 | + PLAYWRIGHT_BROWSERS_PATH: 0 |
| 98 | + |
| 99 | + - name: Upload live results |
| 100 | + if: always() |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: bench-live-results-${{ github.run_id }} |
| 104 | + path: bench-live-results/ |
| 105 | + retention-days: 30 |
| 106 | + if-no-files-found: ignore |
| 107 | + |
| 108 | + - name: Upload bench-opt results |
| 109 | + if: always() |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: bench-opt-results-${{ github.run_id }} |
| 113 | + path: | |
| 114 | + bench-opt-results/ |
| 115 | + retention-days: 30 |
| 116 | + if-no-files-found: ignore |
| 117 | + |
| 118 | + - name: Upload promotion artifacts |
| 119 | + if: always() |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: bench-opt-promotions-${{ github.run_id }} |
| 123 | + path: | |
| 124 | + bench-opt-results/promotions/ |
| 125 | + bench-opt-results/publish/ |
| 126 | + bench-opt-results/rollbacks/ |
| 127 | + retention-days: 90 |
| 128 | + if-no-files-found: ignore |
| 129 | + |
| 130 | + - name: Upload store artifacts |
| 131 | + if: always() |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: bench-opt-store-${{ github.run_id }} |
| 135 | + path: | |
| 136 | + bench-opt-results/store/ |
| 137 | + retention-days: 90 |
| 138 | + if-no-files-found: ignore |
| 139 | + |
| 140 | + - name: Summary |
| 141 | + if: always() |
| 142 | + run: | |
| 143 | + echo "## Bench Opt Results" >> $GITHUB_STEP_SUMMARY |
| 144 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 145 | + echo "- **Run ID:** ${{ github.run_id }}" >> $GITHUB_STEP_SUMMARY |
| 146 | + echo "- **Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY |
| 147 | + echo "- **Split:** ${{ github.event.inputs.split || 'validation' }}" >> $GITHUB_STEP_SUMMARY |
| 148 | + echo "- **Dry Run:** ${{ github.event.inputs.dry-run || 'true' }}" >> $GITHUB_STEP_SUMMARY |
| 149 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 150 | + if [ -f bench-opt-results/latest.json ]; then |
| 151 | + echo "### Latest Report" >> $GITHUB_STEP_SUMMARY |
| 152 | + echo '```json' >> $GITHUB_STEP_SUMMARY |
| 153 | + head -50 bench-opt-results/latest.json >> $GITHUB_STEP_SUMMARY |
| 154 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 155 | + fi |
| 156 | + if [ -f bench-live-results/latest.result.json ]; then |
| 157 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 158 | + echo "### Live Smoke Results" >> $GITHUB_STEP_SUMMARY |
| 159 | + echo '```json' >> $GITHUB_STEP_SUMMARY |
| 160 | + head -30 bench-live-results/latest.result.json >> $GITHUB_STEP_SUMMARY |
| 161 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 162 | + fi |
| 163 | + if [ -d bench-opt-results/promotions ]; then |
| 164 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 165 | + echo "### Promotion Artifacts" >> $GITHUB_STEP_SUMMARY |
| 166 | + ls -la bench-opt-results/promotions/ 2>/dev/null >> $GITHUB_STEP_SUMMARY || echo "No promotion artifacts." >> $GITHUB_STEP_SUMMARY |
| 167 | + fi |
0 commit comments