From ae9b17ad149d99d0eb60176c8afddd44cc7c8ec0 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Fri, 20 May 2022 16:09:39 +0000 Subject: [PATCH] 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 --- .github/workflows/update-xla-commit-hash.yml | 64 ++++++++++++++++++++ .github/xla_commit_hash.txt | 1 + .jenkins/pytorch/common_utils.sh | 4 ++ 3 files changed, 69 insertions(+) create mode 100644 .github/workflows/update-xla-commit-hash.yml create mode 100644 .github/xla_commit_hash.txt diff --git a/.github/workflows/update-xla-commit-hash.yml b/.github/workflows/update-xla-commit-hash.yml new file mode 100644 index 00000000000..8b39bfe554d --- /dev/null +++ b/.github/workflows/update-xla-commit-hash.yml @@ -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('') + }); diff --git a/.github/xla_commit_hash.txt b/.github/xla_commit_hash.txt new file mode 100644 index 00000000000..e996a13b3ad --- /dev/null +++ b/.github/xla_commit_hash.txt @@ -0,0 +1 @@ +7f96fbf6f7e37810a805c741416e7c54ae65c8cd diff --git a/.jenkins/pytorch/common_utils.sh b/.jenkins/pytorch/common_utils.sh index 4b0c75aa0ed..9939641a5bc 100644 --- a/.jenkins/pytorch/common_utils.sh +++ b/.jenkins/pytorch/common_utils.sh @@ -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 }