Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node test for checking exported symbols #2835

Merged
merged 74 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
62abaea
Add node test for checking exported symbols
prateek-kumar-improving Dec 18, 2024
9bfb65d
Add package.json.tmpl file
prateek-kumar-improving Dec 18, 2024
be79255
Fix formatting
prateek-kumar-improving Dec 18, 2024
1df6ec1
formatting fixed
prateek-kumar-improving Dec 18, 2024
cb320e2
Formatting fixed
prateek-kumar-improving Dec 18, 2024
540180f
Fix formatting
prateek-kumar-improving Dec 18, 2024
c2cbf13
Formatting fixed
prateek-kumar-improving Dec 18, 2024
77c6c1c
Node: Change log updated
prateek-kumar-improving Dec 18, 2024
2d100ee
Node: Add npm install
prateek-kumar-improving Jan 14, 2025
7d9ae5a
Node: update changelog.md
prateek-kumar-improving Jan 14, 2025
d7c4254
Node: Add changelog.md
prateek-kumar-improving Jan 14, 2025
cd67e1c
Node: update workflow
prateek-kumar-improving Jan 14, 2025
def5619
Node: Update workflow
prateek-kumar-improving Jan 14, 2025
522fed8
Node: Update workflow
prateek-kumar-improving Jan 14, 2025
479f6a9
Merge branch 'main' into node-exports-check-new
prateek-kumar-improving Jan 14, 2025
59524ee
Merge branch 'main' into node-exports-check-new
prateek-kumar-improving Jan 22, 2025
5e04970
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
8c43948
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
5013e66
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
f35176c
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
ef4ca6e
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
6cdcddf
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
212e367
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
03f2023
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
35602e0
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
ebd30f4
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
a8f4a12
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
d8fc4b9
Node: npm/glide package json created
prateek-kumar-improving Jan 22, 2025
4d92a5d
Node: update workflow
prateek-kumar-improving Jan 24, 2025
a2bf0f1
Node: update workflow
prateek-kumar-improving Jan 24, 2025
8cbfbe9
Node: update workflow
prateek-kumar-improving Jan 24, 2025
23d4df3
Update DEVELOPER.md and README.md files
prateek-kumar-improving Jan 27, 2025
71a3939
Fix formatting
prateek-kumar-improving Jan 27, 2025
4c8ca4b
Fix formatting
prateek-kumar-improving Jan 27, 2025
ffb231e
package.json.tmpl file removed
prateek-kumar-improving Jan 27, 2025
42fa269
Updated env variables
prateek-kumar-improving Jan 27, 2025
481ec1d
Node update formatting
prateek-kumar-improving Jan 27, 2025
1365fb6
Node update formatting
prateek-kumar-improving Jan 27, 2025
242103e
Node update formatting
prateek-kumar-improving Jan 27, 2025
5828ee9
Node update formatting
prateek-kumar-improving Jan 27, 2025
297db5b
Node: index.ts updated
prateek-kumar-improving Jan 29, 2025
390e9ad
Node: index.ts updated
prateek-kumar-improving Jan 29, 2025
caca266
Node: Review comments updated
prateek-kumar-improving Jan 29, 2025
1242f69
Node: fix test case
prateek-kumar-improving Jan 29, 2025
8fe390e
Node: fix formatting
prateek-kumar-improving Jan 29, 2025
0f07070
Node: Fix formatting
prateek-kumar-improving Jan 29, 2025
f5545d2
Merge branch 'main' into node-exports-check-new
prateek-kumar-improving Jan 29, 2025
e50b16e
Merge branch 'main' into node-exports-check-new
prateek-kumar-improving Jan 31, 2025
0e4975c
Node: review comments fixed
prateek-kumar-improving Feb 3, 2025
000a286
Node: fix index.ts
prateek-kumar-improving Feb 5, 2025
fe3a173
Node: fix index.ts
prateek-kumar-improving Feb 5, 2025
8d4a23b
Node: Update workflow
prateek-kumar-improving Feb 5, 2025
f4da746
Node: Update workflow
prateek-kumar-improving Feb 5, 2025
beacc6a
Node: Update workflow
prateek-kumar-improving Feb 5, 2025
f94f0bd
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
dcd8e81
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
839e3c4
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
85d1d00
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
c91d64c
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
0a992e2
Node: Update action.yml
prateek-kumar-improving Feb 5, 2025
5bd6329
Node: action.yml updated
prateek-kumar-improving Feb 5, 2025
17ffca4
Node: action.yml updated
prateek-kumar-improving Feb 5, 2025
9a6edb1
Node: action.yml updated
prateek-kumar-improving Feb 5, 2025
1d55e3e
Node: Fix formatting
prateek-kumar-improving Feb 5, 2025
56f70cc
Node: update package.json
prateek-kumar-improving Feb 5, 2025
c709df7
Node: update package.json
prateek-kumar-improving Feb 5, 2025
6a4a30c
Node: update package.json
prateek-kumar-improving Feb 5, 2025
e6b0e72
Node: update action.yml
prateek-kumar-improving Feb 5, 2025
ab2e8f9
Node: update action.yml
prateek-kumar-improving Feb 5, 2025
bb5bfa6
Node: update action.yml
prateek-kumar-improving Feb 5, 2025
03e6389
Node: remove temp file
prateek-kumar-improving Feb 6, 2025
e2411ab
Node: fix review comments
prateek-kumar-improving Feb 6, 2025
a02748e
Node: add constant variables
prateek-kumar-improving Feb 6, 2025
ed54b7b
Node: fixed formatting
prateek-kumar-improving Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build-node-wrapper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ runs:
rm -rf node_modules && rm -rf package-lock.json && npm install
cd rust-client
rm -rf node_modules && rm -rf package-lock.json && npm install

- name: npm install for /npm/glide package
shell: bash
working-directory: ./node/npm/glide
run: |
rm -rf node_modules && rm -rf package-lock.json && npm install
npm ls jest-haste-map
prateek-kumar-improving marked this conversation as resolved.
Show resolved Hide resolved
- name: Build
shell: bash
working-directory: ./node
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/node-create-package-file/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,27 @@ runs:
envsubst < package.json.tmpl > "package.json"
cat package.json
echo $(ls *json*)
- name: Create package.json file in npm/glide package
shell: bash
working-directory: ./node/npm/glide
run: |
name="valkey-glide"
export node_os="${{ inputs.named_os }}"
export node_arch="${{ inputs.arch }}"
echo "The workflow is: ${{env.EVENT_NAME}}"
if ${{ env.EVENT_NAME == 'workflow_dispatch' }}; then
R_VERSION="${{ env.INPUT_VERSION }}"
else
R_VERSION=${GITHUB_REF:11}
fi
echo "RELEASE_VERSION=${R_VERSION}" >> $GITHUB_ENV
export package_version=${R_VERSION}
export scope=`if [ "${{ inputs.npm_scope }}" != '' ]; then echo "${{ inputs.npm_scope }}/"; fi`
export MUSL_FLAG=`if [[ "${{ inputs.target }}" =~ .*"musl".* ]]; then echo "-musl"; fi`
export pkg_name="${name}-${node_os}${MUSL_FLAG}-${node_arch}"
export dev_dependency_name="${scope}${pkg_name}"
# Create package.json and append devDependency
mv package.json package.json.tmpl
envsubst < package.json.tmpl > "package.json"
jq --arg dev_dependency_name "$dev_dependency_name" --arg path "../.." '.devDependencies += {($dev_dependency_name): $path}' package.json > package.tmpl.json && mv package.tmpl.json package.json
cat package.json
44 changes: 22 additions & 22 deletions node/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ Software Dependencies

If your Nodejs version is below the supported version specified in the client's [documentation](https://github.com/valkey-io/valkey-glide/blob/main/node/README.md#nodejs-supported-version), you can upgrade it using [NVM](https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script).

- npm
- git
- GCC
- pkg-config
- protoc (protobuf compiler)
- openssl
- openssl-dev
- rustup
- npm
prateek-kumar-improving marked this conversation as resolved.
Show resolved Hide resolved
- git
- GCC
- pkg-config
- protoc (protobuf compiler)
- openssl
- openssl-dev
- rustup

**Dependencies installation for Ubuntu**

Expand Down Expand Up @@ -107,16 +107,16 @@ Before starting this step, make sure you've installed all software requirments.
5. Integrating the built GLIDE package into your project:
Add the package to your project using the folder path with the command `npm install <path to GLIDE>/node`.

- For a fast build, execute `npm run build`. This will perform a full, unoptimized build, which is suitable for developing tests. Keep in mind that performance is significantly affected in an unoptimized build, so it's required to build with the `build:release` or `build:benchmark` option when measuring performance.
- If your modifications are limited to the TypeScript code, run `npm run build-external` to build the external package without rebuilding the internal package.
- If your modifications are limited to the Rust code, execute `npm run build-internal` to build the internal package and generate TypeScript code.
- To generate Node's protobuf files, execute `npm run build-protobuf`. Keep in mind that protobuf files are generated as part of full builds (e.g., `build`, `build:release`, etc.).
- For a fast build, execute `npm run build`. This will perform a full, unoptimized build, which is suitable for developing tests. Keep in mind that performance is significantly affected in an unoptimized build, so it's required to build with the `build:release` or `build:benchmark` option when measuring performance.
- If your modifications are limited to the TypeScript code, run `npm run build-external` to build the external package without rebuilding the internal package.
- If your modifications are limited to the Rust code, execute `npm run build-internal` to build the internal package and generate TypeScript code.
- To generate Node's protobuf files, execute `npm run build-protobuf`. Keep in mind that protobuf files are generated as part of full builds (e.g., `build`, `build:release`, etc.).

> Note: Once building completed, you'll find the compiled JavaScript code in the `node/build-ts` folder.

### Troubleshooting

- If the build fails after running `npx tsc` because `glide-rs` isn't found, check if your npm version is in the range 9.0.0-9.4.1, and if so, upgrade it. 9.4.2 contains a fix to a change introduced in 9.0.0 that is required in order to build the library.
- If the build fails after running `npx tsc` because `glide-rs` isn't found, check if your npm version is in the range 9.0.0-9.4.1, and if so, upgrade it. 9.4.2 contains a fix to a change introduced in 9.0.0 that is required in order to build the library.

### Test

Expand Down Expand Up @@ -202,13 +202,13 @@ Development on the Node wrapper may involve changes in either the TypeScript or

**TypeScript:**

- ESLint
- Prettier
- ESLint
- Prettier

**Rust:**

- clippy
- fmt
- clippy
- fmt

#### Running the linters

Expand All @@ -231,8 +231,8 @@ Development on the Node wrapper may involve changes in either the TypeScript or

### Recommended extensions for VS Code

- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - JavaScript / TypeScript formatter.
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - linter.
- [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) - in-editor test runner.
- [Jest Test Explorer](https://marketplace.visualstudio.com/items?itemName=kavod-io.vscode-jest-test-adapter) - adapter to the VSCode testing UI.
- [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) - Rust language support for VSCode.
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - JavaScript / TypeScript formatter.
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - linter.
- [Jest Runner](https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner) - in-editor test runner.
- [Jest Test Explorer](https://marketplace.visualstudio.com/items?itemName=kavod-io.vscode-jest-test-adapter) - adapter to the VSCode testing UI.
- [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) - Rust language support for VSCode.
8 changes: 4 additions & 4 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ The release of Valkey GLIDE was tested on the following platforms:

Linux:

- Ubuntu 22.04.1 (x86_64 and aarch64)
- Amazon Linux 2023 (AL2023) (x86_64)
- Ubuntu 22.04.1 (x86_64 and aarch64)
- Amazon Linux 2023 (AL2023) (x86_64)

macOS:

- macOS 14.7 (Apple silicon/aarch_64)
- macOS 14.7 (Apple silicon/aarch_64)

Alpine:

- node:alpine (default on aarch64 and x86_64)
- node:alpine (default on aarch64 and x86_64)

## NodeJS supported version

Expand Down
70 changes: 18 additions & 52 deletions node/npm/glide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,37 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

import { GLIBC, MUSL, familySync } from "detect-libc";
import { GLIBC, familySync } from "detect-libc";
import { arch, platform } from "process";

let globalObject = global as unknown;

/* eslint-disable @typescript-eslint/no-require-imports */
function loadNativeBinding() {
let nativeBinding = null;
let nativeStr = process.env.native_binding;

switch (platform) {
case "linux":
switch (arch) {
case "x64":
switch (familySync()) {
case GLIBC:
nativeBinding = require("@scope/valkey-glide-linux-x64");
break;
case MUSL:
nativeBinding = require("@scope/valkey-glide-linux-musl-x64");
break;
default:
nativeBinding = require("@scope/valkey-glide-linux-x64");
break;
}
if (nativeStr == undefined) {
const prefix = familySync() == GLIBC ? "" : "-musl";
nativeStr = `${platform}${prefix}-${arch}`;

break;
case "arm64":
switch (familySync()) {
case GLIBC:
nativeBinding = require("@scope/valkey-glide-linux-arm64");
break;
case MUSL:
nativeBinding = require("@scope/valkey-glide-linux-musl-arm64");
break;
default:
nativeBinding = require("@scope/valkey-glide-linux-arm64");
break;
}

break;
default:
throw new Error(
`Unsupported OS: ${platform}, architecture: ${arch}`,
);
}

break;
case "darwin":
switch (arch) {
case "arm64":
nativeBinding = require("@scope/valkey-glide-darwin-arm64");
break;
default:
throw new Error(
`Unsupported OS: ${platform}, architecture: ${arch}`,
);
}

break;
default:
if (
!["x64", "arm64"].includes(arch) ||
!["linux", "darwin"].includes(platform)
) {
throw new Error(
`Unsupported OS: ${platform}, architecture: ${arch}`,
);
}
}

let scope = process.env.scope || "@scope";

if (scope == "@scope") {
scope = "@valkey/";
}
Yury-Fridlyand marked this conversation as resolved.
Show resolved Hide resolved

const nativeBinding = require(`${scope}valkey-glide-${nativeStr}`);

if (!nativeBinding) {
throw new Error(`Failed to load native binding`);
}
Expand Down
32 changes: 32 additions & 0 deletions node/npm/glide/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint no-undef: off */
module.exports = {
preset: "ts-jest",
transform: {
"^.+\\.(t|j)s$": ["ts-jest", { isolatedModules: true }],
},
testEnvironment: "node",
testRegex: "/tests/.*\\.(test|spec)?\\.(ts|tsx)$",
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
"node",
"cjs",
"mjs",
],
testTimeout: 600000,
reporters: [
"default",
[
"./node_modules/jest-html-reporter",
{
includeFailureMsg: true,
includeSuiteFailure: true,
executionTimeWarningThreshold: 60,
sort: "status",
},
],
],
};
7 changes: 6 additions & 1 deletion node/npm/glide/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "${scope}${pkg_name}",
"name": "valkey-glide",
"types": "build-ts/index.d.ts",
"version": "${package_version}",
"description": "General Language Independent Driver for the Enterprise (GLIDE) for Valkey",
Expand Down Expand Up @@ -33,6 +33,11 @@
},
"homepage": "https://github.com/valkey-io/valkey-glide#readme",
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.14",
"ts-jest": "^29.2.5",
"jest": "^29.7.0",
"jest-html-reporter": "^3.10.2",
"@types/node": "^18.11.18",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
Expand Down
Loading
Loading