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:
issue_comment:
types: [created]
types:
- created
jobs:
permissions:
contents: read
performance-test:
if: |
(contains(github.event.comment.body, '/performance-report') || contains(github.event.comment.body, '/perf'))&&
github.event.issue.pull_request
permissions:
pull-requests: write
runs-on: self-hosted
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true # always cancel in-progress
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:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: refs/pull/${{ github.event.issue.number }}/merge
fetch-depth: 0
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.9'
python-version: "3.9"
- name: Install dependencies
- name: Install merged version
run: |
python -m venv tll
source tll/bin/activate
pip install -r requirements-test.txt
pip install .
- name: Build original version
- name: Install original version
run: |
echo "Check files to be deleted!"
git clean -dxn | grep -v 'tll/' | xargs -I{} echo {}
git clean -dxn | grep -v 'tll/' | xargs -I{} rm -rf {}
git clean -dxf -e tll/
echo "Delete files completed!"
git checkout main
python -m venv tl
......@@ -46,19 +51,21 @@ jobs:
pip install .
- name: Run performance test
id: perf-test
id: perfbench
run: |
source tl/bin/activate
python ./maint/scripts/ci_performance.py >> report.txt
python maint/scripts/ci_performance.py
- name: Post Test Results to PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT_BODY=$'📊 ​**Performance Test Results** (triggered by @${{ github.event.comment.user.login }}):\n\n'"$(cat report.txt)"
JSON_PAYLOAD=$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-d "$JSON_PAYLOAD"
- name: Post test results as PR comment
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '📊 ​**Performance Test Results** (triggered by @' + context.payload.comment.user.login + '):\n\n' +
'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:
pull_request_target:
types: [opened]
types:
- opened
jobs:
pr_reminder:
remind:
runs-on: ubuntu-latest
steps:
- name: Remind
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
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' +
'We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work!\n\n' +
'🚀'
'Please remember to run `pre-commit run --all-files` 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' +
'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:
pull_request_target:
......@@ -11,23 +11,35 @@ permissions:
jobs:
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]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
- name: Checkout repository
uses: actions/checkout@v5
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
run: |
chmod +x ./maint/scripts/build_docs.sh
./maint/scripts/build_docs.sh
- name: Push to another repo
env:
TARGET_REPO: ${{ secrets.TARGET_REPO }}
TARGET_TOKEN: ${{ secrets.TARGET_TOKEN }}
bash -ex maint/scripts/build_docs.sh
- name: Push built docs to another repo
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
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
......@@ -37,7 +49,7 @@ jobs:
if [[ -n "$(git status --porcelain)" ]]; then
# If there are changes, commit and push
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
echo "No changes detected, skipping commit and push."
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