chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
name: Auto Label PRs
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
label:
|
||||
# Fork PRs do not get a write-capable GITHUB_TOKEN under pull_request,
|
||||
# so actions/labeler would fail with "Resource not accessible by integration".
|
||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v6
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
sync-labels: false
|
||||
|
||||
size-label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Label PR size
|
||||
uses: codelytv/pr-size-labeler@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
xs_label: "size/XS"
|
||||
xs_max_size: 10
|
||||
s_label: "size/S"
|
||||
s_max_size: 50
|
||||
m_label: "size/M"
|
||||
m_max_size: 200
|
||||
l_label: "size/L"
|
||||
l_max_size: 500
|
||||
xl_label: "size/XL"
|
||||
fail_if_xl: false
|
||||
@@ -0,0 +1,124 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Shell lint
|
||||
run: |
|
||||
find scripts -name '*.sh' | while read f; do
|
||||
echo "Checking $f"
|
||||
bash -n "$f"
|
||||
done
|
||||
|
||||
- name: Check install script
|
||||
run: bash -n install.sh
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.10', '3.11', '3.12', '3.13']
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'pip'
|
||||
|
||||
- name: Syntax check (py_compile)
|
||||
run: |
|
||||
find scripts dashboard -name '*.py' | while read f; do
|
||||
echo " checking $f"
|
||||
python3 -m py_compile "$f"
|
||||
done
|
||||
|
||||
- name: Install test dependencies
|
||||
run: pip install pytest
|
||||
|
||||
- name: Run tests
|
||||
run: pytest tests/ -v
|
||||
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: edict:test
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
edict-backend:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_DB: edict
|
||||
POSTGRES_USER: edict
|
||||
POSTGRES_PASSWORD: edict_dev_2024
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U edict"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- 6379:6379
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
env:
|
||||
DATABASE_URL: postgresql+asyncpg://edict:edict_dev_2024@localhost:5432/edict
|
||||
REDIS_URL: redis://localhost:6379/0
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.12'
|
||||
cache: 'pip'
|
||||
cache-dependency-path: edict/backend/requirements.txt
|
||||
|
||||
- name: Install backend dependencies
|
||||
run: pip install -r edict/backend/requirements.txt
|
||||
|
||||
- name: Syntax check (py_compile)
|
||||
run: |
|
||||
find edict/backend -name '*.py' | while read f; do
|
||||
echo " checking $f"
|
||||
python3 -m py_compile "$f"
|
||||
done
|
||||
|
||||
- name: Run Alembic migrations
|
||||
working-directory: edict
|
||||
run: python -m alembic upgrade head
|
||||
|
||||
- name: Verify FastAPI app imports
|
||||
working-directory: edict/backend
|
||||
run: |
|
||||
python -c "from app.main import app; print(f'FastAPI app loaded: {len(app.routes)} routes')"
|
||||
@@ -0,0 +1,61 @@
|
||||
name: Docker Publish (Multi-Arch)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Docker image tag (e.g. latest, v1.2.3)'
|
||||
required: false
|
||||
default: 'latest'
|
||||
|
||||
env:
|
||||
REGISTRY: docker.io
|
||||
IMAGE_NAME: cft0808/sansheng-demo
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU (multi-arch emulation)
|
||||
uses: docker/setup-qemu-action@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
||||
|
||||
- name: Build and push multi-arch image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
BUILDPLATFORM=linux/amd64
|
||||
@@ -0,0 +1,48 @@
|
||||
name: Stale Issues & PRs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 2 * * 1' # 每周一 UTC 02:00
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v10
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Issue 配置
|
||||
days-before-stale: 60
|
||||
days-before-close: 30
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: >
|
||||
📜 此 Issue 已超过 60 天没有活动。
|
||||
如果问题仍然存在,请回复更新状态;否则此 Issue 将在 30 天后自动关闭。
|
||||
感谢你的贡献!
|
||||
close-issue-message: >
|
||||
🏛️ 此 Issue 因长期无活动已自动关闭。
|
||||
如需重新讨论,欢迎随时重新打开或创建新 Issue。
|
||||
exempt-issue-labels: "P0-critical,P1-important,good first issue,help wanted,pinned"
|
||||
|
||||
# PR 配置
|
||||
days-before-pr-stale: 30
|
||||
days-before-pr-close: 14
|
||||
stale-pr-label: "stale"
|
||||
stale-pr-message: >
|
||||
📜 此 PR 已超过 30 天没有活动。
|
||||
如果仍计划继续,请更新代码或回复说明进度;否则将在 14 天后自动关闭。
|
||||
close-pr-message: >
|
||||
🏛️ 此 PR 因长期无活动已自动关闭。
|
||||
如果你想继续这项工作,欢迎重新打开。
|
||||
exempt-pr-labels: "P0-critical,P1-important,work-in-progress"
|
||||
|
||||
# 通用配置
|
||||
operations-per-run: 30
|
||||
ascending: true
|
||||
remove-stale-when-updated: true
|
||||
Reference in New Issue
Block a user