初始化

This commit is contained in:
雅诺狐
2025-08-11 19:34:18 +08:00
parent ff7d1177fa
commit 2d4745cd58
257 changed files with 69069 additions and 0 deletions

63
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,63 @@
name: Bug Report
description: 提交 Bug
labels: ["BUG"]
body:
- type: checkboxes
attributes:
label: "检查项"
description: "请检查下列项目,并勾选确认。"
options:
- label: "我确认此问题在所有分支的最新版本中依旧存在"
required: true
- label: "我确认在 Issues 列表中并无其他人已经提出过与此问题相同或相似的问题"
required: true
- label: "我使用了 Docker"
- type: dropdown
attributes:
label: "使用的分支"
description: "请选择您正在使用的版本分支"
options:
- main
- dev
validations:
required: true
- type: input
attributes:
label: "具体版本号"
description: "请输入您使用的具体版本号"
placeholder: "例如0.5.11、0.5.8、0.6.0"
validations:
required: true
- type: textarea
attributes:
label: 遇到的问题
validations:
required: true
- type: textarea
attributes:
label: 报错信息
validations:
required: true
- type: textarea
attributes:
label: 如何重现此问题?
placeholder: "若不知道请略过此问题"
- type: textarea
attributes:
label: 可能造成问题的原因
placeholder: "若不知道请略过此问题"
- type: textarea
attributes:
label: 系统环境
placeholder: "例如Windows 11 专业版 64位 24H2 / Debian Bookworm"
validations:
required: true
- type: textarea
attributes:
label: Python 版本
placeholder: "例如Python 3.11"
validations:
required: true
- type: textarea
attributes:
label: 补充信息

View File

@@ -0,0 +1,21 @@
name: Feature Request
description: 新功能请求
labels: ["Feature"]
body:
- type: checkboxes
attributes:
label: "检查项"
description: "请检查下列项目,并勾选确认。"
options:
- label: "我确认在Issues列表中并无其他人已经建议过相似的功能"
required: true
- label: "这个新功能可以解决目前存在的某个问题或BUG"
- label: "你已经更新了最新的dev分支但是你的问题依然没有被解决"
- type: textarea
attributes:
label: 期望的功能描述
validations:
required: true
- type: textarea
attributes:
label: 补充信息

4
.github/prompts/chat.prompt.md vendored Normal file
View File

@@ -0,0 +1,4 @@
---
mode: agent
---
记得执行前激活虚拟环境用的shell是powershell与linux语法有区别

17
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,17 @@
<!-- 提交前必读 -->
- ✅ 接受与main直接相关的Bug修复提交到dev分支
- 新增功能类pr需要经过issue提前讨论否则不会被合并
# 请填写以下内容
(删除掉中括号内的空格,并替换为**小写的x**
1. - [ ] `main` 分支 **禁止修改**,请确认本次提交的分支 **不是 `main` 分支**
2. - [ ] 我确认我阅读了贡献指南
3. - [ ] 本次更新类型为BUG修复
- [ ] 本次更新类型为:功能新增
4. - [ ] 本次更新是否经过测试
5. 请填写破坏性更新的具体内容(如有):
6. 请简要说明本次更新的内容和目的:
# 其他信息
- **关联 Issue**Close #
- **截图/GIF**
- **附加信息**:

164
.github/workflows/docker-image.yml vendored Normal file
View File

@@ -0,0 +1,164 @@
name: Docker Build and Push
on:
push:
branches:
- main
- classical
- dev
tags:
- "v*.*.*"
- "v*"
- "*.*.*"
- "*.*.*-*"
workflow_dispatch: # 允许手动触发工作流
# Workflow's jobs
jobs:
build-amd64:
name: Build AMD64 Image
runs-on: ubuntu-24.04
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Check out git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Clone required dependencies
- name: Clone maim_message
run: git clone https://github.com/MaiM-with-u/maim_message maim_message
- name: Clone lpmm
run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
# Log in docker hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Generate metadata for Docker images
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot
# Build and push AMD64 image by digest
- name: Build and push AMD64
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
labels: ${{ steps.meta.outputs.labels }}
file: ./Dockerfile
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:amd64-buildcache,mode=max
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/maibot,push-by-digest=true,name-canonical=true,push=true
build-args: |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
VCS_REF=${{ github.sha }}
build-arm64:
name: Build ARM64 Image
runs-on: ubuntu-24.04-arm
outputs:
digest: ${{ steps.build.outputs.digest }}
steps:
- name: Check out git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Clone required dependencies
- name: Clone maim_message
run: git clone https://github.com/MaiM-with-u/maim_message maim_message
- name: Clone lpmm
run: git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
# Log in docker hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Generate metadata for Docker images
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot
# Build and push ARM64 image by digest
- name: Build and push ARM64
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
file: ./Dockerfile
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/maibot:arm64-buildcache,mode=max
outputs: type=image,name=${{ secrets.DOCKERHUB_USERNAME }}/maibot,push-by-digest=true,name-canonical=true,push=true
build-args: |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
VCS_REF=${{ github.sha }}
create-manifest:
name: Create Multi-Arch Manifest
runs-on: ubuntu-24.04
needs:
- build-amd64
- build-arm64
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in docker hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Generate metadata for Docker images
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/maibot
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=${{ github.ref_name }}-,enable=${{ github.ref_type == 'branch' }}
- name: Create and Push Manifest
run: |
# 为每个标签创建多架构镜像
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do
echo "Creating manifest for $tag"
docker buildx imagetools create -t $tag \
${{ secrets.DOCKERHUB_USERNAME }}/maibot@${{ needs.build-amd64.outputs.digest }} \
${{ secrets.DOCKERHUB_USERNAME }}/maibot@${{ needs.build-arm64.outputs.digest }}
done

40
.github/workflows/precheck.yml vendored Normal file
View File

@@ -0,0 +1,40 @@
# .github/workflows/precheck.yml
name: PR Precheck
on: [pull_request]
jobs:
conflict-check:
runs-on: [self-hosted, Windows, X64]
outputs:
conflict: ${{ steps.check-conflicts.outputs.conflict }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Conflicts
id: check-conflicts
run: |
git fetch origin main
$conflicts = git diff --name-only --diff-filter=U origin/main...HEAD
if ($conflicts) {
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:
runs-on: [self-hosted, Windows, X64]
needs: conflict-check
if: needs.conflict-check.outputs.conflict == 'true'
steps:
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['🚫冲突需处理']
})

21
.github/workflows/ruff-pr.yml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Ruff PR Check
on: [ pull_request ]
jobs:
ruff:
runs-on: [self-hosted, Windows, X64]
steps:
- uses: actions/checkout@v4
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

53
.github/workflows/ruff.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Ruff
on:
# push:
# branches:
# - main
# - dev
# - dev-refactor # 例如:匹配所有以 feature/ 开头的分支
# # 添加你希望触发此 workflow 的其他分支
workflow_dispatch: # 允许手动触发工作流
branches:
- main
- dev
- dev-refactor
permissions:
contents: write
jobs:
ruff:
runs-on: [self-hosted, Windows, X64]
# 关键修改:添加条件判断
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}
- name: Install Ruff and Run Checks
uses: astral-sh/ruff-action@v3
with:
args: "--version"
version: "latest"
- name: Run Ruff Fix
run: ruff check --fix --unsafe-fixes; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff check completed with warnings" }
shell: pwsh
- name: Run Ruff Format
run: ruff format; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff format completed with warnings" }
shell: pwsh
- name: 提交更改
if: success()
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
$changes = git diff --quiet; $staged = git diff --staged --quiet
if (-not ($changes -and $staged)) {
git commit -m "🤖 自动格式化代码 [skip ci]"
git push
}
shell: pwsh