Unverified Commit 0ae183db authored by Xuehai Pan's avatar Xuehai Pan Committed by GitHub
Browse files

[CI][Refactor] Refactor non-test CI workflow files (#971)



* chore: rename CI workflow files

* chore: rename perbench bot file

* refactor: rewrite comment passing via step output and post with github-script

* chore: rename pr-reminder bot file

* chore: use `pre-commit` instead of `format.sh`

* chore: rename docs workflow file

* refactor: rewrite docs workflow file

* chore: use `git clean -dxf -e <exclude>`
Co-authored-by: default avatarcoderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: fix perfbench condition

---------
Co-authored-by: default avatarcoderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
parent 7913fb1d
name: Bot name: Performance Benchmark Bot
on: on:
issue_comment: issue_comment:
types: [created] types:
- created
jobs: permissions:
contents: read
performance-test: concurrency:
if: | group: "${{ github.workflow }}-${{ github.ref }}"
(contains(github.event.comment.body, '/performance-report') || contains(github.event.comment.body, '/perf'))&& cancel-in-progress: true # always cancel in-progress
github.event.issue.pull_request
permissions:
pull-requests: write
runs-on: self-hosted
jobs:
perfbench:
name: Benchmark between PR and main
if: |
github.event_name == 'pull_request' &&
(contains(github.event.comment.body, '/performance-report') || contains(github.event.comment.body, '/perf'))
runs-on: [self-hosted, nvidia]
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
with: with:
ref: refs/pull/${{ github.event.issue.number }}/merge ref: refs/pull/${{ github.event.issue.number }}/merge
fetch-depth: 0 fetch-depth: 0
submodules: recursive
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v6 uses: actions/setup-python@v6
with: with:
python-version: '3.9' python-version: "3.9"
- name: Install dependencies - name: Install merged version
run: | run: |
python -m venv tll python -m venv tll
source tll/bin/activate source tll/bin/activate
pip install -r requirements-test.txt pip install -r requirements-test.txt
pip install . pip install .
- name: Build original version - name: Install original version
run: | run: |
echo "Check files to be deleted!" echo "Check files to be deleted!"
git clean -dxn | grep -v 'tll/' | xargs -I{} echo {} git clean -dxf -e tll/
git clean -dxn | grep -v 'tll/' | xargs -I{} rm -rf {}
echo "Delete files completed!" echo "Delete files completed!"
git checkout main git checkout main
python -m venv tl python -m venv tl
...@@ -46,19 +51,21 @@ jobs: ...@@ -46,19 +51,21 @@ jobs:
pip install . pip install .
- name: Run performance test - name: Run performance test
id: perf-test id: perfbench
run: | run: |
source tl/bin/activate source tl/bin/activate
python ./maint/scripts/ci_performance.py >> report.txt python maint/scripts/ci_performance.py
- name: Post Test Results to PR - name: Post test results as PR comment
env: uses: actions/github-script@v8
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with:
run: | github-token: ${{ secrets.GITHUB_TOKEN }}
COMMENT_BODY=$'📊 ​**Performance Test Results** (triggered by @${{ github.event.comment.user.login }}):\n\n'"$(cat report.txt)" script: |
JSON_PAYLOAD=$(jq -n --arg body "$COMMENT_BODY" '{body: $body}') github.rest.issues.createComment({
curl -X POST \ owner: context.repo.owner,
-H "Authorization: token $GITHUB_TOKEN" \ repo: context.repo.repo,
-H "Accept: application/vnd.github.v3+json" \ issue_number: context.issue.number,
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \ body: '📊 ​**Performance Test Results** (triggered by @' + context.payload.comment.user.login + '):\n\n' +
-d "$JSON_PAYLOAD" 'Run listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\n' +
"${{ steps.perfbench.outputs.stdout }}"
})
name: Reminder Bot name: PR Reminder Bot
on: on:
pull_request_target: pull_request_target:
types: [opened] types:
- opened
jobs: jobs:
pr_reminder: remind:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Remind - name: Remind
uses: actions/github-script@v8 uses: actions/github-script@v8
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
github.rest.issues.createComment({ github.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: context.issue.number, issue_number: context.issue.number,
body: '👋 Hi! Thank you for contributing to the **TileLang** project.\n\n' + body: '👋 Hi! Thank you for contributing to the **TileLang** project.\n\n' +
'Please remember to run `bash format.sh` in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.\n\n' + 'Please remember to run `pre-commit run --all-files` in the root directory of the project ' +
'We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work!\n\n' + 'to ensure your changes are properly linted and formatted. ' +
'🚀' 'This will help ensure your contribution passes the format check.\n\n' +
'We appreciate you taking this step! ' +
'Our team will review your contribution, and we look forward to your awesome work! 🚀'
}) })
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: documentation name: Documentation
on: on:
pull_request_target: pull_request_target:
...@@ -11,23 +11,35 @@ permissions: ...@@ -11,23 +11,35 @@ permissions:
jobs: jobs:
docs: docs:
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' }} || ${{ github.event_name == 'workflow_dispatch' }} name: Build and Publish Docs
if: |
(github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main') ||
github.event_name == 'workflow_dispatch'
runs-on: [self-hosted, nvidia] runs-on: [self-hosted, nvidia]
steps: steps:
- uses: actions/checkout@v5 - name: Checkout repository
- uses: actions/setup-python@v6 uses: actions/checkout@v5
with: with:
python-version: '3.10' fetch-depth: 0
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Build docs - name: Build docs
run: | run: |
chmod +x ./maint/scripts/build_docs.sh bash -ex maint/scripts/build_docs.sh
./maint/scripts/build_docs.sh
- name: Push to another repo - name: Push built docs to another repo
env:
TARGET_REPO: ${{ secrets.TARGET_REPO }}
TARGET_TOKEN: ${{ secrets.TARGET_TOKEN }}
run: | run: |
git clone https://github.com/${TARGET_REPO}.git -b main target_repo # Hide sensitive info in logs
echo "::add-mask::${{ secrets.TARGET_TOKEN }}"
echo "::add-mask::${{ secrets.TARGET_REPO }}"
TARGET_REPO_URL="https://github.com/${{ secrets.TARGET_REPO }}.git"
git clone "${TARGET_REPO_URL}" -b main target_repo
cd target_repo cd target_repo
git config --local user.name "github-actions[bot]" git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.email "github-actions[bot]@users.noreply.github.com"
...@@ -37,7 +49,7 @@ jobs: ...@@ -37,7 +49,7 @@ jobs:
if [[ -n "$(git status --porcelain)" ]]; then if [[ -n "$(git status --porcelain)" ]]; then
# If there are changes, commit and push # If there are changes, commit and push
git commit -m "Update docs" git commit -m "Update docs"
git push https://github-actions[bot]:$TARGET_TOKEN@github.com/${TARGET_REPO}.git main git push "https://github-actions[bot]:${{ secrets.TARGET_TOKEN }}@${TARGET_REPO_URL##*://}" main
else else
echo "No changes detected, skipping commit and push." echo "No changes detected, skipping commit and push."
fi fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment