|
| 1 | +--- |
| 2 | +name: Code Health (fork) |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: {} |
| 9 | + |
| 10 | +jobs: |
| 11 | + run-tests: |
| 12 | + name: Run MongoDB tests |
| 13 | + if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version-file: package.json |
| 21 | + cache: "npm" |
| 22 | + - name: Install dependencies |
| 23 | + run: npm ci |
| 24 | + - name: Run tests |
| 25 | + run: npm test |
| 26 | + - name: Upload test results |
| 27 | + if: always() |
| 28 | + uses: actions/upload-artifact@v4 |
| 29 | + with: |
| 30 | + name: test-results |
| 31 | + path: coverage/lcov.info |
| 32 | + |
| 33 | + run-atlas-tests: |
| 34 | + name: Run Atlas tests |
| 35 | + if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - uses: GitHubSecurityLab/actions-permissions/monitor@v1 |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + - uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version-file: package.json |
| 43 | + cache: "npm" |
| 44 | + - name: Install dependencies |
| 45 | + run: npm ci |
| 46 | + - name: Run tests |
| 47 | + env: |
| 48 | + MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }} |
| 49 | + MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }} |
| 50 | + MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }} |
| 51 | + run: npm test -- --testPathIgnorePatterns "tests/integration/tools/mongodb" --testPathIgnorePatterns "tests/integration/[^/]+\.ts" |
| 52 | + - name: Upload test results |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + if: always() |
| 55 | + with: |
| 56 | + name: atlas-test-results |
| 57 | + path: coverage/lcov.info |
| 58 | + |
| 59 | + coverage: |
| 60 | + name: Report Coverage |
| 61 | + if: always() && github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: [run-tests, run-atlas-tests] |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + - uses: actions/setup-node@v4 |
| 67 | + with: |
| 68 | + node-version-file: package.json |
| 69 | + cache: "npm" |
| 70 | + - name: Install dependencies |
| 71 | + run: npm ci |
| 72 | + - name: Download test results |
| 73 | + uses: actions/download-artifact@v4 |
| 74 | + with: |
| 75 | + name: test-results |
| 76 | + path: coverage/mongodb |
| 77 | + - name: Download atlas test results |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: atlas-test-results |
| 81 | + path: coverage/atlas |
| 82 | + - name: Merge coverage reports |
| 83 | + run: | |
| 84 | + npx -y [email protected] "coverage/*/lcov.info" "coverage/lcov.info" |
| 85 | + - name: Coveralls GitHub Action |
| 86 | + uses: coverallsapp/[email protected] |
| 87 | + with: |
| 88 | + file: coverage/lcov.info |
| 89 | + git-branch: ${{ github.head_ref || github.ref_name }} |
| 90 | + git-commit: ${{ github.event.pull_request.head.sha || github.sha }} |
| 91 | + |
| 92 | + merge-dependabot-pr: |
| 93 | + name: Merge Dependabot PR |
| 94 | + if: github.event.pull_request.user.login == 'dependabot[bot]' |
| 95 | + runs-on: ubuntu-latest |
| 96 | + permissions: |
| 97 | + pull-requests: write |
| 98 | + contents: write |
| 99 | + needs: |
| 100 | + - coverage |
| 101 | + steps: |
| 102 | + - name: Enable auto-merge for Dependabot PRs |
| 103 | + run: gh pr merge --auto --squash "$PR_URL" |
| 104 | + env: |
| 105 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 106 | + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
0 commit comments