From c03d3ab14ae6bad5e9d66c5aef5e25b3da826eec Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 7 Jan 2023 15:23:40 +0100 Subject: [PATCH 1/4] chore(worklows/test): deno: change to use MMS instead of manual --- .github/workflows/test.yml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea565ae9e82..84e827c27a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,22 +90,31 @@ 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@755da8c3cf115ac066823e79a1e1788f8940201b # 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 + # - 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 - name: Setup node uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 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: From d8ed2a6041912c66193e3b6eb9df8e2b54c18b4b Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sat, 7 Jan 2023 15:30:37 +0100 Subject: [PATCH 2/4] test(deno.js): run mocha-fixtures --- package.json | 2 +- test/deno.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 757a14a2471..a6105b6959f 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,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 --unstable ./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 +}); From a65781acc522b468bd8e6cfa880c10e7b9709963 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Sun, 8 Jan 2023 14:40:40 +0100 Subject: [PATCH 3/4] chore(workflows/test): remove commented-out mongodb download --- .github/workflows/test.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 84e827c27a4..a239888022d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,16 +95,6 @@ jobs: MONGOMS_PREFER_GLOBAL_PATH: 1 steps: - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # 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 - name: Setup node uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1 with: From d9a6de728a45de99e0e4733d4175a7a85c14c523 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Tue, 7 Feb 2023 08:29:29 +0100 Subject: [PATCH 4/4] chore: remove "unstable" from deno and increase deno test version --- .github/workflows/test.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a239888022d..1095b8060a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -108,7 +108,7 @@ jobs: - 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 a6105b6959f..ca1a307c7d7 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,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 --allow-write --unstable ./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}",