From 5097e885655fa2086e10cdf084a77663cb7766cc Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 3 Dec 2024 08:12:29 -0700 Subject: [PATCH 1/3] test(NODE-6586): add regression test to ensure compressionLevel works (#46) --- test/index.test.js | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/test/index.test.js b/test/index.test.js index d3f030a..523b295 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -33,6 +33,13 @@ describe('decompress', function () { }); describe('compress', function () { + test('compress() supports compressionLevel', async function () { + const buffer = Buffer.from(historyFile()); + const unspecified = await compress(buffer); + const specified = await compress(buffer, 22); + + expect(specified.length).to.be.lessThan(unspecified.length); + }); test('compress() throws a TypeError', async function () { expect(await compress().catch(e => e)) .to.be.instanceOf(TypeError) @@ -81,3 +88,115 @@ function testSuite(decompress, compress) { }); }; } + +/** + * This function returns a string that, when compressed with compression level 22, + * compresses smaller than the default level 3. This is used to ensure that we handle + * the compression level option. + */ +function historyFile() { + return ` +# Changelog + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [v2.0.0-alpha.0](https://github.com/mongodb-js/zstd/compare/v1.2.2...v2.0.0-alpha.0) (2024-11-27) + +### Features + +* **NODE-4569:** add "musl" builds for Alpine Linux ([#12](https://github.com/mongodb-js/zstd/issues/12)) ([b3dedc3](https://github.com/mongodb-js/zstd/commit/b3dedc31a274df1eecb54b9092c8dd270f31c21c)) +* **NODE-6539:** add base napi C++ template with standard Node team tooling ([#28](https://github.com/mongodb-js/zstd/issues/28)) ([8c40b08](https://github.com/mongodb-js/zstd/commit/8c40b08782969c87b85d5d1bea0a753db73cc87f)) +* **NODE-6540:** Add c++ zstd compression API ([#30](https://github.com/mongodb-js/zstd/issues/30)) ([6673245](https://github.com/mongodb-js/zstd/commit/667324522600abc6f731b54a9d9a7c6e92954bef)) +* **NODE-6588:** add ssdlc to zstd ([#43](https://github.com/mongodb-js/zstd/issues/43)) ([016d857](https://github.com/mongodb-js/zstd/commit/016d857ccb76f01ebaf18e01756b571338723a16)) + +### [1.2.2](https://github.com/mongodb-js/zstd/compare/v1.2.1...v1.2.2) (2024-09-16) + + +### Bug Fixes + +* **NODE-6381:** use targeting for x86_64 darwin ([#26](https://github.com/mongodb-js/zstd/issues/26)) ([f95c9f6](https://github.com/mongodb-js/zstd/commit/f95c9f6b1e836cce7da4e6955181261110e88487)) + +### [1.2.1](https://github.com/mongodb-js/zstd/compare/v1.2.0...v1.2.1) (2024-09-06) + + +### Bug Fixes + +* **NODE-6348:** Wrap thrown errors in JS Error objects with stacks ([#25](https://github.com/mongodb-js/zstd/issues/25)) ([af62c4f](https://github.com/mongodb-js/zstd/commit/af62c4f5f816386ce605c20641ad30cc74bb77e2)) + +## [1.2.0](https://github.com/mongodb-js/zstd/compare/v1.1.0...v1.2.0) (2023-08-29) + + +### Bug Fixes + +* **NODE-5177:** update to latest zstd-sys ([#15](https://github.com/mongodb-js/zstd/issues/15)) ([6b6d8ce](https://github.com/mongodb-js/zstd/commit/6b6d8ce098de757c53fd52a09d47aa3e29ed2902)) + +## [1.1.0](https://github.com/mongodb-js/zstd/compare/v1.0.0...v1.1.0) (2023-01-23) + + +### Features + +* **NODE-4569:** add "musl" builds for Alpine Linux ([#12](https://github.com/mongodb-js/zstd/issues/12)) ([b3dedc3](https://github.com/mongodb-js/zstd/commit/b3dedc31a274df1eecb54b9092c8dd270f31c21c)) + +## [1.0.0](https://github.com/mongodb-js/zstd/compare/v0.0.7...v1.0.0) (2022-05-18) + +### [0.0.7](https://github.com/mongodb-js/zstd/compare/v0.0.6...v0.0.7) (2022-05-18) + + +### Bug Fixes + +* fix macos arm64 build ([#9](https://github.com/mongodb-js/zstd/issues/9)) ([1ebefde](https://github.com/mongodb-js/zstd/commit/1ebefdedb761b34bcc721a934296d3ac9f0e7a1b)) + +### [0.0.6](https://github.com/mongodb-js/zstd/compare/v0.0.5...v0.0.6) (2022-05-18) + + +### Features + +* add readme ([833aa92](https://github.com/mongodb-js/zstd/commit/833aa92213236ef35c4bd79d4c462751a3b4e634)) +* update readme ([49ac44e](https://github.com/mongodb-js/zstd/commit/49ac44efbe9a4ab544958b97ae178b51cac057ff)) + +### [0.0.5](https://github.com/mongodb-js/zstd/compare/v0.0.4...v0.0.5) (2022-05-09) + + +### Bug Fixes + +* remove 686 win build ([ea36ddc](https://github.com/mongodb-js/zstd/commit/ea36ddc0ce3e6630321e7074a138f2d45dd16f4f)) + +### [0.0.4](https://github.com/mongodb-js/zstd/compare/v0.0.3...v0.0.4) (2022-05-06) + + +### Features + +* **NODE-1837:** support passing compression level ([2c1a917](https://github.com/mongodb-js/zstd/commit/2c1a9171c689c1fc87428d383ffeb823291f84cf)) + +### [0.0.3](https://github.com/mongodb-js/zstd/compare/v0.0.2...v0.0.3) (2022-05-06) + + +### Bug Fixes + +* update publish task regex ([b62d9b0](https://github.com/mongodb-js/zstd/commit/b62d9b0e644c85d3443f738d953ae7816d3eba00)) + +### [0.0.2](https://github.com/mongodb-js/zstd/compare/v0.0.1...v0.0.2) (2022-05-06) + + +### Bug Fixes + +* dont use org in napi name ([9063ea8](https://github.com/mongodb-js/zstd/commit/9063ea8bb7b187aacd876f75b3e74bc0188e7a2b)) + +### 0.0.1 (2022-05-05) + + +### Features + +* add release script ([c2c1783](https://github.com/mongodb-js/zstd/commit/c2c1783242766c8b65f57838494d1a3c4dc23305)) +* add standard version ([f63a9b9](https://github.com/mongodb-js/zstd/commit/f63a9b95ba261004cb2f481ff201fa2e116d3aed)) +* initial project setup ([53671a3](https://github.com/mongodb-js/zstd/commit/53671a393326605650d3ae12959796a6c6976472)) +* update package.json files ([7823f1b](https://github.com/mongodb-js/zstd/commit/7823f1b3156f4eacd2c235ac660aa9810eee6f84)) +* update to idomatic rust ([16e215a](https://github.com/mongodb-js/zstd/commit/16e215a59817fdf94bb62c8620b49b6255bafda0)) + + +### Bug Fixes + +* handle status in error ([e29c0ed](https://github.com/mongodb-js/zstd/commit/e29c0ed3b1077987c28bc4daa11c5d6a01c650cf)) +* remove debug js ([c454785](https://github.com/mongodb-js/zstd/commit/c454785a6cbfe63ed21ca3942ce0707e0b399d3f)) +`; +} From 4972129c5e1a48d4f448324e597df9c2a8f91f25 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 4 Dec 2024 10:58:26 -0700 Subject: [PATCH 2/3] fix(NODE-6590): add build for x64 macos (#45) --- .github/workflows/build.yml | 4 +--- .github/workflows/test.yml | 2 +- .release-please-manifest.json | 2 +- binding.gyp | 13 +++++++++++++ etc/install-zstd.sh | 3 +-- package.json | 3 ++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3d038b..efbbfe7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,4 @@ on: - pull_request: - branches: [main] workflow_dispatch: {} workflow_call: {} @@ -10,7 +8,7 @@ jobs: host_tests: strategy: matrix: - os: [macos-latest, windows-2019] + os: [macos-latest, windows-2019, macos-13] fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4644bb..57413b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: host_tests: strategy: matrix: - os: [macos-latest, windows-2019] + os: [macos-latest, windows-2019, macos-13] node: [16.20.1, 18.x, 20.x, 22.x] fail-fast: false runs-on: ${{ matrix.os }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6e011e8..4a263fa 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { ".": "2.0.0-alpha.1" -} \ No newline at end of file +} diff --git a/binding.gyp b/binding.gyp index b076cb9..3da1b99 100644 --- a/binding.gyp +++ b/binding.gyp @@ -34,6 +34,19 @@ ] }, } + ], + ['OS=="mac"', { + 'xcode_settings': { + "OTHER_CFLAGS": [ + "-arch x86_64", + "-arch arm64" + ], + "OTHER_LDFLAGS": [ + "-arch x86_64", + "-arch arm64" + ] + } + } ] ], 'cflags!': [ '-fno-exceptions' ], diff --git a/etc/install-zstd.sh b/etc/install-zstd.sh index 62a129f..d9ba539 100644 --- a/etc/install-zstd.sh +++ b/etc/install-zstd.sh @@ -6,7 +6,6 @@ clean_deps() { } download_zstd() { - rm -rf deps mkdir -p deps/zstd ZSTD_VERSION=$(node -p "require('./package.json')['mongodb:zstd_version']") @@ -20,7 +19,7 @@ build_zstd() { # CMAKE_RC_FLAGS is a workaround for a bug in 1.5.6 that breaks compilation on windows. # The fix is merged but not yet released. see https://github.com/facebook/zstd/issues/3999 - cmake -DCMAKE_RC_FLAGS="$(pwd)/lib" -DZSTD_MULTITHREAD_SUPPORT=OFF -DZSTD_BUILD_SHARED=OFF . + cmake -DCMAKE_RC_FLAGS="$(pwd)/lib" -DZSTD_MULTITHREAD_SUPPORT=OFF -DZSTD_BUILD_SHARED=OFF -DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' . cmake --build . } diff --git a/package.json b/package.json index dc42fda..7bce18a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "node": ">= 16.20.1" }, "scripts": { - "install": "prebuild-install --runtime napi || node-gyp rebuild", + "install": "prebuild-install --runtime napi || npm run clean-install", + "clean-install": "npm run install-zstd && npm run compile", "compile": "node-gyp rebuild", "test": "mocha test/index.test.js", "install-zstd": "bash etc/install-zstd.sh", From ecc3e46f5f781466e2c0aee005109086703d7037 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:03:31 -0700 Subject: [PATCH 3/3] chore(main): release 2.0.0-alpha.2 (#49) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bailey Pearson --- .release-please-manifest.json | 2 +- HISTORY.md | 7 +++++++ package-lock.json | 6 +++--- package.json | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4a263fa..af4b15c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-alpha.1" + ".": "2.0.0-alpha.2" } diff --git a/HISTORY.md b/HISTORY.md index f79f067..29701a8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.0.0-alpha.2](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2024-12-04) + + +### Bug Fixes + +* **NODE-6590:** add build for x64 macos ([#45](https://github.com/mongodb-js/zstd/issues/45)) ([4972129](https://github.com/mongodb-js/zstd/commit/4972129c5e1a48d4f448324e597df9c2a8f91f25)) + ## [2.0.0-alpha.1](https://github.com/mongodb-js/zstd/compare/v2.0.0-alpha.0...v2.0.0-alpha.1) (2024-12-02) diff --git a/package-lock.json b/package-lock.json index a37aed5..2eb27ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.1", + "version": "2.0.0-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.1", + "version": "2.0.0-alpha.2", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -10045,4 +10045,4 @@ "dev": true } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 7bce18a..93156a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mongodb-js/zstd", - "version": "2.0.0-alpha.1", + "version": "2.0.0-alpha.2", "main": "lib/index.js", "types": "index.d.ts", "repository": "https://github.com/mongodb-js/zstd",