Merge pull request #14887 from Automattic/vkarpov15/gh-3027 #9269
This file contains 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 | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/test.yml' | |
- 'package.json' | |
- 'index.js' | |
- 'lib/**' | |
- 'test/**.js' | |
push: | |
paths: | |
- '.github/workflows/test.yml' | |
- 'package.json' | |
- 'index.js' | |
- 'lib/**' | |
- 'test/**.js' | |
permissions: | |
contents: read | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
name: Lint JS-Files | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: 18 | |
- run: npm install | |
- name: Lint JS-Files | |
run: npm run lint-js | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [16, 18, 20] | |
os: [ubuntu-20.04, ubuntu-22.04] | |
mongodb: [4.4.29, 5.0.26, 6.0.15, 7.0.12] | |
include: | |
- os: ubuntu-20.04 # customize on which matrix the coverage will be collected on | |
mongodb: 5.0.26 | |
node: 16 | |
coverage: true | |
exclude: | |
- os: ubuntu-22.04 # exclude because there are no 4.x mongodb builds for 2204 | |
mongodb: 4.4.29 | |
- os: ubuntu-22.04 # exclude because there are no 5.x mongodb builds for 2204 | |
mongodb: 5.0.26 | |
name: Node ${{ matrix.node }} MongoDB ${{ matrix.mongodb }} OS ${{ matrix.os }} | |
env: | |
MONGOMS_VERSION: ${{ matrix.mongodb }} | |
MONGOMS_PREFER_GLOBAL_PATH: 1 | |
FORCE_COLOR: true | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: Load MongoDB binary cache | |
id: cache-mongodb-binaries | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/mongodb-binaries | |
key: ${{ matrix.os }}-${{ matrix.mongodb }} | |
- run: npm install | |
- name: NPM Test without Coverage | |
run: npm test | |
if: matrix.coverage != true | |
- name: NPM Test with Coverage | |
run: npm run test-coverage | |
if: matrix.coverage == true | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
if: matrix.coverage == true | |
with: | |
name: coverage | |
path: coverage | |
test-deno: | |
runs-on: ubuntu-20.04 | |
name: Deno tests | |
env: | |
MONGOMS_VERSION: 6.0.15 | |
MONGOMS_PREFER_GLOBAL_PATH: 1 | |
FORCE_COLOR: true | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: 16 | |
- name: Load MongoDB binary cache | |
id: cache-mongodb-binaries | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/mongodb-binaries | |
key: deno-${{ env.MONGOMS_VERSION }} | |
- name: Setup Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.37.x | |
- run: deno --version | |
- run: npm install | |
- name: Run Deno tests | |
run: npm run test-deno | |
test-replica-sets: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
name: Replica Set tests | |
env: | |
FORCE_COLOR: true | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup node | |
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 | |
with: | |
node-version: 16 | |
- run: npm install | |
- name: Test | |
run: npm run test-rs | |
dependency-review: | |
name: Dependency Review | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Dependency review | |
uses: actions/dependency-review-action@v4 |