Skip to content

Commit 405f074

Browse files
committed
fix: re-track .github/workflows so GitHub CI can run
1 parent b6f0582 commit 405f074

File tree

4 files changed

+360
-2
lines changed

4 files changed

+360
-2
lines changed

.github/workflows/ci-strict.yml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
name: CI (Strict)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-strict-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
PYTHON_VERSION: "3.12"
18+
NODE_VERSION: "20"
19+
PNPM_VERSION: "9"
20+
# Use official PyPI in CI (override any mirror settings)
21+
UV_INDEX_URL: "https://pypi.org/simple/"
22+
23+
jobs:
24+
# ============================================
25+
# Job: Dependency Integrity Check
26+
# ============================================
27+
lockfile-check:
28+
name: 🔒 Lockfile Integrity
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ env.PYTHON_VERSION }}
38+
39+
- name: Set up uv
40+
uses: astral-sh/setup-uv@v5
41+
with:
42+
enable-cache: true
43+
44+
- name: Replace PyPI mirror in uv.lock
45+
run: |
46+
# Replace Tsinghua mirror URLs with official PyPI for CI compatibility
47+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/|https://pypi.org/simple/|g' uv.lock
48+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/|https://files.pythonhosted.org/packages/|g' uv.lock
49+
# Re-sync to update lockfile hashes after URL replacement
50+
uv sync
51+
52+
- name: Set up pnpm
53+
uses: pnpm/action-setup@v4
54+
with:
55+
version: ${{ env.PNPM_VERSION }}
56+
57+
- name: Set up Node.js
58+
uses: actions/setup-node@v4
59+
with:
60+
node-version: ${{ env.NODE_VERSION }}
61+
cache: pnpm
62+
cache-dependency-path: ui/pnpm-lock.yaml
63+
64+
- name: Verify pnpm-lock.yaml is up to date
65+
working-directory: ui
66+
run: |
67+
pnpm install --frozen-lockfile || (
68+
echo "❌ pnpm-lock.yaml is out of date. Run 'pnpm install' in ui/ locally and commit the changes."
69+
exit 1
70+
)
71+
72+
# ============================================
73+
# Job: Python Backend Checks
74+
# ============================================
75+
backend:
76+
name: 🐍 Backend
77+
runs-on: ubuntu-latest
78+
needs: lockfile-check
79+
strategy:
80+
fail-fast: true
81+
matrix:
82+
check: [format, lint, test]
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
87+
- name: Set up Python
88+
uses: actions/setup-python@v5
89+
with:
90+
python-version: ${{ env.PYTHON_VERSION }}
91+
92+
- name: Set up uv
93+
uses: astral-sh/setup-uv@v5
94+
with:
95+
enable-cache: true
96+
97+
- name: Install dependencies
98+
run: |
99+
# Replace Tsinghua mirror URLs with official PyPI for CI compatibility
100+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/|https://pypi.org/simple/|g' uv.lock
101+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/|https://files.pythonhosted.org/packages/|g' uv.lock
102+
uv sync
103+
104+
# Format Check
105+
- name: Check Python formatting
106+
if: matrix.check == 'format'
107+
run: uv run ruff format --check swarmmind/ tests/
108+
109+
# Lint
110+
- name: Run Python linter
111+
if: matrix.check == 'lint'
112+
run: uv run ruff check swarmmind/ tests/
113+
114+
# Test with Coverage (skip LLM tests in CI)
115+
- name: Run Python tests with coverage
116+
if: matrix.check == 'test'
117+
run: uv run python -m pytest tests/ -v -m "not requires_llm" --cov=swarmmind --cov-report=xml --cov-report=term-missing
118+
119+
- name: Upload coverage report
120+
if: matrix.check == 'test'
121+
uses: codecov/codecov-action@v4
122+
with:
123+
files: ./coverage.xml
124+
fail_ci_if_error: false
125+
verbose: true
126+
env:
127+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
128+
129+
# ============================================
130+
# Job: Frontend Checks
131+
# ============================================
132+
frontend:
133+
name: ⚛️ Frontend
134+
runs-on: ubuntu-latest
135+
needs: lockfile-check
136+
strategy:
137+
fail-fast: true
138+
matrix:
139+
check: [lint, typecheck, build]
140+
steps:
141+
- name: Checkout
142+
uses: actions/checkout@v4
143+
144+
- name: Set up pnpm
145+
uses: pnpm/action-setup@v4
146+
with:
147+
version: ${{ env.PNPM_VERSION }}
148+
149+
- name: Set up Node.js
150+
uses: actions/setup-node@v4
151+
with:
152+
node-version: ${{ env.NODE_VERSION }}
153+
cache: pnpm
154+
cache-dependency-path: ui/pnpm-lock.yaml
155+
156+
- name: Install dependencies
157+
working-directory: ui
158+
run: pnpm install --frozen-lockfile
159+
160+
# Lint
161+
- name: Run ESLint
162+
if: matrix.check == 'lint'
163+
working-directory: ui
164+
run: pnpm run lint
165+
166+
# Type Check
167+
- name: Run TypeScript type check
168+
if: matrix.check == 'typecheck'
169+
working-directory: ui
170+
run: pnpm run typecheck
171+
172+
# Build
173+
- name: Build for production
174+
if: matrix.check == 'build'
175+
working-directory: ui
176+
run: pnpm run build
177+
178+
# ============================================
179+
# Job: Spell Check
180+
# ============================================
181+
spellcheck:
182+
name: 📝 Spell Check
183+
runs-on: ubuntu-latest
184+
steps:
185+
- name: Checkout
186+
uses: actions/checkout@v4
187+
188+
- name: Check for typos
189+
uses: crate-ci/typos@v1.21.0
190+
with:
191+
files: .
192+
config: ./typos.toml
193+
194+
# ============================================
195+
# Job: Summary
196+
# ============================================
197+
ci-summary:
198+
name: ✅ CI Summary
199+
runs-on: ubuntu-latest
200+
needs: [backend, frontend, spellcheck]
201+
if: always()
202+
steps:
203+
- name: Check all jobs status
204+
run: |
205+
echo "Backend: ${{ needs.backend.result }}"
206+
echo "Frontend: ${{ needs.frontend.result }}"
207+
echo "Spell Check: ${{ needs.spellcheck.result }}"
208+
209+
- name: Fail if any job failed
210+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
211+
run: |
212+
echo "❌ CI failed"
213+
exit 1
214+
215+
- name: Success
216+
run: echo "✅ All CI checks passed!"

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
# Required for tests that need LLM configuration
18+
LLM_MODEL: gpt-4o-mini
19+
LLM_PROVIDER: openai
20+
# Use official PyPI in CI (override any mirror settings)
21+
UV_INDEX_URL: "https://pypi.org/simple/"
22+
23+
jobs:
24+
backend:
25+
name: Backend Test
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.12"
36+
37+
- name: Set up uv
38+
uses: astral-sh/setup-uv@v5
39+
with:
40+
enable-cache: true
41+
42+
- name: Install backend dependencies
43+
run: |
44+
# Replace Tsinghua mirror URLs with official PyPI for CI compatibility
45+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/|https://pypi.org/simple/|g' uv.lock
46+
sed -i 's|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/packages/|https://files.pythonhosted.org/packages/|g' uv.lock
47+
uv sync --locked
48+
49+
- name: Run backend tests (skip LLM tests)
50+
run: uv run python -m pytest tests/ -v -m "not requires_llm"
51+
52+
frontend:
53+
name: Frontend Check
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Set up pnpm
61+
uses: pnpm/action-setup@v4
62+
with:
63+
version: 9
64+
65+
- name: Set up Node.js
66+
uses: actions/setup-node@v4
67+
with:
68+
node-version: "20"
69+
cache: pnpm
70+
cache-dependency-path: ui/pnpm-lock.yaml
71+
72+
- name: Install frontend dependencies
73+
working-directory: ui
74+
run: pnpm install --frozen-lockfile
75+
76+
- name: Run typecheck
77+
working-directory: ui
78+
run: pnpm run typecheck
79+
80+
- name: Run production build
81+
working-directory: ui
82+
run: npx vite build
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PR Branch Naming Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
check-branch-name:
9+
name: Validate Branch Name
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check branch naming convention
13+
run: |
14+
BRANCH_NAME="${{ github.head_ref }}"
15+
echo "Checking branch: $BRANCH_NAME"
16+
17+
# 允许的分支名模式
18+
# main, release* - 受保护分支,不应该直接创建PR
19+
# feature/*, fix/*, docs/*, refactor/*, test/*, chore/*, perf/*, hotfix/* - 功能分支
20+
21+
if [[ "$BRANCH_NAME" =~ ^(main|release.*)$ ]]; then
22+
echo "❌ ERROR: Branch '$BRANCH_NAME' is a protected branch."
23+
echo "You should not create pull requests from main or release branches."
24+
exit 1
25+
fi
26+
27+
if [[ "$BRANCH_NAME" =~ ^(feature|fix|docs|refactor|test|chore|perf|hotfix)/[a-z0-9-]+$ ]]; then
28+
echo "✅ Branch name '$BRANCH_NAME' follows the naming convention."
29+
exit 0
30+
fi
31+
32+
# Allow Claude Code agent branches (claude/<any-name>)
33+
if [[ "$BRANCH_NAME" =~ ^claude/.+ ]]; then
34+
echo "✅ Branch name '$BRANCH_NAME' is a Claude Code agent branch."
35+
exit 0
36+
fi
37+
38+
echo "❌ ERROR: Branch name '$BRANCH_NAME' does not follow the naming convention."
39+
echo ""
40+
echo "Expected format: <type>/<short-description>"
41+
echo ""
42+
echo "Allowed types:"
43+
echo " - feature - New features"
44+
echo " - fix - Bug fixes"
45+
echo " - docs - Documentation"
46+
echo " - refactor - Code refactoring"
47+
echo " - test - Test related"
48+
echo " - chore - Build/tools/config"
49+
echo " - perf - Performance improvements"
50+
echo " - hotfix - Emergency fixes"
51+
echo " - claude - Claude Code agent branches"
52+
echo ""
53+
echo "Examples:"
54+
echo " ✅ feature/user-auth"
55+
echo " ✅ fix/memory-leak"
56+
echo " ✅ docs/api-guide"
57+
echo " ✅ claude/my-task"
58+
echo ""
59+
echo "See CONTRIBUTING.md for more details."
60+
exit 1

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ tests/e2e/
8484
tests/snapshots/
8585
docs/e2e_test_task.md
8686

87-
# CI / CD workflows (infrastructure)
88-
.github/workflows/
87+
# CI / CD workflows are tracked so GitHub Actions can run.
88+
# .github/workflows/

0 commit comments

Comments
 (0)