Skip to content

Commit

Permalink
Refactor: Separate Rust client into standalone npm package
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Awawdi <[email protected]>
  • Loading branch information
Muhammad-awawdi-amazon committed Jan 12, 2025
1 parent d31d3fa commit b808143
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/install-shared-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
description: "Specified target for rust toolchain, ex. x86_64-apple-darwin"
type: string
required: false
defalt: "x86_64-unknown-linux-gnu"
default: "x86_64-unknown-linux-gnu"
options:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
Expand Down
36 changes: 33 additions & 3 deletions .github/workflows/npm-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,37 @@ jobs:
# Get the matrix from the matrix.json file, without the object that has the IMAGE key
export "PLATFORM_MATRIX=$(jq 'map(select(.PACKAGE_MANAGERS != null and (.PACKAGE_MANAGERS | contains(["npm"]))))' < .github/json_matrices/build-matrix.json | jq -c .)"
echo "PLATFORM_MATRIX=${PLATFORM_MATRIX}" >> $GITHUB_OUTPUT
publish-rust-client:
needs: [start-self-hosted-runner, load-platform-matrix]
if: github.repository_owner == 'valkey-io'
name: Publish Rust client to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "true"

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "latest"
registry-url: "https://registry.npmjs.org"
scope: "${{ vars.NPM_SCOPE }}"
always-auth: true

- name: Publish Rust client
working-directory: ./node/rust-client
run: |
npm ci
npm run build
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

publish-binaries:
needs: [start-self-hosted-runner, load-platform-matrix]
needs: [start-self-hosted-runner, load-platform-matrix, publish-rust-client]
if: github.repository_owner == 'valkey-io'
name: Publish packages to NPM
runs-on: ${{ matrix.build.RUNNER }}
Expand Down Expand Up @@ -216,7 +244,7 @@ jobs:
publish-base-to-npm:
if: github.event_name != 'pull_request'
name: Publish the base NPM package
needs: publish-binaries
needs: [publish-binaries, publish-rust-client]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -378,7 +406,7 @@ jobs:
working-directory: ./utils/release-candidate-testing/node
run: |
npm install
npm install --no-save @valkey/valkey-glide@${{ env.NPM_TAG }}
npm install --no-save @valkey/valkey-glide@${{ env.NPM_TAG }} @valkey/glide-rs@${{ env.NPM_TAG }}
npm run test
- name: Deprecating packages on failure
Expand Down Expand Up @@ -417,6 +445,8 @@ jobs:
# Deprecating base package
npm deprecate "@valkey/valkey-glide@${RELEASE_VERSION}" "This version has been deprecated" --force || true
# Deprecating Rust client package
npm deprecate "@valkey/glide-rs@${RELEASE_VERSION}" "This version has been deprecated" --force || true
# Process platform matrix
echo "${PLATFORM_MATRIX}" > platform_matrix.json
Expand Down
4 changes: 2 additions & 2 deletions node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

export { ClusterScanCursor, Script } from "glide-rs";
export { ClusterScanCursor, Script } from "@valkey/glide-rs";
export * from "./src/BaseClient";
export * from "./src/Commands";
export * from "./src/Errors";
export * from "./src/GlideClient";
export * from "./src/GlideClusterClient";
export * from "./src/Logger";
export * from "./src/server-modules/GlideJson";
export * from "./src/server-modules/GlideFt";
export * from "./src/server-modules/GlideFtOptions";
export * from "./src/server-modules/GlideJson";
export * from "./src/Transaction";
14 changes: 4 additions & 10 deletions node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,15 @@
},
"homepage": "https://github.com/valkey-io/valkey-glide#readme",
"dependencies": {
"glide-rs": "file:rust-client",
"@valkey/glide-rs": "^0.1.0",
"long": "^5.2.3",
"npmignore": "^0.3.1",
"protobufjs": "^7.4.0"
},
"bundleDependencies": [
"glide-rs"
],
"scripts": {
"build": "npm run prereq && npm run build-internal && npm run build-protobuf && npm run build-external",
"build:release": "npm run build-internal:release && npm run build-protobuf && npm run build-external:release",
"build:benchmark": "npm run build-internal:benchmark && npm run build-protobuf && npm run build-external",
"build-internal": "cd rust-client && npm run build",
"build-internal:release": "cd rust-client && npm run build:release",
"build-internal:benchmark": "cd rust-client && npm run build:benchmark",
"build": "npm run prereq && npm run build-protobuf && npm run build-external",
"build:release": " npm run build-protobuf && npm run build-external:release",
"build:benchmark": " npm run build-protobuf && npm run build-external",
"build-external": "rm -rf build-ts && tsc",
"build-external:release": "rm -rf build-ts && tsc --stripInternal",
"build-protobuf": "npm run compile-protobuf-files && npm run fix-protobuf-file",
Expand Down
2 changes: 1 addition & 1 deletion node/rust-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "glide-rs",
"name": "@valkey/glide-rs",
"version": "0.1.0",
"description": "Valkey client",
"main": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion node/src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
StartSocketConnection,
getStatistics,
valueFromSplitPointer,
} from "glide-rs";
} from "@valkey/glide-rs";
import * as net from "net";
import { Buffer, BufferWriter, Long, Reader, Writer } from "protobufjs";
import {
Expand Down
2 changes: 1 addition & 1 deletion node/src/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

import { createLeakedStringVec, MAX_REQUEST_ARGS_LEN } from "glide-rs";
import { createLeakedStringVec, MAX_REQUEST_ARGS_LEN } from "@valkey/glide-rs";
import Long from "long";

import {
Expand Down
4 changes: 2 additions & 2 deletions node/src/GlideClusterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

import { ClusterScanCursor, Script } from "glide-rs";
import { ClusterScanCursor, Script } from "@valkey/glide-rs";
import * as net from "net";
import {
AdvancedBaseClientConfiguration,
Expand All @@ -17,14 +17,14 @@ import {
convertGlideRecordToRecord,
} from "./BaseClient";
import {
ClusterScanOptions,
FlushMode,
FunctionListOptions,
FunctionListResponse,
FunctionRestorePolicy,
FunctionStatsSingleResponse,
InfoOptions,
LolwutOptions,
ClusterScanOptions,
createClientGetName,
createClientId,
createConfigGet,
Expand Down
2 changes: 1 addition & 1 deletion node/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
*/

import { InitInternalLogger, Level, log } from "glide-rs";
import { InitInternalLogger, Level, log } from "@valkey/glide-rs";

const LEVEL = new Map<LevelOptions | undefined, Level | undefined>([
["error", Level.Error],
Expand Down

0 comments on commit b808143

Please sign in to comment.