Compatibility Matrix Tests #197
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: Compatibility Matrix Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| schedule: | |
| # 每日 UTC 00:00 运行完整矩阵 | |
| - cron: '0 0 * * *' | |
| jobs: | |
| # 核心组合测试(每次 PR 运行) | |
| core-compatibility: | |
| name: Core - Node ${{ matrix.node }} / Driver ${{ matrix.driver }} / ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| # 核心 LTS 版本 | |
| node: ['18.x', '20.x'] | |
| # 当前使用的驱动版本 | |
| driver: ['6.17.0'] | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run compatibility tests | |
| run: npm run test:compatibility | |
| - name: Upload results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: core-results-node${{ matrix.node }}-${{ matrix.os }} | |
| path: reports/monSQLize/compatibility-*.json | |
| # 完整矩阵测试(仅在 main 分支和定时任务) | |
| full-matrix: | |
| name: Full - Node ${{ matrix.node }} / Driver ${{ matrix.driver }} | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'schedule' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # 所有支持的 Node.js 版本 | |
| node: ['14.x', '16.x', '18.x', '20.x', '22.x'] | |
| # 多个 MongoDB Driver 版本 | |
| driver: ['4.17.2', '5.9.2', '6.17.0'] | |
| exclude: | |
| # Node.js 14 不支持最新的某些依赖 | |
| - node: '14.x' | |
| driver: '6.17.0' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: Install dependencies (default driver) | |
| run: npm ci | |
| - name: Install specific MongoDB Driver version | |
| run: | | |
| npm uninstall mongodb | |
| npm install mongodb@${{ matrix.driver }} --save-exact | |
| - name: Run compatibility tests | |
| run: npm run test:compatibility | |
| continue-on-error: true | |
| - name: Upload results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: full-results-node${{ matrix.node }}-driver${{ matrix.driver }} | |
| path: reports/monSQLize/compatibility-*.json | |
| # Server 版本测试(Memory Server 模式) | |
| server-compatibility: | |
| name: Server Compatibility (Memory Server) | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.event_name == 'schedule' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Server compatibility tests | |
| run: npm run test:compatibility:server | |
| continue-on-error: true | |
| - name: Upload results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: server-results | |
| path: reports/monSQLize/server-compatibility-*.json | |
| # 生成兼容性报告 | |
| generate-report: | |
| name: Generate Compatibility Report | |
| runs-on: ubuntu-latest | |
| needs: [core-compatibility, full-matrix, server-compatibility] | |
| if: always() | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| - name: Download all results | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: test-results | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Generate combined report | |
| run: | | |
| node scripts/generate-compatibility-report.js test-results | |
| - name: Upload report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: compatibility-report | |
| path: reports/monSQLize/compatibility-report-*.md | |
| - name: Comment PR with report | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const reportPath = 'reports/monSQLize/compatibility-report-latest.md'; | |
| if (fs.existsSync(reportPath)) { | |
| const report = fs.readFileSync(reportPath, 'utf8'); | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: report | |
| }); | |
| } | |