Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/update_llvm_sha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Copyright 2025 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: Update LLVM SHA

on:
workflow_dispatch:
inputs:
branch-name:
default: "integrates/llvm"
type: string
description: The branch name to put updates on
schedule:
# Weekly on Monday at 09:00 AM UTC
- cron: "0 9 * * 1"

permissions:
contents: write
pull-requests: write

env:
GIT_BRANCH_NAME: ${{ inputs.branch-name || 'integrates/llvm' }}
LLVM_REPO: https://github.com/llvm/llvm-project.git
LLVM_SHA_FILE: water/llvm-sha.txt

jobs:
check-for-existing-branch:
if: ${{ github.repository_owner == 'iree-org' || github.event_name != 'schedule' }}
runs-on: ubuntu-22.04
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use 24 here for longer term support?

Suggested change
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess? It was copypasted from exisitng update iree script

Copy link
Member

Choose a reason for hiding this comment

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

Please link to the script somewhere (e.g. in the PR description)

We've had a few iterations of automated updates. I want to check which you forked and if there were known issues with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

outputs:
branch-exists: ${{ steps.check-exists.outputs.branch-exists }}

steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Check for existing integrate branch
id: check-exists
run: |
BRANCH_EXISTS=$(git ls-remote --exit-code --heads origin ${{ env.GIT_BRANCH_NAME }} | wc -l)
echo branch-exists=${BRANCH_EXISTS} >> "${GITHUB_OUTPUT}"
if [[ ${BRANCH_EXISTS} == 1 ]]; then
echo "Skipping update PR creation since the \`${{ env.GIT_BRANCH_NAME }}\` branch already exists." >> ${GITHUB_STEP_SUMMARY}
fi

update-llvm:
needs: check-for-existing-branch
runs-on: ubuntu-22.04
if: ${{ needs.check-for-existing-branch.outputs.branch-exists == 0 }}

steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0

- name: Get current LLVM SHA
id: current-sha
run: |
CURRENT_SHA=$(cat ${{ env.LLVM_SHA_FILE }} | tr -d '[:space:]')
echo "current=${CURRENT_SHA}" >> "${GITHUB_OUTPUT}"
echo "Current LLVM SHA: ${CURRENT_SHA}" >> ${GITHUB_STEP_SUMMARY}

- name: Get latest LLVM SHA
id: latest-sha
run: |
LATEST_SHA=$(git ls-remote ${{ env.LLVM_REPO }} HEAD | awk '{print $1}')
echo "latest=${LATEST_SHA}" >> "${GITHUB_OUTPUT}"
echo "Latest LLVM SHA: ${LATEST_SHA}" >> ${GITHUB_STEP_SUMMARY}

- name: Update LLVM SHA file
if: ${{ steps.current-sha.outputs.current != steps.latest-sha.outputs.latest }}
run: |
echo "${{ steps.latest-sha.outputs.latest }}" > ${{ env.LLVM_SHA_FILE }}
echo "Updated ${{ env.LLVM_SHA_FILE }} to ${{ steps.latest-sha.outputs.latest }}" >> ${GITHUB_STEP_SUMMARY}

- uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
if: ${{ steps.current-sha.outputs.current != steps.latest-sha.outputs.latest && env.CREATE_PULL_REQUEST_TOKEN_APP_ID != '' && env.CREATE_PULL_REQUEST_TOKEN_APP_PRIVATE_KEY != '' }}
id: generate-token
with:
app-id: ${{ secrets.CREATE_PULL_REQUEST_TOKEN_APP_ID }}
private-key: ${{ secrets.CREATE_PULL_REQUEST_TOKEN_APP_PRIVATE_KEY }}
env:
CREATE_PULL_REQUEST_TOKEN_APP_ID: ${{ secrets.CREATE_PULL_REQUEST_TOKEN_APP_ID }}
CREATE_PULL_REQUEST_TOKEN_APP_PRIVATE_KEY: ${{ secrets.CREATE_PULL_REQUEST_TOKEN_APP_PRIVATE_KEY }}

- name: Create or update pull request
if: ${{ steps.current-sha.outputs.current != steps.latest-sha.outputs.latest }}
id: cpr
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
with:
token: ${{ steps.generate-token.outputs.token || secrets.GITHUB_TOKEN }}
base: main
branch: ${{ env.GIT_BRANCH_NAME }}
author: iree-pr-automator[bot] <[email protected]>
signoff: true
title: "Bump LLVM to latest upstream commit"
body: |
This PR updates the LLVM commit SHA in `${{ env.LLVM_SHA_FILE }}` to the latest upstream commit.

**Current SHA:** `${{ steps.current-sha.outputs.current }}`
**Latest SHA:** `${{ steps.latest-sha.outputs.latest }}`

Commit diff: https://github.com/llvm/llvm-project/compare/${{ steps.current-sha.outputs.current }}...${{ steps.latest-sha.outputs.latest }}

Auto-generated by GitHub Actions using [`.github/workflows/update_llvm_sha.yml`](https://github.com/${{ github.repository }}/blob/main/.github/workflows/update_llvm_sha.yml).
commit-message: "Bump LLVM to ${{ steps.latest-sha.outputs.latest }}"

- name: Write summary
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request URL: ${{ steps.cpr.outputs.pull-request-url }}" >> ${GITHUB_STEP_SUMMARY}

- name: No update needed
if: ${{ steps.current-sha.outputs.current == steps.latest-sha.outputs.latest }}
run: |
echo "No update needed. LLVM is already at the latest commit: ${{ steps.current-sha.outputs.current }}" >> ${GITHUB_STEP_SUMMARY}
Loading