From 094ad0cf441861099830097dd2bb32641717c95b Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 05:47:04 -0600 Subject: [PATCH 01/10] Store shared user buffer as ref --- read.js | 26 ++++++++++---------------- src/env.cpp | 51 +++++++++++++++++++++++++++++++++++++-------------- src/lmdb-js.h | 7 +++++-- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/read.js b/read.js index 7148d50f4..0587d5501 100644 --- a/read.js +++ b/read.js @@ -401,23 +401,17 @@ export function addReadMethods( keySize = this.writeKey(id, keyBytes, 4); } }; - let userSharedBuffers = - this._userSharedBuffers || (this._userSharedBuffers = new Map()); - let sharedBuffer = userSharedBuffers.get(id.toString()); - if (!sharedBuffer) { + setKeyBytes(); + let sharedBuffer = getUserSharedBuffer( + env.address, + keySize, + defaultBuffer, + options?.callback, + ); + sharedBuffer.notify = () => { setKeyBytes(); - sharedBuffer = getUserSharedBuffer( - env.address, - keySize, - defaultBuffer, - options?.callback, - ); - userSharedBuffers.set(id.toString(), sharedBuffer); - sharedBuffer.notify = () => { - setKeyBytes(); - return notifyUserCallbacks(env.address, keySize); - }; - } + return notifyUserCallbacks(env.address, keySize); + }; return sharedBuffer; }, diff --git a/src/env.cpp b/src/env.cpp index fb6d125d4..798e6c1df 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1074,6 +1074,11 @@ ExtendedEnv::ExtendedEnv() { pthread_mutex_init(&userBuffersLock, nullptr); } ExtendedEnv::~ExtendedEnv() { + // delete all user shared buffers refs + for (auto &buffer : userSharedBuffers) { + napi_delete_reference(buffer.second.env, buffer.second.buffer_ref); + } + pthread_mutex_destroy(&locksModificationLock); pthread_mutex_destroy(&userBuffersLock); } @@ -1085,14 +1090,13 @@ uint64_t ExtendedEnv::getNextTime() { uint64_t ExtendedEnv::getLastTime() { return bswap_64(lastTime); } + NAPI_FUNCTION(getUserSharedBuffer) { ARGS(4) GET_INT64_ARG(0) EnvWrap* ew = (EnvWrap*) i64; uint32_t size; GET_UINT32_ARG(size, 1); - MDB_val default_buffer; - napi_get_arraybuffer_info(env, args[2], &default_buffer.mv_data, &default_buffer.mv_size); ExtendedEnv* extend_env = (ExtendedEnv*) mdb_env_get_userctx(ew->env); std::string key(ew->keyBuffer, size); napi_value as_bool; @@ -1101,23 +1105,37 @@ NAPI_FUNCTION(getUserSharedBuffer) { napi_get_value_bool(env, as_bool, &has_callback); // get a shared buffer with the key, starting value, and convert pointer to an array buffer - MDB_val buffer = extend_env->getUserSharedBuffer(key, default_buffer, args[3], has_callback, env, ew); - if (buffer.mv_data == default_buffer.mv_data) return args[2]; - napi_value return_value; - napi_create_external_arraybuffer(env, buffer.mv_data, buffer.mv_size, cleanupLMDB, buffer.mv_data, &return_value); - return return_value; + napi_value buffer = extend_env->getUserSharedBuffer(key, args[2], args[3], has_callback, env, ew); + return buffer; } -/*napi_finalize cleanup_callback = [](napi_env env, void* data, void* buffer_info) { - // Data belongs to LMDB, we shouldn't free it here -}*/ -MDB_val ExtendedEnv::getUserSharedBuffer(std::string key, MDB_val default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew) { + +napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew) { pthread_mutex_lock(&userBuffersLock); + auto resolution = userSharedBuffers.find(key); if (resolution == userSharedBuffers.end()) { + void* default_buffer_data; + size_t default_buffer_size; + napi_get_arraybuffer_info(env, default_buffer, &default_buffer_data, &default_buffer_size); + + // Create a copy of the input buffer + char* copied_data = new char[default_buffer_size]; + memcpy(copied_data, default_buffer_data, default_buffer_size); + + napi_value buffer_value; + napi_create_external_arraybuffer(env, copied_data, default_buffer_size, nullptr, nullptr, &buffer_value); + + napi_ref buffer_ref; + napi_create_reference(env, buffer_value, 1, &buffer_ref); + user_buffer_t user_shared_buffer; - user_shared_buffer.buffer = default_buffer; + user_shared_buffer.buffer_ref = buffer_ref; + user_shared_buffer.env = env; resolution = userSharedBuffers.emplace(key, user_shared_buffer).first; + } else { + napi_reference_ref(env, resolution->second.buffer_ref, nullptr); } + if (has_callback) { napi_threadsafe_function callback; napi_value resource; @@ -1130,10 +1148,15 @@ MDB_val ExtendedEnv::getUserSharedBuffer(std::string key, MDB_val default_buffer napi_unref_threadsafe_function(env, callback); resolution->second.callbacks.push_back(callback); } - MDB_val buffer = resolution->second.buffer; + + napi_value buffer_value; + napi_get_reference_value(env, resolution->second.buffer_ref, &buffer_value); + pthread_mutex_unlock(&userBuffersLock); - return buffer; + + return buffer_value; } + /** * Notify the user callbacks associated with a user buffer for a given key * @param key diff --git a/src/lmdb-js.h b/src/lmdb-js.h index 65dc39b25..04dd734e4 100644 --- a/src/lmdb-js.h +++ b/src/lmdb-js.h @@ -282,10 +282,13 @@ typedef struct callback_holder_t { EnvWrap* ew; std::vector callbacks; } callback_holder_t; + typedef struct user_buffer_t { - MDB_val buffer; + napi_env env; + napi_ref buffer_ref; std::vector callbacks; } user_buffer_t; + class ExtendedEnv { public: ExtendedEnv(); @@ -298,7 +301,7 @@ class ExtendedEnv { pthread_mutex_t userBuffersLock; uint64_t lastTime; // actually encoded as double uint64_t previousTime; // actually encoded as double - MDB_val getUserSharedBuffer(std::string key, MDB_val default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew); + napi_value getUserSharedBuffer(std::string key, napi_value default_buffer, napi_value func, bool has_callback, napi_env env, EnvWrap* ew); bool notifyUserCallbacks(std::string key); bool attemptLock(std::string key, napi_env env, napi_value func, bool has_callback, EnvWrap* ew); bool unlock(std::string key, bool only_check); From e61649257816c37a642aaf538a8ba60f6b5015f4 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 15:14:44 -0600 Subject: [PATCH 02/10] Remove refs, use smart pointer instead, add ci test --- .github/workflows/test.yml | 32 +++++++ src/env.cpp | 26 ++---- src/lmdb-js.h | 4 +- test/index.test.js | 12 +-- test/threads.cjs | 181 +++++++++++++++++++++---------------- 5 files changed, 151 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..b0a0e84dc --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Tests + +on: [pull_request] + +concurrency: + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + test: + name: Test on Node ${{ matrix.node }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [16, 18] + # node: [16, 18, 20, 22] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test diff --git a/src/env.cpp b/src/env.cpp index 798e6c1df..4c33fe04b 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1074,11 +1074,6 @@ ExtendedEnv::ExtendedEnv() { pthread_mutex_init(&userBuffersLock, nullptr); } ExtendedEnv::~ExtendedEnv() { - // delete all user shared buffers refs - for (auto &buffer : userSharedBuffers) { - napi_delete_reference(buffer.second.env, buffer.second.buffer_ref); - } - pthread_mutex_destroy(&locksModificationLock); pthread_mutex_destroy(&userBuffersLock); } @@ -1118,22 +1113,13 @@ napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_ size_t default_buffer_size; napi_get_arraybuffer_info(env, default_buffer, &default_buffer_data, &default_buffer_size); - // Create a copy of the input buffer - char* copied_data = new char[default_buffer_size]; - memcpy(copied_data, default_buffer_data, default_buffer_size); - - napi_value buffer_value; - napi_create_external_arraybuffer(env, copied_data, default_buffer_size, nullptr, nullptr, &buffer_value); - - napi_ref buffer_ref; - napi_create_reference(env, buffer_value, 1, &buffer_ref); + std::shared_ptr buffer_data = std::make_shared(default_buffer_size); + memcpy(buffer_data.get(), default_buffer_data, default_buffer_size); user_buffer_t user_shared_buffer; - user_shared_buffer.buffer_ref = buffer_ref; - user_shared_buffer.env = env; + user_shared_buffer.data = buffer_data; + user_shared_buffer.size = default_buffer_size; resolution = userSharedBuffers.emplace(key, user_shared_buffer).first; - } else { - napi_reference_ref(env, resolution->second.buffer_ref, nullptr); } if (has_callback) { @@ -1149,8 +1135,10 @@ napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_ resolution->second.callbacks.push_back(callback); } + // Get the raw pointer from the shared_ptr + char* buffer_data = resolution->second.data.get(); napi_value buffer_value; - napi_get_reference_value(env, resolution->second.buffer_ref, &buffer_value); + napi_create_external_arraybuffer(env, buffer_data, resolution->second.size, nullptr, nullptr, &buffer_value); pthread_mutex_unlock(&userBuffersLock); diff --git a/src/lmdb-js.h b/src/lmdb-js.h index 04dd734e4..bcf924f6c 100644 --- a/src/lmdb-js.h +++ b/src/lmdb-js.h @@ -284,8 +284,8 @@ typedef struct callback_holder_t { } callback_holder_t; typedef struct user_buffer_t { - napi_env env; - napi_ref buffer_ref; + std::shared_ptr data; + size_t size; std::vector callbacks; } user_buffer_t; diff --git a/test/index.test.js b/test/index.test.js index 93d3b2b4c..f192c0f71 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -914,21 +914,21 @@ describe('lmdb-js', function () { }); it('getUserSharedBuffer', function () { let defaultIncrementer = new BigInt64Array(1); - defaultIncrementer[0] = 4n; let incrementer = new BigInt64Array( db.getUserSharedBuffer('incrementer-test', defaultIncrementer.buffer), ); + incrementer[0] = 4n; should.equal(Atomics.add(incrementer, 0, 1n), 4n); let secondDefaultIncrementer = new BigInt64Array(1); //should not get used - incrementer = new BigInt64Array( // should return same incrementer + let nextIncrementer = new BigInt64Array( // should return same incrementer db.getUserSharedBuffer( 'incrementer-test', secondDefaultIncrementer.buffer, ), ); - should.equal(defaultIncrementer[0], 5n); - should.equal(Atomics.add(incrementer, 0, 1n), 5n); - should.equal(defaultIncrementer[0], 6n); + should.equal(incrementer[0], 5n); + should.equal(Atomics.add(nextIncrementer, 0, 1n), 5n); + should.equal(incrementer[0], 6n); should.equal(secondDefaultIncrementer[0], 0n); }); it('getUserSharedBuffer with callbacks', async function () { @@ -2109,4 +2109,4 @@ describe('lmdb-js', function () { function delay(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); -} +} \ No newline at end of file diff --git a/test/threads.cjs b/test/threads.cjs index 1ad93f6c2..3e81fb8db 100644 --- a/test/threads.cjs +++ b/test/threads.cjs @@ -1,95 +1,122 @@ var assert = require('assert'); -const { Worker, isMainThread, parentPort, threadId } = require('worker_threads'); +const { + Worker, + isMainThread, + parentPort, + threadId, +} = require('worker_threads'); var path = require('path'); var numCPUs = require('os').cpus().length; +const { setFlagsFromString } = require('v8'); +const { runInNewContext } = require('vm'); + +setFlagsFromString('--expose_gc'); +const gc = runInNewContext('gc'); const { open } = require('../dist/index.cjs'); const MAX_DB_SIZE = 256 * 1024 * 1024; if (isMainThread) { - var inspector = require('inspector') -// inspector.open(9331, null, true);debugger + var inspector = require('inspector'); + // inspector.open(9331, null, true);debugger - // The main thread + // The main thread - let db = open({ - path: path.resolve(__dirname, './testdata'), - maxDbs: 10, - mapSize: MAX_DB_SIZE, - maxReaders: 126, - overlappingSync: true, - }); + let db = open({ + path: path.resolve(__dirname, './testdata'), + maxDbs: 10, + mapSize: MAX_DB_SIZE, + maxReaders: 126, + overlappingSync: true, + }); - var workerCount = Math.min(numCPUs * 2, 20); - var value = {test: '48656c6c6f2c20776f726c6421'}; - var str = 'this is supposed to be bigger than 16KB threshold for shared memory buffers'; - for (let i = 0; i < 9; i++) { - str += str; - } - var bigValue = {test: str}; - // This will start as many workers as there are CPUs available. - var workers = []; - for (var i = 0; i < workerCount; i++) { - var worker = new Worker(__filename); - workers.push(worker); - } + let incrementer = new BigInt64Array(1); + let incrementerBuffer = db.getUserSharedBuffer('test', incrementer.buffer); + incrementer = new BigInt64Array(incrementerBuffer); + incrementer[0] = 10000n; - var messages = []; - workers.forEach(function(worker) { - worker.on('message', function(msg) { - messages.push(msg); - // Once every worker has replied with a response for the value - // we can exit the test. + var workerCount = Math.min(numCPUs * 2, 20); + var value = { test: '48656c6c6f2c20776f726c6421' }; + var str = + 'this is supposed to be bigger than 16KB threshold for shared memory buffers'; + for (let i = 0; i < 9; i++) { + str += str; + } + var bigValue = { test: str }; + // This will start as many workers as there are CPUs available. + var workers = []; + for (var i = 0; i < workerCount; i++) { + var worker = new Worker(__filename); + workers.push(worker); + } - setTimeout(() => { - worker.terminate() - }, 100); - if (messages.length === workerCount) { - db.close(); - for (var i = 0; i < messages.length; i ++) { - assert(messages[i] === value.toString('hex')); - } - console.log("done", threadId) - //setTimeout(() => - //process.exit(0), 200); - } - }); - }); + var messages = []; + workers.forEach(function (worker) { + worker.on('message', function (msg) { + messages.push(msg); + // Once every worker has replied with a response for the value + // we can exit the test. - let last - for (var i = 0; i < workers.length; i++) { - last = db.put('key' + i, i % 2 === 1 ? bigValue : value); - } + setTimeout(() => { + worker.terminate(); + }, 100); + if (messages.length === workerCount) { + db.close(); + for (var i = 0; i < messages.length; i++) { + assert(messages[i] === value.toString('hex')); + } + assert(incrementer[0] === 10000n + BigInt(workerCount) * 10n); + console.log('done', threadId, incrementer[0]); + //setTimeout(() => + //process.exit(0), 200); + } + }); + }); - last.then(() => { - for (var i = 0; i < workers.length; i++) { - var worker = workers[i]; - worker.postMessage({key: 'key' + i}); - }; - }); + let last; + for (var i = 0; i < workers.length; i++) { + last = db.put('key' + i, i % 2 === 1 ? bigValue : value); + } + last.then(() => { + for (var i = 0; i < workers.length; i++) { + var worker = workers[i]; + worker.postMessage({ key: 'key' + i }); + } + }); } else { - // The worker process - let db = open({ - path: path.resolve(__dirname, './testdata'), - maxDbs: 10, - mapSize: MAX_DB_SIZE, - maxReaders: 126, - overlappingSync: true, - }); + // The worker process + let db = open({ + path: path.resolve(__dirname, './testdata'), + maxDbs: 10, + mapSize: MAX_DB_SIZE, + maxReaders: 126, + overlappingSync: true, + }); + parentPort.on('message', async function (msg) { + if (msg.key) { + for (let i = 0; i < 10; i++) { + let incrementer = new BigInt64Array(1); + incrementer[0] = 1n; // should be ignored + let incrementerBuffer = db.getUserSharedBuffer( + 'test', + incrementer.buffer, + ); + incrementer = new BigInt64Array(incrementerBuffer); + Atomics.add(incrementer, 0, 1n); + gc(); + await new Promise((resolve) => setTimeout(resolve, 100)); + } - parentPort.on('message', async function(msg) { - if (msg.key) { - var value = db.get(msg.key); - if (msg.key == 'key1' || msg.key == 'key3') { - await db.put(msg.key, 'updated'); - } - if (value === null) { - parentPort.postMessage(""); - } else { - parentPort.postMessage(value.toString('hex')); - } - - } - }); -} + var value = db.get(msg.key); + if (msg.key == 'key1' || msg.key == 'key3') { + await db.put(msg.key, 'updated'); + } + if (value === null) { + parentPort.postMessage(''); + } else { + parentPort.postMessage(value.toString('hex')); + } + } + }); +} \ No newline at end of file From 70aaefb002b10cdae1eb295c6b982865c29d58d6 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 15:17:32 -0600 Subject: [PATCH 03/10] Run ci tests on more platforms and Node.js versions --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0a0e84dc..d6d967ab0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,13 @@ concurrency: jobs: test: - name: Test on Node ${{ matrix.node }} - runs-on: ubuntu-latest + name: Test on Node.js ${{ matrix.node }} and ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - node: [16, 18] - # node: [16, 18, 20, 22] + node: [16, 18, 20, 22] + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - name: Checkout repository From 7b97396b117d8a3e94d3d1d25010548bbb806e73 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 15:24:56 -0600 Subject: [PATCH 04/10] Build before running test --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6d967ab0..0e4cd9a5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,5 +28,8 @@ jobs: - name: Install dependencies run: npm install + - name: Build + run: npm run build + - name: Run tests run: npm test From 1685cf95fd304e3780e30815de79320b974a2739 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 15:58:34 -0600 Subject: [PATCH 05/10] Skip macos + node 16 and windows + node 22 --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e4cd9a5c..eb5f65c6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: node: [16, 18, 20, 22] - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout repository @@ -26,10 +26,16 @@ jobs: node-version: ${{ matrix.node }} - name: Install dependencies + if: | + !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm install - name: Build + if: | + !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm run build - name: Run tests + if: | + !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm test From 6d3cf028afc7af408a027f7e6614daa06c8746b3 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 16:09:11 -0600 Subject: [PATCH 06/10] Cleanup --- src/env.cpp | 15 ++++++++------- src/lmdb-js.h | 5 +---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/env.cpp b/src/env.cpp index 4c33fe04b..1c2174ee1 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1113,12 +1113,15 @@ napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_ size_t default_buffer_size; napi_get_arraybuffer_info(env, default_buffer, &default_buffer_data, &default_buffer_size); - std::shared_ptr buffer_data = std::make_shared(default_buffer_size); - memcpy(buffer_data.get(), default_buffer_data, default_buffer_size); + char* buffer_data = new char[default_buffer_size]; + memcpy(buffer_data, default_buffer_data, default_buffer_size); + + MDB_val buffer; + buffer.mv_data = (void*)buffer_data; + buffer.mv_size = default_buffer_size; user_buffer_t user_shared_buffer; - user_shared_buffer.data = buffer_data; - user_shared_buffer.size = default_buffer_size; + user_shared_buffer.buffer = buffer; resolution = userSharedBuffers.emplace(key, user_shared_buffer).first; } @@ -1135,10 +1138,8 @@ napi_value ExtendedEnv::getUserSharedBuffer(std::string key, napi_value default_ resolution->second.callbacks.push_back(callback); } - // Get the raw pointer from the shared_ptr - char* buffer_data = resolution->second.data.get(); napi_value buffer_value; - napi_create_external_arraybuffer(env, buffer_data, resolution->second.size, nullptr, nullptr, &buffer_value); + napi_create_external_arraybuffer(env, resolution->second.buffer.mv_data, resolution->second.buffer.mv_size, nullptr, nullptr, &buffer_value); pthread_mutex_unlock(&userBuffersLock); diff --git a/src/lmdb-js.h b/src/lmdb-js.h index bcf924f6c..a8a34ffb9 100644 --- a/src/lmdb-js.h +++ b/src/lmdb-js.h @@ -282,13 +282,10 @@ typedef struct callback_holder_t { EnvWrap* ew; std::vector callbacks; } callback_holder_t; - typedef struct user_buffer_t { - std::shared_ptr data; - size_t size; + MDB_val buffer; std::vector callbacks; } user_buffer_t; - class ExtendedEnv { public: ExtendedEnv(); From c46195b2aa9d3414672895675619480e0da43cf0 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 17:21:55 -0600 Subject: [PATCH 07/10] Install python setup tools for macos --- .github/workflows/test.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb5f65c6e..09f85206c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,18 +24,23 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + + - name: Install Python dependencies + if: matrix.os == 'macos-latest' + run: | + python -m pip install setuptools - name: Install dependencies if: | - !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) + !(matrix.node == 22 && matrix.os == 'windows-latest') run: npm install - name: Build if: | - !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) + !(matrix.node == 22 && matrix.os == 'windows-latest') run: npm run build - name: Run tests if: | - !((matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) + !(matrix.node == 22 && matrix.os == 'windows-latest') run: npm test From 93b9ddceea1023a6c83f91daaea29c121106727d Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 17:26:39 -0600 Subject: [PATCH 08/10] Install latest node-gyp --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09f85206c..b3e4e462f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,8 +27,11 @@ jobs: - name: Install Python dependencies if: matrix.os == 'macos-latest' - run: | - python -m pip install setuptools + run: python -m pip install setuptools + + - name: Install latest node-gyp + if: matrix.os == 'macos-latest' + run: npm i -g node-gyp - name: Install dependencies if: | From e42d11f99f63cff78f0555d25a80bf77bf90f79b Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 17:28:17 -0600 Subject: [PATCH 09/10] Enable windows tests --- .github/workflows/test.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3e4e462f..9185083b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,26 +24,18 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - - - name: Install Python dependencies - if: matrix.os == 'macos-latest' - run: python -m pip install setuptools - - - name: Install latest node-gyp - if: matrix.os == 'macos-latest' - run: npm i -g node-gyp - name: Install dependencies if: | - !(matrix.node == 22 && matrix.os == 'windows-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') run: npm install - name: Build if: | - !(matrix.node == 22 && matrix.os == 'windows-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') run: npm run build - name: Run tests if: | - !(matrix.node == 22 && matrix.os == 'windows-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') run: npm test From c4bc187f6b447f9d83b7d4254af6d0c15505abf1 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Fri, 3 Jan 2025 17:32:59 -0600 Subject: [PATCH 10/10] Ignore windows + node 22 --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9185083b8..253e9d2cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,15 +27,15 @@ jobs: - name: Install dependencies if: | - !(matrix.node == 16 && matrix.os == 'macos-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm install - name: Build if: | - !(matrix.node == 16 && matrix.os == 'macos-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm run build - name: Run tests if: | - !(matrix.node == 16 && matrix.os == 'macos-latest') + !(matrix.node == 16 && matrix.os == 'macos-latest') || (matrix.node == 22 && matrix.os == 'windows-latest')) run: npm test