New action test
Build Sphinx Documentation / Build Documentation from PR Branch (pull_request) Failing after 3m5s

This commit is contained in:
2025-08-25 12:56:59 +08:00
parent d9e0b2f6bd
commit 6f7975959f
+34 -61
View File
@@ -1,82 +1,55 @@
#For test name: Build Sphinx Documentation
name: Build and Deploy Sphinx Docs
on: on:
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened, edited]
branches: [master] branches: [master]
jobs: jobs:
build-docs: build-docs:
name: Build Documentation name: Build Documentation from PR Branch
runs-on: linux runs-on: linux
steps: steps:
# 第一步:设置主工作目录和稳定的虚拟环境 # 第一步:检出PR分支代码
- name: Set up master worktree with stable environment - name: Checkout PR branch
run: | uses: actions/checkout@v4
echo "=== Setting up master worktree ===" with:
ref: ${{ github.head_ref }} # 检出PR分支而不是主分支
fetch-depth: 0
# 创建主工作目录并克隆仓库 # 第二步:设置Python虚拟环境
if [ ! -d /home/ly0kos/work/test_env ]; then - name: Set up Python virtual environment
echo "Cloning repository to master worktree..." run: |
git clone http://localhost:3000/yuysh/Manlink_Doc.git /home/ly0kos/work/test_env echo "Setting up Python environment for PR branch"
cd /home/ly0kos/work/test_env python -m venv /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}
echo "Creating virtual environment..." source /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}/bin/activate
python -m venv .venv
source .venv/bin/activate
echo "Installing dependencies..."
pip install --upgrade pip pip install --upgrade pip
if [ -f requirements.txt ]; then
pip install -r requirements.txt pip install -r requirements.txt
echo "✓ master worktree and virtual environment created"
else else
echo "Updating existing master worktree..." echo "No requirements.txt found, installing sphinx"
cd /home/ly0kos/work/test_env pip install sphinx
git pull origin master
source .venv/bin/activate
echo "Updating dependencies if needed..."
pip install -r requirements.txt
echo "✓ master worktree updated"
fi fi
# 验证环境 # 第三步:构建文档(从PR分支)
echo "Environment verification:" - name: Build documentation from PR branch
source .venv/bin/activate
echo "Python: $(python --version)"
echo "Sphinx-build: $(sphinx-build --version 2>/dev/null || echo 'Not found')"
# 第二步:创建临时构建工作树
- name: Create temporary build worktree
run: | run: |
echo "=== Creating build worktree ===" echo "=== Building documentation from PR branch: ${{ github.head_ref }} ==="
cd /home/ly0kos/work/test_env source /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}/bin/activate
# 清理可能存在的旧构建目录 # 在PR分支目录中构建
if [ -d /home/ly0kos/work/test_env/build ]; then sphinx-build -b html ./docs ./build -v -j 4
echo "Removing old build worktree..."
git worktree remove /home/ly0kos/work/test_env/build --force 2>/dev/null || true
rm -rf /home/ly0kos/work/test_env/build 2>/dev/null || true
fi
# 创建新的构建工作树 # 将构建结果移动到共享位置,便于查看
echo "Creating new build worktree..." rm -rf /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
git worktree add /home/ly0kos/work/test_env/build mkdir -p /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
echo "✓ Build worktree created at /home/ly0kos/work/test_env/build" cp -r ./build/* /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/
# 第三步:使用主目录的虚拟环境构建文档 echo "✓ Build completed for PR branch: ${{ github.head_ref }}"
- name: Build documentation
# 第四步:验证构建结果
- name: Verify build
run: | run: |
echo "=== Building documentation ===" echo "Build output for PR ${{ github.head_ref }}:"
cd /home/ly0kos/work/test_env ls -la /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/ | head -10
source .venv/bin/activate
echo "Building from: /home/ly0kos/work/test_env/source"
echo "Output to: /home/ly0kos/work/test_env/build/build"
# 使用主目录的虚拟环境来构建构建目录中的代码
sphinx-build -b html /home/ly0kos/work/test_env/source /home/ly0kos/work/test_env/build/ -v -j 4
echo "✓ Build completed successfully"
# 验证构建结果
echo "Build output contents:"
ls -la /home/ly0kos/work/test_env/build/