Merge branch 'dev' of https://github.com/MaiM-with-u/MaiBot into dev
This commit is contained in:
27
.github/workflows/precheck.yml
vendored
27
.github/workflows/precheck.yml
vendored
@@ -4,21 +4,32 @@ on: [pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
conflict-check:
|
conflict-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
outputs:
|
||||||
|
conflict: ${{ steps.check-conflicts.outputs.conflict }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- name: Check Conflicts
|
- name: Check Conflicts
|
||||||
|
id: check-conflicts
|
||||||
run: |
|
run: |
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
if git diff --name-only --diff-filter=U origin/main...HEAD | grep .; then
|
$conflicts = git diff --name-only --diff-filter=U origin/main...HEAD
|
||||||
echo "CONFLICT=true" >> $GITHUB_ENV
|
if ($conflicts) {
|
||||||
fi
|
echo "conflict=true" >> $env:GITHUB_OUTPUT
|
||||||
|
Write-Host "Conflicts detected in files: $conflicts"
|
||||||
|
} else {
|
||||||
|
echo "conflict=false" >> $env:GITHUB_OUTPUT
|
||||||
|
Write-Host "No conflicts detected"
|
||||||
|
}
|
||||||
|
shell: pwsh
|
||||||
labeler:
|
labeler:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
needs: conflict-check
|
needs: conflict-check
|
||||||
|
if: needs.conflict-check.outputs.conflict == 'true'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v6
|
- uses: actions/github-script@v7
|
||||||
if: env.CONFLICT == 'true'
|
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
github.rest.issues.addLabels({
|
github.rest.issues.addLabels({
|
||||||
|
|||||||
18
.github/workflows/ruff-pr.yml
vendored
18
.github/workflows/ruff-pr.yml
vendored
@@ -1,9 +1,21 @@
|
|||||||
name: Ruff
|
name: Ruff PR Check
|
||||||
on: [ pull_request ]
|
on: [ pull_request ]
|
||||||
jobs:
|
jobs:
|
||||||
ruff:
|
ruff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: astral-sh/ruff-action@v3
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install Ruff and Run Checks
|
||||||
|
uses: astral-sh/ruff-action@v3
|
||||||
|
with:
|
||||||
|
args: "--version"
|
||||||
|
version: "latest"
|
||||||
|
- name: Run Ruff Check (No Fix)
|
||||||
|
run: ruff check --output-format=github
|
||||||
|
shell: pwsh
|
||||||
|
- name: Run Ruff Format Check
|
||||||
|
run: ruff format --check --diff
|
||||||
|
shell: pwsh
|
||||||
|
|
||||||
|
|||||||
14
.github/workflows/ruff.yml
vendored
14
.github/workflows/ruff.yml
vendored
@@ -13,7 +13,7 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ruff:
|
ruff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
# 关键修改:添加条件判断
|
# 关键修改:添加条件判断
|
||||||
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
|
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
|
||||||
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')
|
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')
|
||||||
@@ -29,14 +29,20 @@ jobs:
|
|||||||
args: "--version"
|
args: "--version"
|
||||||
version: "latest"
|
version: "latest"
|
||||||
- name: Run Ruff Fix
|
- name: Run Ruff Fix
|
||||||
run: ruff check --fix --unsafe-fixes || true
|
run: ruff check --fix --unsafe-fixes; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff check completed with warnings" }
|
||||||
|
shell: pwsh
|
||||||
- name: Run Ruff Format
|
- name: Run Ruff Format
|
||||||
run: ruff format || true
|
run: ruff format; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff format completed with warnings" }
|
||||||
|
shell: pwsh
|
||||||
- name: 提交更改
|
- name: 提交更改
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git config --local user.name "github-actions[bot]"
|
git config --local user.name "github-actions[bot]"
|
||||||
git add -A
|
git add -A
|
||||||
git diff --quiet && git diff --staged --quiet || git commit -m "🤖 自动格式化代码 [skip ci]"
|
$changes = git diff --quiet; $staged = git diff --staged --quiet
|
||||||
|
if (-not ($changes -and $staged)) {
|
||||||
|
git commit -m "🤖 自动格式化代码 [skip ci]"
|
||||||
git push
|
git push
|
||||||
|
}
|
||||||
|
shell: pwsh
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from typing import Optional, Tuple, List, Any
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
from rich.traceback import install
|
from rich.traceback import install
|
||||||
|
|
||||||
|
|
||||||
from src.common.database.database_model import Emoji
|
from src.common.database.database_model import Emoji
|
||||||
from src.common.database.database import db as peewee_db
|
from src.common.database.database import db as peewee_db
|
||||||
from src.common.logger import get_logger
|
from src.common.logger import get_logger
|
||||||
|
|||||||
Reference in New Issue
Block a user