Update viable/strict #35505
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: Update viable/strict | |
| on: | |
| schedule: | |
| - cron: 17,47 * * * * | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| jobs: | |
| do_update_viablestrict: | |
| permissions: | |
| id-token: write | |
| if: ${{ github.repository_owner == 'pytorch' }} | |
| runs-on: ubuntu-22.04 | |
| environment: ${{ (github.event_name == 'schedule') && 'update-viable-strict' || '' }} | |
| steps: | |
| - name: Update viable/strict | |
| id: update | |
| uses: pytorch/test-infra/.github/actions/update-viablestrict@main | |
| with: | |
| repository: pytorch/executorch | |
| stable-branch: viable/strict | |
| requires: '[\"pull\", \"lint\", \"trunk\", \"Build documentation\", \"^Apple$\"]' | |
| secret-bot-token: ${{ secrets.UPDATEBOT_TOKEN }} | |
| clickhouse-url: ${{ secrets.CLICKHOUSE_URL }} | |
| clickhouse-username: ${{ secrets.CLICKHOUSE_VIABLESTRICT_USERNAME }} | |
| clickhouse-password: ${{ secrets.CLICKHOUSE_VIABLESTRICT_PASSWORD }} | |
| - name: Summarize CI failures | |
| if: steps.update.outputs.latest_viable_sha == 'None' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "## ❌ No green commit found" >> $GITHUB_STEP_SUMMARY | |
| echo "No green commit found" | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "viable/strict branch was not updated because no commit passed all required checks." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Pattern matching required workflows (must match 'requires' input above) | |
| # Uses exact matching with anchors and case-insensitive matching | |
| REQUIRED_PATTERN="^pull$|^lint$|^trunk$|^Build documentation$|^Apple$" | |
| echo "### Failures by commit (recent)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Get commits between viable/strict and main using GitHub API | |
| VIABLE_SHA=$(gh api repos/pytorch/executorch/git/ref/heads/viable/strict --jq '.object.sha' 2>/dev/null || echo "") | |
| MAIN_SHA=$(gh api repos/pytorch/executorch/git/ref/heads/main --jq '.object.sha' 2>/dev/null || echo "") | |
| found_failures=false | |
| if [ -n "$VIABLE_SHA" ] && [ -n "$MAIN_SHA" ]; then | |
| # Get commits between viable/strict and main (up to 20) | |
| # Use ASCII unit separator (0x1f) to avoid issues with special chars in names | |
| COMMITS=$(gh api "repos/pytorch/executorch/compare/${VIABLE_SHA}...${MAIN_SHA}" \ | |
| --jq '.commits | reverse | .[:20] | .[] | "\(.sha)\u001f\(.commit.message | split("\n")[0] | .[:50])"' 2>/dev/null || echo "") | |
| if [ -n "$COMMITS" ]; then | |
| echo "| Commit | Title | Failed Job (up to 5 jobs) |" >> $GITHUB_STEP_SUMMARY | |
| echo "|--------|-------|---------------------------|" >> $GITHUB_STEP_SUMMARY | |
| while IFS=$'\x1f' read -r sha title; do | |
| [ -z "$sha" ] && continue | |
| short_sha="${sha:0:7}" | |
| # Sanitize title for markdown table | |
| title=$(echo "$title" | tr '|' '-') | |
| # Get workflow runs for this commit (use unit separator) | |
| # Only include workflows that match the requires patterns (case-insensitive) | |
| # Show up to 5 failed workflows per commit | |
| failed_runs=$(gh api "repos/pytorch/executorch/actions/runs?head_sha=${sha}&per_page=100" \ | |
| --jq ".workflow_runs[] | select(.conclusion == \"failure\" and (.name | test(\"${REQUIRED_PATTERN}\"; \"i\"))) | \"\(.id)\u001f\(.name)\"" 2>/dev/null | head -5) | |
| if [ -n "$failed_runs" ]; then | |
| # Collect all failed jobs for this commit | |
| all_failed_jobs="" | |
| while IFS=$'\x1f' read -r run_id workflow_name; do | |
| [ -z "$run_id" ] && continue | |
| workflow_name=$(echo "$workflow_name" | tr '|' '-') | |
| # Get failed job names (up to 5 per workflow) | |
| failed_jobs=$(gh api "repos/pytorch/executorch/actions/runs/${run_id}/jobs?per_page=100" \ | |
| --jq '.jobs[] | select(.conclusion == "failure") | .name' 2>/dev/null | head -5) | |
| if [ -n "$failed_jobs" ]; then | |
| while read -r failed_job; do | |
| [ -z "$failed_job" ] && continue | |
| failed_job=$(echo "$failed_job" | tr '|' '-') | |
| if [ -n "$all_failed_jobs" ]; then | |
| all_failed_jobs="${all_failed_jobs}<br>${workflow_name} / ${failed_job}" | |
| else | |
| all_failed_jobs="${workflow_name} / ${failed_job}" | |
| fi | |
| done <<< "$failed_jobs" | |
| else | |
| if [ -n "$all_failed_jobs" ]; then | |
| all_failed_jobs="${all_failed_jobs}<br>${workflow_name} / unknown" | |
| else | |
| all_failed_jobs="${workflow_name} / unknown" | |
| fi | |
| fi | |
| done <<< "$failed_runs" | |
| echo "| ${short_sha} | ${title} | ${all_failed_jobs} |" >> $GITHUB_STEP_SUMMARY | |
| found_failures=true | |
| fi | |
| done <<< "$COMMITS" | |
| fi | |
| fi | |
| if [ "$found_failures" = false ]; then | |
| # Fallback: show recent failed runs from main branch only | |
| echo "> Note: Could not determine commits between branches. Showing recent failures from main branch." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| Commit | Title | Failed Job |" >> $GITHUB_STEP_SUMMARY | |
| echo "|--------|-------|------------|" >> $GITHUB_STEP_SUMMARY | |
| # Filter by branch=main and use unit separator | |
| # Only include workflows that match the requires patterns (case-insensitive) | |
| gh api "repos/pytorch/executorch/actions/runs?branch=main&per_page=20" \ | |
| --jq ".workflow_runs[] | select(.conclusion == \"failure\" and (.name | test(\"${REQUIRED_PATTERN}\"; \"i\"))) | \"\(.id)\u001f\(.head_sha | .[:7])\u001f\(.display_title | .[:50])\u001f\(.name)\"" 2>/dev/null | \ | |
| while IFS=$'\x1f' read -r run_id sha title workflow; do | |
| # Sanitize for markdown table | |
| title=$(echo "$title" | tr '|' '-') | |
| workflow=$(echo "$workflow" | tr '|' '-') | |
| failed_job=$(gh api "repos/pytorch/executorch/actions/runs/${run_id}/jobs?per_page=100" \ | |
| --jq '.jobs[] | select(.conclusion == "failure") | .name' 2>/dev/null | head -1 | tr '|' '-') | |
| if [ -n "$failed_job" ]; then | |
| echo "| ${sha} | ${title} | ${workflow} / ${failed_job} |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| done | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Summary by job (main branch, last 24h)" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| # Filter by main branch and created in last 24 hours (GNU date syntax for Ubuntu runner) | |
| # Only include workflows that match the requires patterns (case-insensitive) | |
| yesterday=$(date -u -d '24 hours ago' '+%Y-%m-%dT%H:%M:%SZ') | |
| gh api "repos/pytorch/executorch/actions/runs?branch=main&created=>${yesterday}&per_page=100" \ | |
| --jq ".workflow_runs[] | select(.conclusion == \"failure\" and (.name | test(\"${REQUIRED_PATTERN}\"; \"i\"))) | .name" 2>/dev/null \ | |
| | sort | uniq -c | sort -rn | head -10 >> $GITHUB_STEP_SUMMARY || echo "Failed to fetch data" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "::error::No green commit found - viable/strict was not updated" | |
| exit 1 |