-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Enqueue | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
jobs: | ||
build: | ||
if: github.event.issue.number == 1312 && github.event.sender.type == 'User' | ||
runs-on: self-hosted | ||
|
||
permissions: | ||
issues: write | ||
pull-requests: write | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: false | ||
fetch-depth: 0 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git submodule update --init llvm/llvm-project | ||
git -C llvm/llvm-project checkout . | ||
git -C llvm/llvm-project clean -fdx | ||
- name: Set up pre-commit info | ||
id: info | ||
run: | | ||
echo -e "> $PATCH_URL\n\n" > ${{ github.workspace }}/scripts/issue.md | ||
python3 ${{ github.workspace }}/scripts/enqueue.py 2>&1 | tee -a ${{ github.workspace }}/scripts/issue.md | ||
env: | ||
PATCH_URL: ${{ github.event.comment.body }} | ||
USER: ${{ github.event.sender.login }} | ||
|
||
- name: Create PR | ||
if: steps.info.outputs.SHOULD_OPEN_PR == '1' | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
branch: "test-run${{ github.run_id }}" | ||
commit-message: "pre-commit: PR${{ steps.info.outputs.PR_TITLE }}" | ||
title: "pre-commit: PR${{ steps.info.outputs.PR_TITLE }}" | ||
add-paths: scripts/setup_pre_commit_patch.sh | ||
body: | | ||
Link: ${{ github.event.comment.body }} | ||
Requested by: @${{ github.event.sender.login }} | ||
- name: Update report | ||
if: ${{ steps.cpr.outputs.pull-request-number }} | ||
run: | ||
echo -e "> ${{ github.event.comment.body }}\n\nSee ${{ steps.cpr.outputs.pull-request-url }}" > ${{ github.workspace }}/scripts/issue.md | ||
|
||
- name: Comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body-path: ${{ github.workspace }}/scripts/issue.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import subprocess | ||
from urllib.parse import urlparse | ||
|
||
patch_url = os.environ.get('PATCH_URL').strip().replace('@','') | ||
user = os.environ.get('USER') | ||
authorized_users = ['dtcxzyw','nikic','preames','topperc','goldsteinn','fhahn','RKSimon','arsenm','antoniofrighetto','asb'] | ||
|
||
if user not in authorized_users: | ||
print(f'User {user} is not authorized to submit tasks.') | ||
exit(0) | ||
|
||
try: | ||
res = urlparse(patch_url) | ||
if res.scheme != 'https': | ||
print(f'Please provide a valid HTTPS URL: {patch_url}') | ||
exit(0) | ||
if res.netloc != 'github.com': | ||
print(f'Please provide a valid GitHub URL: {patch_url}') | ||
exit(0) | ||
patch_url = res.path.removeprefix('/') | ||
except: | ||
print(f'Invalid patch URL: {patch_url}') | ||
exit(0) | ||
|
||
patch_name = patch_url.removeprefix('llvm/llvm-project/pull/') | ||
|
||
try: | ||
subprocess.check_call(['sed', '-i', f's|export GITHUB_PATCH_ID=.*|export GITHUB_PATCH_ID={patch_url}|', 'scripts/setup_pre_commit_patch.sh']) | ||
except Exception as e: | ||
print(f'Failed to set up patch: {e}') | ||
exit(0) | ||
|
||
output_path = os.getenv('GITHUB_OUTPUT') | ||
with open(output_path, 'a') as f: | ||
f.write(f"SHOULD_OPEN_PR=1\n") | ||
f.write(f"PR_TITLE={patch_name}\n") |