feat(plugin-blocklet): support custom chunkSizeLimit [release-minor] #61
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ensure-create-blocklet-successfully | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| ensure-create-blocklet-successfully: | |
| name: ${{ matrix.os }} + Node ${{ matrix.node }} + ${{ matrix.package-manager }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| node: [22] | |
| package-manager: [pnpm] | |
| template: [ | |
| # DApp templates | |
| react-dapp, | |
| react-dapp-ts, | |
| react-aigne-dapp, | |
| did-wallet-dapp, | |
| todo-list-example, | |
| did-connect-dapp, | |
| solidjs-dapp, | |
| vue-dapp, | |
| # svelte-dapp, | |
| # Static templates | |
| react-static, | |
| solidjs-static, | |
| vue-static, | |
| vue-ts-static, | |
| svelte-static, | |
| html-static, | |
| # API templates | |
| express-api, | |
| nestjs-api | |
| ] | |
| env: | |
| PACKAGE_MANAGER: ${{ matrix.package-manager }} | |
| TEMPLATE: ${{ matrix.template }} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| steps: | |
| - uses: 8BitJonny/gh-get-current-pr@1.4.0 | |
| id: PR | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| sha: ${{ github.event.pull_request.head.sha }} | |
| filterOutClosed: true | |
| - name: Check WIP in PR Title | |
| uses: embano1/wip@v1 | |
| with: | |
| title: '${{ steps.PR.outputs.pr_title }}' | |
| regex: '^WIP' | |
| - name: 检查 OPENAI_API_KEY | |
| if: matrix.template == 'react-aigne-dapp' | |
| run: | | |
| if [ -z "$OPENAI_API_KEY" ]; then | |
| echo "❌ 使用 react-aigne-dapp 模板时必须设置 OPENAI_API_KEY 环境变量" | |
| exit 1 | |
| fi | |
| echo "✅ OPENAI_API_KEY 环境变量已设置" | |
| - name: 检出代码 | |
| uses: actions/checkout@v3 | |
| - name: 设置 Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: 安装 pnpm | |
| if: matrix.package-manager == 'pnpm' | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| # pnpm 10 需要 approve-builds,不支持在 CI 中使用,暂时使用 pnpm 9 | |
| version: 9 | |
| - name: 安装 yarn | |
| if: matrix.package-manager == 'yarn' | |
| run: | | |
| npm install -g yarn | |
| - name: Install Nginx with stream module | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nginx-extras # nginx-extras 包含 ngx_stream_module | |
| sudo nginx -t # 测试配置文件是否正确 | |
| sudo setcap 'cap_net_bind_service=+ep' $(which nginx) | |
| - name: Install build tools | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get update && sudo apt-get install -y build-essential | |
| - name: 安装 blocklet CLI | |
| run: | | |
| npm install -g @blocklet/cli | |
| - name: 启动 blocklet server | |
| run: | | |
| # 创建一个临时文件来存储输出 | |
| OUTPUT_FILE=$(mktemp) | |
| # 启动server并将输出重定向到文件 | |
| # 使用跨平台方式处理超时,替代timeout命令 | |
| if [[ "${{ runner.os }}" == "macOS" ]]; then | |
| # macOS方式实现超时 | |
| ( | |
| blocklet server start -a | tee $OUTPUT_FILE & | |
| SERVER_PID=$! | |
| # 最多等待120秒,但不杀掉进程 | |
| sleep 120 | |
| # 不再杀掉服务进程,让它继续运行 | |
| echo "后台服务进程ID: $SERVER_PID" | |
| ) & | |
| else | |
| # Linux方式使用timeout | |
| timeout 120s bash -c "blocklet server start -a | tee $OUTPUT_FILE" & | |
| fi | |
| # 设置最大等待时间 | |
| START_TIME=$(date +%s) | |
| END_TIME=$((START_TIME + 120)) | |
| SUCCESS=false | |
| # 循环检查输出文件是否包含成功标记 | |
| while [ $(date +%s) -lt $END_TIME ]; do | |
| if grep -q "Secure URLs" $OUTPUT_FILE; then | |
| SUCCESS=true | |
| break | |
| fi | |
| sleep 2 | |
| done | |
| # 如果成功,返回0,否则返回错误 | |
| if $SUCCESS; then | |
| echo "✅ Blocklet Server 成功启动 - 检测到 'Secure URLs'" | |
| # 提取 Secure URL | |
| SERVER_URL=$(grep -A 5 "Secure URLs" $OUTPUT_FILE | grep "https://" | head -n 1 | sed 's/^[ \t]*-*[ \t]*//g' | sed 's/^*//g') | |
| echo "找到服务器URL: $SERVER_URL" | |
| # 将URL保存为GitHub Actions环境变量 | |
| echo "SERVER_URL=$SERVER_URL" >> $GITHUB_ENV | |
| # 显示日志以便调试 | |
| tail $OUTPUT_FILE | |
| exit 0 | |
| else | |
| echo "❌ Blocklet Server 启动失败或超时 - 未检测到 'Secure URLs'" | |
| echo "最后60行日志:" | |
| tail -n 60 $OUTPUT_FILE | |
| exit 1 | |
| fi | |
| - name: 检查服务器是否正常运行 | |
| if: success() | |
| run: | | |
| # 使用提取的URL进行HTTP验证 | |
| echo "正在检查URL: ${{ env.SERVER_URL }}" | |
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -I ${{ env.SERVER_URL }}) | |
| if [ "$HTTP_STATUS" == "200" ]; then | |
| echo "✅ Blocklet Server 成功响应HTTP请求,状态码: $HTTP_STATUS" | |
| else | |
| echo "⚠️ Blocklet Server 启动了,但HTTP请求返回状态码: $HTTP_STATUS" | |
| exit 1 | |
| fi | |
| - name: 安装依赖 | |
| run: | | |
| pnpm install | |
| - name: 测试创建应用 | |
| run: | | |
| npm run e2e |