From 3db7af73e32da40dd59aec5e4cfe91a25103e87c Mon Sep 17 00:00:00 2001 From: Michael Tarnawa Date: Wed, 6 Dec 2023 10:30:52 +0100 Subject: [PATCH] Update pytorch release PR workflow (#1286) * Update pytorch-latest-release.yml * Update latest-pytorch-support.yml * Delete .github/workflows/pytorch-latest-main.yml * Update checkout version --------- Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> --- .github/workflows/ci.yaml | 2 +- .github/workflows/latest-pytorch-support.yml | 37 ++++++++------------ .github/workflows/pytorch-latest-main.yml | 34 ------------------ .github/workflows/pytorch-latest-release.yml | 12 +++++-- 4 files changed, 26 insertions(+), 59 deletions(-) delete mode 100644 .github/workflows/pytorch-latest-main.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4da49b8e33..38e6f64a49 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,7 +37,7 @@ jobs: name: Python ${{ matrix.py-version }} with ${{ matrix.pytorch-version }}; options ${{ matrix.install-options }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup MPI uses: mpi4py/setup-mpi@v1 with: diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 94b23e0ad7..f4ad99c1fd 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -1,14 +1,14 @@ name: Support latest PyTorch on: - push: - branches: - - 'support/new-pytorch-release-branch' - - 'support/new-pytorch-main-branch' - paths: - - '.github/pytorch-release-versions/*' -env: - working_branch: ${{ github.ref }} + workflow_call: + inputs: + working_branch: + required: true + type: string + base_branch: + required: true + type: string permissions: contents: write issues: write @@ -17,7 +17,7 @@ jobs: latest-torch-support: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: JasonEtco/create-an-issue@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -29,10 +29,10 @@ jobs: update_existing: true search_existing: open - name: Check out new branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - ref: '${{ env.working_branch }}' + ref: '${{ inputs.working_branch }}' - name: Set env variables run: | echo "previous_pytorch=$(grep 'torch>=' setup.py | awk -F '<' '{print $2}' | tr -d '",')" >> $GITHUB_ENV @@ -44,22 +44,15 @@ jobs: - name: Update setup.py run: | sed -i '/torch>=/ s/'"${{ env.previous_pytorch }}"'/'"${{ env.setup_pytorch }}"'/g' setup.py - - name: Define base branch - run: | - if [[ ${{ github.ref }} =~ .*main.* ]]; then - echo "base_branch=main" >> $GITHUB_ENV - elif [[ ${{ github.ref }} =~ .*release.* ]]; then - echo "base_branch=release/1.2.x" >> $GITHUB_ENV - fi - name: Create PR from branch - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@v5 with: - base: ${{ env.base_branch }} - branch: ${{ env.working_branch }} + base: ${{ inputs.base_branch }} + branch: ${{ inputs.working_branch }} delete-branch: true token: ${{ secrets.GITHUB_TOKEN }} commit-message: Support latest PyTorch release - title: Support PyTorch ${{ env.new_pytorch }} on branch ${{ env.base_branch }} + title: Support PyTorch ${{ env.new_pytorch }} on branch ${{ inputs.base_branch }} body: | Run tests on latest PyTorch release Issue/s resolved: #${{ steps.create-issue.outputs.number }} diff --git a/.github/workflows/pytorch-latest-main.yml b/.github/workflows/pytorch-latest-main.yml deleted file mode 100644 index c59736c82f..0000000000 --- a/.github/workflows/pytorch-latest-main.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Get latest PyTorch version main branch -on: - workflow_dispatch: -env: - working_branch: support/new-pytorch-main-branch - base_branch: main -permissions: - contents: write -jobs: - get-version: - runs-on: ubuntu-latest - if: ${{ github.repository }} == 'hemlholtz-analytics/heat' - steps: - - uses: actions/checkout@v4 - with: - ref: '${{ env.base_branch }}' - - name: Fetch PyTorch release version - run: | - curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | \ - jq -r ".tag_name" | tr -d 'v' > .github/pytorch-release-versions/pytorch-latest.txt - - name: Check if file has been modified - id: git-check - run: echo "::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true")" - - name: Delete working branch if it already exists - run: git push --delete origin ${{ env.working_branch }} || true - - name: Commit latest PyTorch release version to new branch - if: ${{ steps.git-check.outputs.modified == 'true' }} - run: | - git checkout -b ${{ env.working_branch }} - echo "new=$(<.github/pytorch-release-versions/pytorch-latest.txt)" >> $GITHUB_ENV - git config --global user.name 'ClaudiaComito' - git config --global user.email 'c.comito@fz-juelich.de@users.noreply.github.com' - git commit -am "New PyTorch release ${{ env.new }}" - git push --set-upstream origin ${{ env.working_branch }} diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 6126fa610a..26094dc0d0 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -2,10 +2,12 @@ name: Get latest PyTorch version release branch on: workflow_dispatch: env: - working_branch: support/new-pytorch-release-branch - base_branch: release/1.2.x + working_branch: support/new-pytorch-${{ github.ref_name }} + base_branch: ${{ github.ref_name }} permissions: contents: write + issues: write + pull-requests: write jobs: get-version: runs-on: ubuntu-latest @@ -32,3 +34,9 @@ jobs: git config --global user.email 'c.comito@fz-juelich.de@users.noreply.github.com' git commit -am "New PyTorch release ${{ env.new }}" git push --set-upstream origin ${{ env.working_branch }} + call-workflow: + needs: get-version + uses: ./.github/workflows/latest-pytorch-support.yml + with: + working_branch: support/new-pytorch-${{ github.ref_name }} + base_branch: ${{ github.ref_name }}