Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenXLA-pin-update trigger] Create _openxla_pin_update_weekly.yml #7108

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
79 changes: 79 additions & 0 deletions .github/workflows/openxla_pin_update_weekly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Weekly Code Update PR
on:
workflow_dispatch: # Manual trigger
schedule:
- cron: '0 9 * * 1' # Each Monday 9:00AM (PDT time)
ManfeiBai marked this conversation as resolved.
Show resolved Hide resolved

jobs:
update_and_create_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get current date
run: echo "CURRENT_DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Create new branch
run: git checkout -b weekly-update-${{ env.CURRENT_DATE }}

- name: Install sed
run: sudo apt-get update && sudo apt-get install -y sed

- name: Get JAX version for specified date
run: |
JAX_VERSION=$(curl -s https://storage.googleapis.com/jax-releases/jax_releases.json | jq -r '.[] | select(.released_on == "${{ env.CURRENT_DATE }}") | .version')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is https://storage.googleapis.com/jax-releases/jax_releases.json the correct path? I don't see a JSON file when I gsutil ls gs://jax-releases.

$ curl https://storage.googleapis.com/jax-releases/jax_releases.json
<?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: jax-releases/jax_releases.json</Details></Error

if [ -z "$JAX_VERSION" ]; then
echo "No JAX release found for ${{ env.CURRENT_DATE }}. Skipping update."
exit 0
fi
echo "JAX_VERSION=$JAX_VERSION" >> $GITHUB_ENV

- name: Update date in setup.py
run: |
sed -i "s/_date =.*/_date = '${{ env.CURRENT_DATE }}'/" ${FILE_PATH}
sed -i "s/_jax_version =.*/_jax_version = f'${{ env.JAX_VERSION }}.dev${{ env.CURRENT_DATE }}'/" ${FILE_PATH}
git add ${FILE_PATH}
# git commit -m "Weekly update setup.py to (${{ env.CURRENT_DATE }})"
# git push origin HEAD
env:
FILE_PATH: setup.py

- name: Fetch HEAD commit from OpenXLA github repo
run: |
git remote add target https://github.com/openxla/xla.git
ManfeiBai marked this conversation as resolved.
Show resolved Hide resolved
git fetch target
echo "HEAD_COMMIT=$(git rev-parse target/main)" >> $GITHUB_ENV

- name: Update OpenXLA commit in WORKSPACE
ManfeiBai marked this conversation as resolved.
Show resolved Hide resolved
run: |
sed -i "s/xla_hash =.*/xla_hash = '${{ env.GITHUB_ENV }}'/" ${FILE_PATH}
git add ${FILE_PATH}
git commit -m "Weekly update WORKSPACE with (${{ env.GITHUB_ENV }})"
git push origin HEAD
env:
FILE_PATH: WORKSPACE

- name: Create Pull Request
uses: actions/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: weekly-update
ManfeiBai marked this conversation as resolved.
Show resolved Hide resolved
base: main
title: "Weekly Code Update - ${{ env.CURRENT_DATE }}"
body: "This PR contains the weekly OpenXLA-pin update at commit: (HEAD commit: ${{ env.HEAD_COMMIT }}), with libtpu version at ${{ env.CURRENT_DATE }}."

- name: Add TPUCI label
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create-pull-request has a labels option: https://github.com/marketplace/actions/create-pull-request#action-inputs

If the label is not on the PR when it is created, the TPU CI will not run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, have we used create-pull-request before? wanna confirm before use

uses: actions/github-script@v6
if: ${{ github.event_name == 'schedule' }} # Only label scheduled PRs
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['tpuci']
})


Loading