gaogaotiantian opened a new pull request, #60365: URL: https://github.com/apache/spark/pull/60365
### What changes were proposed in this pull request? This PR adds `dev/visualize_ci_schedule.py`, which renders the schedule of the scheduled GitHub Actions workflows as an SVG image, `.github/workflows/images/scheduled-ci.svg`, checked into the repo and linked from the "Scheduled workflow cadence" section of `.github/workflows/README.md`. The script: - Reads every `cron:` entry in `.github/workflows`. Directly scheduled workflows run on `master`. For the `branch*_scheduler.yml` workflows, it follows each cron YAML anchor through the `env.*_CRON` condition of a step to the `dev/dispatch-if-changed.sh <workflow> <branch>` call, so branch builds are attributed to the dispatched workflow and branch. - Draws one timeline panel per cadence (every 3 days by day-of-month phase, weekly by day of week, and daily if any). Each run is a bar from its cron start time, as long as its estimated duration, as thick as its estimated number of runners, and labeled like `A 08:17, 2.5h x 8`. Under each panel, a strip shows the runner load of that panel. - Draws a heatmap of the combined runner load over 21 days, which covers every combination of the 3-day phase and the weekday once. Each cell is the peak number of runners in use in that hour. Each day also shows the runs starting that day, the runner-hours used, and their share of the ASF daily budget (25 runners x 24h). - Compares the load with the [ASF GitHub Actions limits](https://infra.apache.org/github-actions-policy.html), which are averages over all apache/spark workflows. Currently, the busiest 7 days use 40% of the weekly limit of 25 runners, and the busiest 5 days use 34% of the five-day limit of 30 runners. - Keeps the estimated duration and average runner count of each workflow in an `ESTIMATES` table. The values are medians of the latest 10 first-attempt runs on apache/spark, preferring successful runs. `--sample` measures them again with the GitHub CLI and prints a new table. Scheduled workflows that usually finish within an hour and do not run tests (image cache, pages, stale, build status, labeler) are listed in `EXCLUDED_WORKFLOWS` and named in the image's notes. Every scheduled workflow must be in one of the two tables, and entries for workflows that are no longer scheduled are rejected, so the tables stay in sync with the workflows. The script only uses the Python standard library, and its output is deterministic: it does not depend on the time, the Python version, the hash seed, the locale, or the working directory. A new "Scheduled CI image check" step in the lint job runs `./dev/visualize_ci_schedule.py --check`, which fails when the image is out of date with the workflow schedules or the estimates, and makes no network calls. The image on this branch: https://github.com/gaogaotiantian/spark/blob/ci-schedule-viz/.github/workflows/images/scheduled-ci.svg ### Why are the changes needed? The scheduled workflows are spread across many workflow files and branch schedulers with three-day and weekly cadences, which makes it hard to see whether they are evenly distributed, where the load peaks, and which slots are free when rescheduling a workflow. A single image, kept up to date by the lint job, answers these questions at a glance and shows how much of the ASF limits the scheduled CI takes. ### Does this PR introduce _any_ user-facing change? No. It only adds a development script, a generated image, a README section, and a lint step. ### How was this patch tested? - Generated the image and checked its layout by rendering it in headless Chrome. - Checked that the output is byte-identical across repeated runs, `PYTHONHASHSEED` values, Python 3.6, 3.10, 3.11 and 3.12, other working directories, time zones and locales, and that the CI command `./dev/visualize_ci_schedule.py --check` passes in a clean environment without `gh` and does not modify the image. Generation takes about 20 ms. - Checked that `--check` fails when a branch scheduler cron, a direct cron, a dispatch target, an estimate, or an ASF limit changes, or when the image is edited by hand or missing, and that it passes again after regenerating. It also rejects scheduled workflows without an estimate; this caught `labeler.yml`, which was added upstream while this PR was being written. - Ran `--sample` against apache/spark to produce the current estimates. - `ruff check` and `ruff format --diff` pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Isaac (Claude Code, Claude Opus 5.5) This pull request and its description were written by Isaac. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
