From a7bf1367794f66b1c170a6fb0d50b39badd5ec0f Mon Sep 17 00:00:00 2001 From: Zachary Holland Date: Mon, 22 Jan 2024 14:53:05 -0600 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20fixed=20error:=20=E2=80=98class=20v8?= =?UTF-8?q?::Object=E2=80=99=20has=20no=20member=20named=20'CreationContex?= =?UTF-8?q?t'=20(#44)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: fixed error: ‘class v8::Object’ has no member named ‘CreationContext’; allowing node-gyp to rebind with node-postal, which enables node-postal to be used on Node v20.5.0 * feat: add node v16 and v20 to github actions matrix * fix: updated workflow script to run on push and pull request events * fix: updated actions/checkout@v2 to v3 as the former was deprecated * test: trying to get the bindings file made/located correctly * fix: removed incorrect cd step * feat: added fail-fast so jobs will continue running after a node version test fails in the matrix * feat/test: set the context depending on the node version; node v16+ use new update, else use old way * fix/test: added node version header to expand.cc and parser.cc * test: changed node_version header to node header * fix: reverting back to state where node 16,18,20 tests worked... * fix/test: reverted github actions to v2 from v3... * test: attempt to get tests to pass for node v16+ * fix: re-added line in ParseAddress that had been incorrectly removed * fix: depending on node version call the right context function * fix: removed typo --- .github/workflows/push.yml | 7 +++++-- src/expand.cc | 9 +++++++-- src/parser.cc | 7 ++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c98b709..ffdb5ec 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,10 +1,11 @@ name: 'Continuous Integration' -on: push +on: [push, pull_request] jobs: unit-tests: runs-on: '${{ matrix.os }}' continue-on-error: ${{ matrix.status != 'current' }} strategy: + fail-fast: false matrix: status: ['current'] os: @@ -13,6 +14,8 @@ jobs: - 12.x - 14.x - 16.x + - 18.x + - 20.x include: - os: ubuntu-20.04 node-version: 8.x @@ -26,7 +29,7 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get install curl autoconf automake libtool pkg-config + sudo apt-get install build-essential curl autoconf automake libtool pkg-config - name: 'Create working directories' shell: bash run: | diff --git a/src/expand.cc b/src/expand.cc index d3cb950..5a56d7c 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -133,8 +133,13 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->CreationContext(); - + // Check Node.js version + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #else + v8::Local context = exports->CreationContext(); + #endif + if (!libpostal_setup() || !libpostal_setup_language_classifier()) { Nan::ThrowError("Could not load libpostal"); return; diff --git a/src/parser.cc b/src/parser.cc index 240d591..b93d26b 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -96,7 +96,12 @@ static void cleanup(void*) { } void init(v8::Local exports) { - v8::Local context = exports->CreationContext(); + // Check Node.js version + #if NODE_MAJOR_VERSION >= 16 + v8::Local context = exports->GetCreationContext().ToLocalChecked(); + #else + v8::Local context = exports->CreationContext(); + #endif if (!libpostal_setup() || !libpostal_setup_parser()) { Nan::ThrowError("Could not load libpostal"); From 8c83daf7298c54783dd0ebddad9f614ffff83bc8 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 28 Jan 2024 07:14:27 +0100 Subject: [PATCH 2/9] 1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93ecff6..bcbbc32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-postal", - "version": "1.1.1", + "version": "1.2.0", "author": "Al Barrentine (@thatdatabaseguy)", "description": "International address parsing/normalization at C speed", "main": "index.js", From a7d24408465b695de3be49ebef1bc42ea551cc5e Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Sat, 30 Nov 2024 09:17:49 -0800 Subject: [PATCH 3/9] feat(deps): Update NAN to v2.22 (#51) * feat(deps): Update NAN to v2.22 This is required for Node.js 22 support * CI: Add Node.js 22 to CI --- .github/workflows/push.yml | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ffdb5ec..9278a6d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -16,6 +16,7 @@ jobs: - 16.x - 18.x - 20.x + - 22.x include: - os: ubuntu-20.04 node-version: 8.x diff --git a/package.json b/package.json index bcbbc32..dcdcf45 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "dependencies": { "bindings": "^1.5.0", - "nan": "^2.14.0" + "nan": "^2.22.0" }, "devDependencies": { "mocha": "^7.1.1", From aa7f6c20c62029b5a11a92eb2f54f21bae8321aa Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 21 Jan 2025 11:55:16 +0100 Subject: [PATCH 4/9] CI: Node.js v23 (#53) * Test on Node.js v23 * Lose the arm * actions/checkout@v4 --- .github/workflows/push.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 9278a6d..6e1f887 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -9,7 +9,7 @@ jobs: matrix: status: ['current'] os: - - ubuntu-20.04 + - ubuntu-22.04 node-version: - 12.x - 14.x @@ -17,6 +17,7 @@ jobs: - 18.x - 20.x - 22.x + - 23.x include: - os: ubuntu-20.04 node-version: 8.x @@ -25,7 +26,7 @@ jobs: node-version: 10.x status: 'deprecated' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: 'Install apt packages' shell: bash run: | From 55b536b9d4b99733213c3f57fcad569e9d920279 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 21 Jan 2025 11:59:41 +0100 Subject: [PATCH 5/9] Add ubuntu-24.04-arm to the testing ```diff + - os: ubuntu-24.04-arm + node-version: 22.x + status: 'current' ``` --- .github/workflows/push.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 6e1f887..42d62d9 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -25,6 +25,9 @@ jobs: - os: ubuntu-20.04 node-version: 10.x status: 'deprecated' + - os: ubuntu-24.04-arm + node-version: 22.x + status: 'current' steps: - uses: actions/checkout@v4 - name: 'Install apt packages' From da73c7caa4966b4891539aea7f4f155b1c90b98a Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 22 Jan 2025 13:02:57 +0100 Subject: [PATCH 6/9] CI: Disable SSE2 on ARM runners --- .github/workflows/push.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 42d62d9..58db973 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -47,7 +47,9 @@ jobs: git clone https://github.com/openvenues/libpostal cd libpostal ./bootstrap.sh - ./configure --datadir=/data --prefix=/deps --bindir=/deps || cat config.log + CONFIGURE_FLAGS=(--datadir=/data --prefix=/deps --bindir=/deps) + if [[ $(uname -m) =~ ^(aarch64|arm64)?$ ]]; then CONFIGURE_FLAGS+=(--disable-sse2); fi + ./configure "${CONFIGURE_FLAGS[@]}" || cat config.log make -j4 make install - name: 'Install node.js ${{ matrix.node-version }}' From adc32843532e19f1fad1b98f3a59494bb189f10b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Jan 2025 13:46:45 +0100 Subject: [PATCH 7/9] Keep GitHub Actions up to date with GitHub's Dependabot * [Keeping your actions up to date with Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) * [Configuration options for the dependabot.yml file - package-ecosystem](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem) --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..be006de --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly From 830159491fb326463f8bd9e1964e825da9f528cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 14:57:18 +0100 Subject: [PATCH 8/9] Bump actions/setup-node from 2.pre.beta to 4.1.0 in the github-actions group (#56) * Bump actions/setup-node in the github-actions group Bumps the github-actions group with 1 update: [actions/setup-node](https://github.com/actions/setup-node). Updates `actions/setup-node` from 2.pre.beta to 4.1.0 - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2-beta...v4.1.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production dependency-group: github-actions ... Signed-off-by: dependabot[bot] * Update .github/workflows/push.yml Co-authored-by: Christian Clauss --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Peter Johnson Co-authored-by: Christian Clauss --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 58db973..f94ab18 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -53,7 +53,7 @@ jobs: make -j4 make install - name: 'Install node.js ${{ matrix.node-version }}' - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v4 with: node-version: '${{ matrix.node-version }}' - name: 'Install node-postal' From c2bd9522be03f4fe4d7928092bd79d19bd8a27a3 Mon Sep 17 00:00:00 2001 From: Aamir Date: Thu, 30 Jan 2025 08:35:02 +0400 Subject: [PATCH 9/9] Fixed runtime crash (#58) Instead of manually freeing the memory allocated by `libpostal_expand_address()`, use `libpostal_expansion_array_destroy()` to free the memory. This is how example program from libpostal frees the memory. For more details, please refer to this issue: https://github.com/openvenues/libpostal/issues/682 --- src/expand.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/expand.cc b/src/expand.cc index 5a56d7c..263d9c1 100644 --- a/src/expand.cc +++ b/src/expand.cc @@ -120,9 +120,10 @@ void ExpandAddress(const Nan::FunctionCallbackInfo& info) { for (i = 0; i < num_expansions; i++) { v8::Local e = Nan::New(expansions[i]).ToLocalChecked(); ret->Set(context, i, e); - free(expansions[i]); } - free(expansions); + + // Free expansions + libpostal_expansion_array_destroy(expansions, num_expansions); info.GetReturnValue().Set(ret); }