fix:修改测试用例,并将mongodb示例替换成mongodb-memory-server #2
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: Test & Coverage | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| name: Test on Node.js ${{ matrix.node-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x] | |
| os: [ubuntu-latest, windows-latest] | |
| mongodb-version: ['6.0'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Start MongoDB | |
| uses: supercharge/mongodb-github-action@1.10.0 | |
| with: | |
| mongodb-version: ${{ matrix.mongodb-version }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| env: | |
| MONGODB_URI: mongodb://localhost:27017 | |
| - name: Run coverage | |
| if: matrix.node-version == '20.x' && matrix.os == 'ubuntu-latest' | |
| run: npm run coverage | |
| - name: Upload coverage to Codecov | |
| if: matrix.node-version == '20.x' && matrix.os == 'ubuntu-latest' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| 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 ESLint | |
| run: npm run lint --if-present | |
| continue-on-error: true | |