pytorch/.github/scripts
Catherine Lee 200108c6e6 Delete old branches (#117079)
Example https://github.com/pytorch/pytorch/actions/runs/7562281351/job/20592425611?pr=117079 (The code to delete branches isn't being run, it's just listing the branches it wants to delete)

Internal code: https://fburl.com/code/hdvvbfkj

Threshold for branch with PR is 30 days regardless of whether or not the PR is merged or not (compared to 3 days if merged and 30 days if closed).  Threshold for branch without PR is 1.5 years (same internally).

Threshold of ~400 queries to github so it doesn't hit token usage limits.  Currently this leads to about 350 branches deleted per run.

Only query for the last 90 days of updated PRs to reduce token usage, so if a branch has a PR but it was updated 90+ days ago, it will think it doesn't have a PR and will wait for the 1.5 years branch update check instead, regardless of whether the PR is open or closed.

I tested that it could delete my own branch and it worked.

labeled with test-config/crossref because I just want the smallest test config possible to reduce CI usage
Pull Request resolved: https://github.com/pytorch/pytorch/pull/117079
Approved by: https://github.com/malfet
2024-02-05 20:50:05 +00:00
..
build_triton_wheel.py Update Triton pin (#117873) 2024-01-23 21:05:30 +00:00
check_labels.py
close_nonexistent_disable_issues.py
collect_ciflow_labels.py
comment_on_pr.py
convert_lintrunner_annotations_to_github.py
delete_old_branches.py Delete old branches (#117079) 2024-02-05 20:50:05 +00:00
drci_mocks.json.gz Improve the error message when a PR lacks the necessary approvals (#116161) 2023-12-22 00:22:43 +00:00
ensure_actions_will_cancel.py
export_pytorch_labels.py
file_io_utils.py
filter_test_configs.py [CI] Filter should not fail if pr_body is empty (#118934) 2024-02-02 00:49:20 +00:00
generate_binary_build_matrix.py Upgrade nightly wheels to rocm6.0 (#116983) 2024-01-11 20:36:00 +00:00
generate_ci_workflows.py [CI] Build M1 conda binaries on M1 runners (#117801) 2024-01-19 14:31:12 +00:00
generate_docker_release_matrix.py s/verison/version/ (#118749) 2024-01-31 19:23:55 +00:00
generate_pytorch_version.py
get_workflow_job_id.py [ci][ez] Add job_id to emit_metrics (#113099) 2023-11-08 10:32:41 +00:00
github_utils.py Delete old branches (#117079) 2024-02-05 20:50:05 +00:00
gitutils.py Fix mergeability check for ghstack PRs (#118258) 2024-01-26 03:15:56 +00:00
gql_mocks.json.gz [GHF] Add co-authors to PR (#118347) 2024-01-27 01:02:49 +00:00
kill_active_ssh_sessions.ps1
label_utils.py [mergebot] Dry run for labels + easier to read Dr CI result (#118240) 2024-01-25 23:06:43 +00:00
lint_native_functions.py
parse_ref.py
pr-sanity-check.sh
pytest_cache.py [td] Consistent pytest cache (#113804) 2023-11-17 23:45:47 +00:00
pytest_caching_utils.py [td] Consistent pytest cache (#113804) 2023-11-17 23:45:47 +00:00
README.md
report_git_status.sh
rockset_mocks.json.gz
stop_runner_service.sh
tag_docker_images_for_release.py [RelEng] Tag docker images for release, pin unstable and disabled jobs, apply release only changes (#114355) 2023-11-23 02:14:22 +00:00
test_check_labels.py
test_filter_test_configs.py Various CI settings (#117668) 2024-01-26 00:17:29 +00:00
test_gitutils.py
test_label_utils.py
test_pytest_caching_utils.py
test_trymerge.py Delete old branches (#117079) 2024-02-05 20:50:05 +00:00
test_tryrebase.py
trymerge.py Delete old branches (#117079) 2024-02-05 20:50:05 +00:00
trymerge_explainer.py
tryrebase.py [GHF] Abort merge on rebase failure (#113960) 2023-11-17 23:11:00 +00:00
wait_for_ssh_to_drain.ps1

pytorch/.github

NOTE: This README contains information for the .github directory but cannot be located there because it will overwrite the repo README.

This directory contains workflows and scripts to support our CI infrastructure that runs on GitHub Actions.

Workflows

  • Pull CI (pull.yml) is run on PRs and on main.
  • Trunk CI (trunk.yml) is run on trunk to validate incoming commits. Trunk jobs are usually more expensive to run so we do not run them on PRs unless specified.
  • Scheduled CI (periodic.yml) is a subset of trunk CI that is run every few hours on main.
  • Binary CI is run to package binaries for distribution for all platforms.

Templates

Templates written in Jinja are located in the .github/templates directory and used to generate workflow files for binary jobs found in the .github/workflows/ directory. These are also a couple of utility templates used to discern common utilities that can be used amongst different templates.

(Re)Generating workflow files

You will need jinja2 in order to regenerate the workflow files which can be installed using:

pip install -r .github/requirements/regenerate-requirements.txt

Workflows can be generated / regenerated using the following command:

.github/regenerate.sh

Adding a new generated binary workflow

New generated binary workflows can be added in the .github/scripts/generate_ci_workflows.py script. You can reference examples from that script in order to add the workflow to the stream that is relevant to what you particularly care about.

Different parameters can be used to achieve different goals, i.e. running jobs on a cron, running only on trunk, etc.

ciflow (trunk)

The label ciflow/trunk can be used to run trunk only workflows. This is especially useful if trying to re-land a PR that was reverted for failing a non-default workflow.

Infra

Currently most of our self hosted runners are hosted on AWS, for a comprehensive list of available runner types you can reference .github/scale-config.yml.

Exceptions to AWS for self hosted:

  • ROCM runners

Adding new runner types

New runner types can be added by committing changes to .github/scale-config.yml. Example: https://github.com/pytorch/pytorch/pull/70474

NOTE: New runner types can only be used once the changes to .github/scale-config.yml have made their way into the default branch

Testing pytorch/builder changes

In order to test changes to the builder scripts:

  1. Specify your builder PR's branch and repo as builder_repo and builder_branch in .github/templates/common.yml.j2.
  2. Regenerate workflow files with .github/regenerate.sh (see above).
  3. Submit fake PR to PyTorch. If changing binaries build, add an appropriate label like ciflow/binaries to trigger the builds.