Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 1 addition & 57 deletions .cnb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,4 @@ master:
echo "✅ 镜像推送成功!"
echo "镜像地址: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:${CNB_COMMIT_SHORT}"
echo "最新镜像: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}:latest"
echo "========================================"

# ========================================
# 流水线 2: 同步代码到 GitHub 仓库
# ========================================
- name: "同步代码到 GitHub"
# 从环境配置仓库导入 GITHUB_TOKEN
imports: https://cnb.cool/ImAcaiy/envs/-/blob/main/envs.yml
stages:
- name: "配置 Git"
script: |
set -e
echo "========================================"
echo "🔄 开始同步到 GitHub"
echo "========================================"

# 配置 Git 用户信息
git config --global user.name "CNB Bot"
git config --global user.email "imacaiy@outlook.com"

# 添加 GitHub remote(URL 会在推送时更新)
git remote add github https://github.com/acai1998/Automation_Platform.git || git remote set-url github https://github.com/acai1998/Automation_Platform.git

echo "✅ Git 配置完成"

- name: "推送到 GitHub"
script: |
set -e

# 检查 GITHUB_TOKEN 是否设置
if [ -z "$GITHUB_TOKEN" ]; then
echo "❌ 错误: GITHUB_TOKEN 环境变量未设置"
echo "请检查以下配置:"
echo "1. envs.yml 中是否已定义 GITHUB_TOKEN"
echo "2. Token 是否有 repo 权限"
echo "3. envs.yml 路径是否正确:https://cnb.cool/ImAcaiy/envs/-/blob/main/envs.yml"
exit 1
fi

# 使用 token 推送到 GitHub
GITHUB_URL="https://x-access-token:$GITHUB_TOKEN@github.com/acai1998/Automation_Platform.git"

echo "📤 推送代码到 GitHub..."
echo "提交: ${CNB_COMMIT_SHA}"
echo "分支: ${CNB_BRANCH}"
echo "Token 长度: ${#GITHUB_TOKEN}"

# 更新 GitHub remote URL 以包含 token
git remote set-url github ${GITHUB_URL}

# 推送到 GitHub(不使用 force,避免触发分支保护规则)
git push github ${CNB_BRANCH}

echo "========================================"
echo "✅ 同步成功!"
echo "🔗 GitHub 仓库: https://github.com/acai1998/Automation_Platform"
echo "========================================"
echo "========================================"
44 changes: 0 additions & 44 deletions .github/pull_request_template.md

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,3 @@ jobs:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_NAME: ${{ secrets.DB_NAME }}
run: python .github/scripts/sync_cases.py

test-typescript:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run TypeScript tests
run: npm run test
135 changes: 135 additions & 0 deletions .github/workflows/github-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: CI/CD Pipeline

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: TypeScript check (frontend)
run: npx tsc --noEmit -p tsconfig.json

- name: TypeScript check (backend)
run: npx tsc --noEmit -p tsconfig.server.json

test:
name: Test (${{ matrix.platform }} / Node ${{ matrix.node }})
needs: lint
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
node: [18, 20, 22]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: '${{ matrix.node }}'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npx vitest run

build:
name: Build Verification
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build frontend
run: npm run build

- name: Build backend
run: npm run server:build

- name: Verify build output
run: |
test -f dist/index.html || (echo "Frontend build missing" && exit 1)
test -f dist/server/server/index.js || (echo "Backend build missing" && exit 1)
echo "Build verification passed"

coverage:
name: Test Coverage
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests with coverage
run: npx vitest run --coverage

- name: Extract coverage percentage
id: coverage
run: |
PCT=$(node -e "
const fs = require('fs');
const p = require('path');
const dir = 'coverage';
const files = fs.readdirSync(dir).filter(f => f === 'coverage-summary.json');
if (!files.length) { console.error('No coverage-summary.json found'); process.exit(1); }
const data = JSON.parse(fs.readFileSync(p.join(dir, files[0]), 'utf8'));
console.log(data.total.lines.pct);
")
echo "percentage=$PCT" >> "$GITHUB_OUTPUT"
echo "Coverage: $PCT%"

- name: Upload coverage to Gist
if: github.event_name != 'pull_request'
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: ${{ secrets.COVERAGE_GIST_ID }}
filename: coverage.json
label: coverage
message: ${{ steps.coverage.outputs.percentage }}%
valColorRange: ${{ steps.coverage.outputs.percentage }}
minColorRange: 60
maxColorRange: 90
isError: ${{ steps.coverage.outputs.percentage < 60 }}
45 changes: 45 additions & 0 deletions .github/workflows/k6-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: k6 API Performance Smoke

on:
workflow_dispatch:
schedule:
# Daily at Singapore/China 09:00. GitHub cron uses UTC.
- cron: '0 1 * * *'

permissions:
contents: read

jobs:
k6-smoke:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install k6
run: |
sudo gpg -k
curl -s https://dl.k6.io/key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/k6-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install -y k6

- name: Run k6 API smoke test
working-directory: perf
env:
BASE_URL: ${{ vars.PERF_BASE_URL || secrets.PERF_BASE_URL }}
API_TOKEN: ${{ secrets.PERF_API_TOKEN }}
SMOKE_EMAIL: ${{ secrets.PERF_SMOKE_EMAIL }}
SMOKE_PASSWORD: ${{ secrets.PERF_SMOKE_PASSWORD }}
run: |
k6 run \
--summary-export k6-summary.json \
smoke.js

- name: Upload k6 summary
if: always()
uses: actions/upload-artifact@v4
with:
name: k6-summary
path: perf/k6-summary.json
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
2 changes: 1 addition & 1 deletion .github/workflows/sync-to-cnb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ jobs:
run: |
echo "Syncing to GitHub..."
git push https://x-access-token:${GITHUB_TOKEN}@github.com/acai1998/Automation_Platform.git HEAD:master
echo "GitHub sync completed!"
echo "GitHub sync completed!"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ __pycache__/
.env.example
.mrules
.catpaw/
node_modules

# 规则忽略文件
CLAUDE.md
Expand All @@ -27,7 +28,8 @@ Jenkinsfile.optimized
.markdownlint.yaml
.markdownlint.json
.docs\报错日志.txt

.superpowers/*
.worktrees/

# Distribution / packaging
.Python
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<img src="https://img.shields.io/badge/TailwindCSS-3.4-06B6D4?logo=tailwindcss" alt="TailwindCSS" />
<img src="https://img.shields.io/badge/PM2-5.x-2B037A?logo=pm2" alt="PM2" />
<img src="https://img.shields.io/badge/Socket.IO-4.x-010101?logo=socket.io" alt="Socket.IO" />
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/acai1998/ce72e9e3551850f329e4ee3b20bc80ea/raw/coverage.json" alt="Test Coverage" />
</p>

一个现代化的全栈自动化测试管理平台,用于管理测试用例、调度 Jenkins 执行任务、监控执行结果。平台专注于测试管理和调度,实际测试执行由 Jenkins 等外部系统完成。
Expand Down
Loading
Loading