auto make pr for xla pinned hash (#77824)

see https://docs.google.com/document/d/1jRT-on-v8bcTCHD8aGFH7IuCDR7JL37GlP6Z2EYgmyk/edit#

add file with hash, add nightly job that makes a pr to update the hash, pr needs to be manually accepted (for now? maybe can get bot to approve it automatically later)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/77824
Approved by: https://github.com/janeyx99
This commit is contained in:
Catherine Lee 2022-05-20 16:09:39 +00:00 committed by PyTorch MergeBot
parent b9087b664f
commit ae9b17ad14
3 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,64 @@
name: Update xla commit hash
on:
schedule:
# Every day at 12:37am
# Choose a random time near midnight because it may be delayed if there are high loads
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: 37 0 * * *
workflow_dispatch:
env:
NEW_BRANCH_NAME: update-xla-commit-hash/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
jobs:
update-xla-commit-hash:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: false
- name: Checkout xla
shell: bash
run: |
git clone https://github.com/pytorch/xla.git --depth=1 --quiet
- name: Get new commit hash and update file
id: update-file
shell: bash
run: |
echo "::set-output name=original_commit::$(cat .github/xla_commit_hash.txt)"
pushd xla
git rev-parse master > ../.github/xla_commit_hash.txt
popd
if [[ $(git diff --exit-code .github/xla_commit_hash.txt) ]]; then
git checkout -b "${NEW_BRANCH_NAME}"
git config --global user.email "pytorchmergebot@users.noreply.github.com"
git config --global user.name "PyTorch MergeBot"
git add .github/xla_commit_hash.txt
git commit -m "update xla commit hash"
git push --set-upstream origin "${NEW_BRANCH_NAME}"
echo "::set-output name=new_commit::$(cat .github/xla_commit_hash.txt)"
fi
- name: Create Pull Request
uses: actions/github-script@v6
if: ${{ steps.update-file.outputs.new_commit }}
env:
ORIGINAL_COMMIT: ${{ steps.update-file.outputs.original_commit }}
NEW_COMMIT: ${{ steps.update-file.outputs.new_commit }}
with:
script: |
const { repo, owner } = context.repo;
const { NEW_BRANCH_NAME, NEW_COMMIT, ORIGINAL_COMMIT } = process.env
const result = await github.rest.pulls.create({
title: '[XLA hash update] update the pinned xla hash',
owner,
repo,
head: `${NEW_BRANCH_NAME}`,
base: 'master',
body: [
'This PR is auto-generated nightly by [this action](https://github.com/pytorch/pytorch/blob/master/.github/workflows/update-xla-commit-hash.yml).\n',
`Update the pinned xla hash from \`${ORIGINAL_COMMIT}\` to \`${NEW_COMMIT}\`.`
].join('')
});

1
.github/xla_commit_hash.txt vendored Normal file
View file

@ -0,0 +1 @@
7f96fbf6f7e37810a805c741416e7c54ae65c8cd

View file

@ -100,5 +100,9 @@ function checkout_install_torchvision() {
function clone_pytorch_xla() {
if [[ ! -d ./xla ]]; then
git clone --recursive --quiet https://github.com/pytorch/xla.git
pushd xla
# pin the xla hash so that we don't get broken by changes to xla
git checkout "$(cat ../.github/xla_commit_hash.txt)"
popd
fi
}