datai/datai-scenes/datai-scene-salesforce/.github/workflows/ci.yml

132 lines
4.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: CI
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 设置执行权限
run: |
chmod +x scripts/verify.sh
chmod +x .githooks/pre-commit
chmod +x .githooks/commit-msg
- name: 运行验证脚本
run: ./scripts/verify.sh
- name: 检查文档链接存在性
run: |
echo "检查所有文档链接..."
find docs -name "*.md" -exec grep -l "\[.*\](.*)" {} \; | while read -r file; do
echo "检查文件: $file"
grep -o "\[.*\](\(.*\))" "$file" | while read -r link; do
if [[ $link =~ \[.*\]\((.*)\) ]]; then
target=${BASH_REMATCH[1]}
if [[ $target != http* ]]; then
if [[ $target == /* ]]; then
# 绝对路径,从仓库根目录开始
if [ ! -f "${target:1}" ] && [ ! -d "${target:1}" ]; then
echo "错误:$file 中的链接 $target 不存在"
exit 1
fi
else
# 相对路径,从当前文件目录开始
dir=$(dirname "$file")
if [ ! -f "$dir/$target" ] && [ ! -d "$dir/$target" ]; then
echo "错误:$file 中的链接 $target 不存在"
exit 1
fi
fi
fi
fi
done
done
echo "✓ 所有文档链接有效"
- name: 检查ADR编号不重复
run: |
echo "检查ADR编号..."
adr_files=$(find docs/decisions/adr -name "*.md" | grep -v "template.md")
if [ -n "$adr_files" ]; then
adr_numbers=$(echo "$adr_files" | grep -o "[0-9]\{4\}")
if [ -n "$adr_numbers" ]; then
duplicates=$(echo "$adr_numbers" | sort | uniq -d)
if [ -n "$duplicates" ]; then
echo "错误发现重复的ADR编号$duplicates"
exit 1
else
echo "✓ 无重复的ADR编号"
fi
else
echo "✓ 无ADR文件需要检查"
fi
else
echo "✓ 无ADR文件需要检查"
fi
- name: 检查Prompt模板字段不为空
run: |
echo "检查Prompt模板字段..."
prompt_template="docs/prompts/0000-template.md"
if [ -f "$prompt_template" ]; then
required_fields=("输入引用" "目标" "输出格式" "约束" "验收标准" "风险" "使用记录")
for field in "${required_fields[@]}"; do
if ! grep -q "$field" "$prompt_template"; then
echo "错误Prompt模板缺少字段$field"
exit 1
else
# 检查字段内容不为空
if grep -A 5 "$field" "$prompt_template" | grep -q "^$"; then
echo "警告Prompt模板字段 $field 内容可能为空"
fi
fi
done
echo "✓ Prompt模板包含所有必要字段"
else
echo "错误Prompt模板文件不存在"
exit 1
fi
- name: 检查Git钩子配置
run: |
echo "检查Git钩子配置..."
if [ -d ".githooks" ]; then
if [ -f ".githooks/pre-commit" ] && [ -f ".githooks/commit-msg" ]; then
echo "✓ Git钩子文件存在"
else
echo "警告部分Git钩子文件缺失"
fi
else
echo "警告Git钩子目录不存在"
fi
- name: 检查PR模板
run: |
echo "检查PR模板..."
if [ -f ".github/PULL_REQUEST_TEMPLATE.md" ]; then
echo "✓ PR模板存在"
else
echo "警告PR模板不存在"
fi
- name: 检查工作协议和并行任务清单
run: |
echo "检查工作协议和并行任务清单..."
if [ -f "docs/working-agreement.md" ]; then
echo "✓ 工作协议存在"
else
echo "警告:工作协议不存在"
fi
if [ -f "docs/parallel-backlog.md" ]; then
echo "✓ 并行任务清单存在"
else
echo "警告:并行任务清单不存在"
fi