diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0af88b7543..1afe213c7bb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,26 +90,25 @@ jobs: test-deno: runs-on: ubuntu-20.04 name: Deno tests + env: + MONGOMS_VERSION: 6.0.0 + MONGOMS_PREFER_GLOBAL_PATH: 1 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.0.2 - - name: Setup - run: | - wget -q https://downloads.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-6.0.0.tgz - tar xf mongodb-linux-x86_64-ubuntu2004-6.0.0.tgz - mkdir -p ./data/db/27017 ./data/db/27000 - printf "\ntimeout: 8000" >> ./.mocharc.yml - ./mongodb-linux-x86_64-ubuntu2004-6.0.0/bin/mongod --setParameter ttlMonitorSleepSecs=1 --fork --dbpath ./data/db/27017 --syslog --port 27017 - sleep 2 - mongod --version - echo `pwd`/mongodb-linux-x86_64-ubuntu2004-6.0.0/bin >> $GITHUB_PATH + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - name: Setup node uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version: 16 + - name: Load MongoDB binary cache + id: cache-mongodb-binaries + uses: actions/cache@v3 + with: + path: ~/.cache/mongodb-binaries + key: deno-${{ env.MONGOMS_VERSION }} - name: Setup Deno uses: denoland/setup-deno@v1 with: - deno-version: v1.28.x + deno-version: v1.30.x - run: deno --version - run: npm install - name: Run Deno tests diff --git a/package.json b/package.json index 7dfc40afe5d..791e2841b9c 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "release-legacy": "git pull origin 5.x && git push origin 5.x --tags && npm publish --tag legacy", "mongo": "node ./tools/repl.js", "test": "mocha --exit ./test/*.test.js", - "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys ./test/deno.js", + "test-deno": "deno run --allow-env --allow-read --allow-net --allow-run --allow-sys --allow-write ./test/deno.js", "test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js", "test-tsd": "node ./test/types/check-types-filename && tsd", "tdd": "mocha ./test/*.test.js --inspect --watch --recursive --watch-files ./**/*.{js,ts}", diff --git a/test/deno.js b/test/deno.js index 922766f1b20..9245e25da40 100644 --- a/test/deno.js +++ b/test/deno.js @@ -18,12 +18,19 @@ const Mocha = require('mocha'); const fs = require('fs'); const path = require('path'); +const fixtures = require('./mocha-fixtures.js') + const mocha = new Mocha({ timeout: 8000, ...(args.g ? { fgrep: '' + args.g } : {}) }); +// the following is required because mocha somehow does not load "require" options and so needs to be manually set-up +mocha.globalSetup(fixtures.mochaGlobalSetup); +mocha.globalTeardown(fixtures.mochaGlobalTeardown); + const testDir = 'test'; + const files = fs.readdirSync(testDir). concat(fs.readdirSync(path.join(testDir, 'docs')).map(file => path.join('docs', file))). concat(fs.readdirSync(path.join(testDir, 'helpers')).map(file => path.join('helpers', file))); @@ -41,4 +48,4 @@ for (const file of files) { mocha.run(function(failures) { process.exitCode = failures ? 1 : 0; // exit with non-zero status if there were failures process.exit(process.exitCode); -}); \ No newline at end of file +});