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 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c98b709..f94ab18 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,18 +1,23 @@ 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: - - ubuntu-20.04 + - ubuntu-22.04 node-version: - 12.x - 14.x - 16.x + - 18.x + - 20.x + - 22.x + - 23.x include: - os: ubuntu-20.04 node-version: 8.x @@ -20,13 +25,16 @@ 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@v2 + - uses: actions/checkout@v4 - name: 'Install apt packages' 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: | @@ -39,11 +47,13 @@ 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 }}' - uses: actions/setup-node@v2-beta + uses: actions/setup-node@v4 with: node-version: '${{ matrix.node-version }}' - name: 'Install node-postal' diff --git a/package.json b/package.json index 93ecff6..dcdcf45 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", @@ -24,7 +24,7 @@ }, "dependencies": { "bindings": "^1.5.0", - "nan": "^2.14.0" + "nan": "^2.22.0" }, "devDependencies": { "mocha": "^7.1.1", diff --git a/src/expand.cc b/src/expand.cc index d3cb950..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); } @@ -133,8 +134,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");