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 nodejs v22 and v23 to build matrix #89

Merged
merged 28 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
851e9fb
add nodejs v22 and v23 to build matrix
rentallect Jan 7, 2025
9448af2
try 'macos-13'
rentallect Jan 7, 2025
22f32ed
Update c-sdk to latest commit
rentallect Jan 8, 2025
d6ae1e6
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
1d1fddb
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
ae336e7
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
3d66f7d
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
0e32ecc
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
0360dd1
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
eb152a9
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
e9d3dbf
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
dfb20a0
adjust for latest c-sdk code changes
rentallect Jan 8, 2025
62ac851
build macOS-arm on macos-14, macOS-x64 on macos-13
ekoby Jan 9, 2025
c0837de
build macOS-arm on macos-14, macOS-x64 on macos-13
ekoby Jan 9, 2025
25a73b1
build macOS-arm on macos-14, macOS-x64 on macos-13
ekoby Jan 9, 2025
961732e
debug build failure
ekoby Jan 9, 2025
78af6e7
debug build failure
ekoby Jan 9, 2025
b010e69
debug build failure
ekoby Jan 9, 2025
5ea0d47
use macOS-13, cache deps for speeding up the build
ekoby Jan 9, 2025
93fafc4
macos: install libtool
ekoby Jan 9, 2025
2d7a26f
fix function signature
ekoby Jan 9, 2025
6d9941e
fix function signatures
ekoby Jan 9, 2025
2d304ff
remove ziti-sdk submodule
ekoby Jan 9, 2025
58f86e6
re-enable node versions
ekoby Jan 9, 2025
6e6bbff
copy toolchains
ekoby Jan 9, 2025
04ddf24
drop support for eol-ed node versions [16, 19]
ekoby Jan 9, 2025
5c45075
build changes
ekoby Jan 10, 2025
e47e6ff
always save/update dep cache
ekoby Jan 9, 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
67 changes: 49 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
- { os: windows-latest, target: "windows", arch: "x64" }
- { os: ubuntu-20.04, target: "linux", arch: "x64" }
- { os: ubuntu-20.04, target: "linux", arch: "arm64" }
- { os: macos-latest, target: "macos", arch: "x64" }
- { os: macos-latest, target: "macos", arch: "arm64" }
node_ver: [ 16, 18, 19, 20, 21]
- { os: macos-13, target: "macos", arch: "x64" }
- { os: macos-14, target: "macos", arch: "arm64" }
node_ver: [ 18, 20, 21, 22, 23 ]
fail-fast: false

steps:
Expand All @@ -57,6 +57,11 @@ jobs:
submodules: 'recursive'
# token: ${{ secrets.ZITI_CI_GH_TOKEN }}

- name: macOS tools
if: runner.os == 'macOS'
shell: bash
run: brew install autoconf autoconf-archive automake pkg-config libtool

- name: Setup PkgConfig (Windows)
if: matrix.config.target == 'windows'
run: |
Expand Down Expand Up @@ -88,30 +93,34 @@ jobs:
run: echo "date=$(date)" >> $GITHUB_OUTPUT

- name: Install CMake/Ninja
uses: lukka/get-cmake@v3.27.6
uses: lukka/get-cmake@v3.30.1

- name: Run VCPKG
uses: lukka/run-vcpkg@v10
uses: lukka/run-vcpkg@v11
# will use baseline from vcpkg.json
with:
vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00'
# get baseline from vcpkg
vcpkgJsonGlob: './vcpkg.json'

- name: gcc version
- name: show versions
run: |
echo ===== gcc =====
gcc --version
- name: cmake version
run: |
echo ===== cmake =====
cmake --version
- name: ninja version
run: |
ninja --version
- name: node version
run: |
node --version
- name: npm version
run: |
npm --version
echo "ninja: $(ninja --version)"
echo "node: $(node --version)"
echo "npm: $(npm --version)"

- name: restore dependencies cache
uses: actions/cache/restore@v4
id: cache-restore
with:
key: deps-${{ matrix.config.target }}-${{ matrix.config.arch }}-${{ hashFiles('./vcpkg.json') }}
path: './vcpkg/packages'

- name: Build NodeJS-SDK
id: buildSDK
run: |
cd ${{ runner.workspace }}/${{ github.event.repository.name }}
npm install
Expand All @@ -121,11 +130,33 @@ jobs:
TARGET_ARCH: ${{ matrix.config.arch }}
BUILD_DATE: ${{ steps.date.outputs.date }}

- name: show build result
if: always()
run: echo build result ${{ steps.buildSDK.outcome }}

- name: debug build failure
if: always() && steps.buildSDK.outcome == 'failure'
uses: actions/upload-artifact@v3
with:
name: build-logs-${{ matrix.config.target }}-${{ matrix.config.arch }}
path: |
./vcpkg/buildtrees/**/*.log
./build/**/*log

- name: Hello test
if: matrix.config.arch == 'x64'
run: |
node tests/hello.js

- name: save dependencies cache
uses: actions/cache/save@v4
id: cache-save
# save deps even build has failed
if: always()
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: './vcpkg/packages'

- name: upload artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "deps/ziti-sdk-c"]
path = deps/ziti-sdk-c
url = https://github.com/openziti/ziti-sdk-c
branch = main
20 changes: 8 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,20 @@ endif (WIN32)
file(GLOB SOURCE_FILES ./src/*.c ./src/.cpp)

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
SUFFIX ".node"
C_STANDARD 11
POSITION_INDEPENDENT_CODE ON
)

target_include_directories(${PROJECT_NAME}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include
PRIVATE ${CMAKE_JS_INC}
)

if (WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN)

#
# nodejs contains all needed libuv stuff
# trick TLSUV to link against it
add_library(libuv::uv SHARED IMPORTED)
set_target_properties(libuv::uv PROPERTIES
IMPORTED_LOCATION ${CMAKE_JS_LIB}
IMPORTED_IMPLIB ${CMAKE_JS_LIB}
)
set(TLSUV_LIBUV_LIB libuv::uv)
endif (WIN32)


Expand All @@ -49,7 +45,7 @@ if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/ziti-sdk-c)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps)

target_link_libraries(${PROJECT_NAME} PRIVATE ziti ${CMAKE_JS_LIB})
if (WIN32)
Expand Down
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"cacheVariables": {
"VCPKG_TARGET_ARCHITECTURE": "arm64",
"VCPKG_TARGET_TRIPLET": "arm64-osx",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/deps/ziti-sdk-c/toolchains/macOS-arm64.cmake"
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/toolchains/macOS-arm64.cmake"
}
},
{
Expand All @@ -66,15 +66,15 @@
"inherits": "ci-linux-x64",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-linux",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/deps/ziti-sdk-c/toolchains/Linux-arm64.cmake"
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/toolchains/Linux-arm64.cmake"
}
},
{
"name": "ci-linux-arm",
"inherits": "ci-linux-x64",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm-linux",
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/deps/ziti-sdk-c/toolchains/Linux-arm.cmake"
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/toolchains/Linux-arm.cmake"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ The `@openziti/ziti-sdk-nodejs` module works with the following Node.js versions
- v19.x
- v20.x
- v21.x
- v22.x
- v23.x

The `@openziti/ziti-sdk-nodejs` module works with the following architectures:
- amd64
Expand Down
28 changes: 28 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include(FetchContent)

if (WIN32)
# nodejs contains all needed libuv stuff
# trick TLSUV to link against it
add_library(libuv::uv SHARED IMPORTED)
set_target_properties(libuv::uv PROPERTIES
IMPORTED_LOCATION ${CMAKE_JS_LIB}
IMPORTED_IMPLIB ${CMAKE_JS_LIB}
)
set(TLSUV_LIBUV_LIB libuv::uv)

# make sure on WIN32 tlsuv uses our definition for libuv
FetchContent_Declare(tlsuv
GIT_REPOSITORY https://github.com/openziti/tlsuv.git
GIT_TAG v0.33.1
PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/tlsuv-libuv.patch
)
FetchContent_MakeAvailable(tlsuv)
endif (WIN32)

FetchContent_Declare(ziti
GIT_REPOSITORY https://github.com/openziti/ziti-sdk-c.git
GIT_TAG 1.3.5
)
FetchContent_MakeAvailable(ziti)


43 changes: 43 additions & 0 deletions deps/tlsuv-libuv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8a0c2f..a07ee13 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,21 +84,25 @@ endif()
include(FindPkgConfig)
find_package(PkgConfig)

-find_package(libuv CONFIG QUIET)
-if (libuv_FOUND)
- # newer libuv versions (via VCPKG) have proper namespacing
- if (TARGET libuv::uv_a)
- set(TLSUV_LIBUV_LIB libuv::uv_a)
- elseif (TARGET uv_a)
- set(TLSUV_LIBUV_LIB uv_a)
- elseif (TARGET libuv::uv)
- set(TLSUV_LIBUV_LIB libuv::uv)
+if (TARGET libuv::uv)
+ set(TLSUV_LIBUV_LIB libuv::uv)
+else ()
+ find_package(libuv CONFIG QUIET)
+ if (libuv_FOUND)
+ # newer libuv versions (via VCPKG) have proper namespacing
+ if (TARGET libuv::uv_a)
+ set(TLSUV_LIBUV_LIB libuv::uv_a)
+ elseif (TARGET uv_a)
+ set(TLSUV_LIBUV_LIB uv_a)
+ elseif (TARGET libuv::uv)
+ set(TLSUV_LIBUV_LIB libuv::uv)
+ else()
+ set(TLSUV_LIBUV_LIB uv)
+ endif()
else()
- set(TLSUV_LIBUV_LIB uv)
+ pkg_check_modules(libuv REQUIRED IMPORTED_TARGET libuv)
+ set(TLSUV_LIBUV_LIB PkgConfig::libuv)
endif()
-else()
- pkg_check_modules(libuv REQUIRED IMPORTED_TARGET libuv)
- set(TLSUV_LIBUV_LIB PkgConfig::libuv)
endif()

add_library(tlsuv STATIC
1 change: 0 additions & 1 deletion deps/ziti-sdk-c
Submodule ziti-sdk-c deleted from d33672
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "@openziti/ziti-sdk-nodejs",
"description": "A NodeJS-based SDK for delivering secure applications over a Ziti Network",
"version": "0.17.0",
"version": "0.18.0",
"main": "./lib/ziti",
"scripts": {
"build": "npm run build:init && npm run build:configure && npm run build:make",
"build:init": "git submodule update --init --recursive",
"build": "npm run build:configure && npm run build:make",
"build:configure": "run-script-os",
"build:configure:windows": "configure",
"build:configure:linux:darwin": "./configure",
Expand Down
8 changes: 4 additions & 4 deletions src/Ziti_https_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct ListMap* newListMap() {

uv_mutex_t client_pool_lock;

bool listMapInsert(struct ListMap* collection, char* key, void* value) {
bool listMapInsert(struct ListMap* collection, const char* key, void* value) {

if (collection->count == listMapCapacity) {
ZITI_NODEJS_LOG(ERROR, "collection->count already at capacity [%d], insert FAIL", listMapCapacity);
Expand Down Expand Up @@ -214,7 +214,7 @@ static void allocate_client(uv_work_t* req) {
}


struct hostname_port* getHostnamePortForService(char* key) {
struct hostname_port* getHostnamePortForService(const char* key) {

ZITI_NODEJS_LOG(DEBUG, "getHostnamePortForService() entered, key: %s", key);

Expand All @@ -239,7 +239,7 @@ struct hostname_port* getHostnamePortForService(char* key) {
/**
*
*/
void track_service_to_hostname(char* service_name, char* hostname, int port) {
void track_service_to_hostname(const char* service_name, char* hostname, int port) {

ZITI_NODEJS_LOG(DEBUG, "track_service_to_hostname() entered, service_name: %s hostname: %s port: %d", service_name, hostname, port);

Expand Down Expand Up @@ -360,7 +360,7 @@ static void CallJs_on_resp_body(napi_env env, napi_value js_cb, void* context, v
/**
*
*/
void on_resp_body(tlsuv_http_req_t *req, const char *body, ssize_t len) {
void on_resp_body(tlsuv_http_req_t *req, char *body, ssize_t len) {

// ZITI_NODEJS_LOG(DEBUG, "len: %zd, body is: \n>>>>>%s<<<<<", len, body);
ZITI_NODEJS_LOG(DEBUG, "body: %p", body);
Expand Down
2 changes: 1 addition & 1 deletion src/Ziti_https_request_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void CallJs_on_req_body(napi_env env, napi_value js_cb, void* context, vo
/**
*
*/
void on_req_body(tlsuv_http_req_t *req, const char *body, ssize_t status) {
void on_req_body(tlsuv_http_req_t *req, char *body, ssize_t status) {

ZITI_NODEJS_LOG(DEBUG, "status: %zd, body: %p", status, body);

Expand Down
6 changes: 3 additions & 3 deletions src/build_config.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define ZITI_VERSION @ZITI_VERSION@
#define ZITI_COMMIT @ZITI_COMMIT@
#define ZITI_BRANCH @ZITI_BRANCH@
#define ZITI_NODEJS_VERSION @ZITI_VERSION@
#define ZITI_NODEJS_COMMIT @ZITI_COMMIT@
#define ZITI_NODEJS_BRANCH @ZITI_BRANCH@
#define ZITI_OS @CMAKE_SYSTEM_NAME@
#define ZITI_ARCH @CMAKE_SYSTEM_PROCESSOR@
#define BUILD_DATE @BUILD_DATE@
6 changes: 3 additions & 3 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ limitations under the License.

const char* ziti_nodejs_get_version(int verbose) {
if (verbose) {
return "\n\tVersion:\t" to_str(ZITI_VERSION)
return "\n\tVersion:\t" to_str(ZITI_NODEJS_VERSION)
"\n\tBuild Date:\t" to_str(BUILD_DATE)
"\n\tGit Branch:\t" to_str(ZITI_BRANCH)
"\n\tGit SHA:\t" to_str(ZITI_COMMIT)
"\n\tGit Branch:\t" to_str(ZITI_NODEJS_BRANCH)
"\n\tGit SHA:\t" to_str(ZITI_NODEJS_COMMIT)
"\n\tOS: \t" to_str(ZITI_OS)
"\n\tArch: \t" to_str(ZITI_ARCH)
"\n\t";
Expand Down
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern FILE *ziti_nodejs_debug_out;

// TEMP: skip logging on windows
#ifdef WIN32
#define ZITI_NODEJS_LOG
#define ZITI_NODEJS_LOG(...)
#else
#define ZITI_NODEJS_LOG(level, fmt, ...) do { \
if (level <= ziti_nodejs_debug_level) {\
Expand Down
2 changes: 1 addition & 1 deletion src/ziti-nodejs.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ extern void expose_ziti_websocket_write(napi_env env, napi_value exports);
//
extern int tlsuv_websocket_init_with_src (uv_loop_t *loop, tlsuv_websocket_t *ws, tlsuv_src_t *src);

extern void track_service_to_hostname(char* service_name, char* hostname, int port);
extern void track_service_to_hostname(const char* service_name, char* hostname, int port);

#ifdef __cplusplus
}
Expand Down
Loading
Loading