Cron CI #29
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: Cron CI | |
| on: | |
| schedule: | |
| # 每天 UTC 时间 02:00 运行(北京时间 10:00) | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| # Cancel previous workflows if they are the same workflow on same ref | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
| cancel-in-progress: true | |
| env: | |
| ZIG_VERSION: "0.15.1" | |
| jobs: | |
| # 定时全面测试 | |
| cron-test: | |
| name: Cron Test (${{ matrix.os }} ${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # 主要平台和架构 | |
| - os: ubuntu-latest | |
| arch: x86_64-linux | |
| target: x86_64-linux | |
| - os: ubuntu-latest | |
| arch: aarch64-linux | |
| target: aarch64-linux | |
| - os: macos-latest | |
| arch: aarch64-macos | |
| target: aarch64-macos | |
| - os: windows-latest | |
| arch: x86_64-windows | |
| target: x86_64-windows | |
| # 特殊架构 | |
| - os: ubuntu-latest | |
| arch: riscv64-linux | |
| target: riscv64-linux | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ env.ZIG_VERSION }} | |
| - name: Verify Zig installation | |
| run: zig version | |
| - name: Show system info | |
| run: | | |
| echo "OS: ${{ matrix.os }}" | |
| echo "Architecture: ${{ matrix.arch }}" | |
| echo "Target: ${{ matrix.target }}" | |
| uname -a || echo "uname not available" | |
| - name: Build project (native) | |
| run: zig build | |
| - name: Build project (cross-compile) | |
| run: zig build -Dtarget=${{ matrix.target }} | |
| if: matrix.target != matrix.arch | |
| - name: Run comprehensive tests | |
| run: | | |
| zig build test | |
| zig test tests/unit/ | |
| zig test tests/integration/ | |
| - name: Run performance benchmarks | |
| run: zig test tests/benchmarks/ -Doptimize=ReleaseFast | |
| - name: Check formatting | |
| run: zig fmt --check . | |
| - name: Build documentation | |
| run: zig build docs | |
| - name: Upload cron test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: cron-test-results-${{ matrix.os }}-${{ matrix.arch }} | |
| path: | | |
| zig-cache/ | |
| zig-out/ | |
| # 依赖检查 | |
| dependency-check: | |
| name: Dependency Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ env.ZIG_VERSION }} | |
| - name: Check for outdated dependencies | |
| run: | | |
| echo "Checking for outdated Zig version..." | |
| zig version | |
| echo "Current Zig version: ${{ env.ZIG_VERSION }}" | |
| echo "Latest available versions can be checked at: https://ziglang.org/download/" | |
| - name: Check build system compatibility | |
| run: | | |
| zig build --help | |
| zig test --help | |
| # 长期稳定性测试 | |
| stability-test: | |
| name: Stability Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ env.ZIG_VERSION }} | |
| - name: Long-running stability test | |
| run: | | |
| echo "Running long-running stability tests..." | |
| # 多次构建测试 | |
| for i in {1..5}; do | |
| echo "Build iteration $i" | |
| zig build clean | |
| zig build | |
| zig build test | |
| done | |
| # 内存压力测试 | |
| echo "Running memory stress tests..." | |
| zig test tests/benchmarks/ -Doptimize=ReleaseFast | |
| - name: Upload stability test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: stability-test-results | |
| path: | | |
| zig-cache/ | |
| zig-out/ | |
| # 多版本兼容性测试 | |
| version-compatibility: | |
| name: Version Compatibility | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| zig-version: ["0.15.0", "0.15.1", "0.16.0"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig ${{ matrix.zig-version }} | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ matrix.zig-version }} | |
| - name: Verify Zig installation | |
| run: zig version | |
| - name: Test compatibility with Zig ${{ matrix.zig-version }} | |
| run: | | |
| zig build | |
| zig build test | |
| - name: Upload compatibility test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: compatibility-test-${{ matrix.zig-version }} | |
| path: | | |
| zig-cache/ | |
| zig-out/ | |
| # 性能回归测试 | |
| performance-regression: | |
| name: Performance Regression | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ env.ZIG_VERSION }} | |
| - name: Run performance benchmarks | |
| run: | | |
| echo "Running performance regression tests..." | |
| zig test tests/benchmarks/ -Doptimize=ReleaseFast --summary all | |
| - name: Compare with baseline | |
| run: | | |
| echo "Performance baseline comparison would go here" | |
| echo "This could integrate with performance monitoring tools" | |
| - name: Upload performance results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: performance-regression-results | |
| path: | | |
| benchmark-results.json | |
| # 安全扫描 | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Zig | |
| uses: goto-bus-stop/setup-zig@v2 | |
| with: | |
| version: ${{ env.ZIG_VERSION }} | |
| - name: Run security checks | |
| run: | | |
| echo "Running security scans..." | |
| # 构建安全检查 | |
| zig build -Doptimize=ReleaseSafe | |
| zig build -Doptimize=ReleaseFast | |
| # 内存安全检查 | |
| zig build -Doptimize=Debug -fsanitize=address | |
| - name: Check for known vulnerabilities | |
| run: | | |
| echo "Checking for known vulnerabilities..." | |
| echo "This could integrate with security scanning tools" | |
| # 总结报告 | |
| cron-summary: | |
| name: Cron Summary | |
| runs-on: ubuntu-latest | |
| needs: [cron-test, dependency-check, stability-test, version-compatibility, performance-regression, security-scan] | |
| if: always() | |
| steps: | |
| - name: Cron CI Summary | |
| run: | | |
| echo "## 定时 CI 测试总结" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| 测试类型 | 状态 |" >> $GITHUB_STEP_SUMMARY | |
| echo "|---------|------|" >> $GITHUB_STEP_SUMMARY | |
| echo "| 多平台测试 | ${{ needs.cron-test.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| 依赖检查 | ${{ needs.dependency-check.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| 稳定性测试 | ${{ needs.stability-test.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| 版本兼容性 | ${{ needs.version-compatibility.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| 性能回归 | ${{ needs.performance-regression.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "| 安全扫描 | ${{ needs.security-scan.result }} |" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**测试时间**: $(date)" >> $GITHUB_STEP_SUMMARY | |
| echo "**触发方式**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY |