Skip to content

Commit 3ea1ac1

Browse files
committed
Trying to make all the shell scripts resilient to errors. No more PRs without passing all tests...
1 parent 5436dc5 commit 3ea1ac1

File tree

15 files changed

+329
-79
lines changed

15 files changed

+329
-79
lines changed

.github/workflows/docker-hub.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ jobs:
2828
run: docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" -p "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"
2929

3030
- name: Pull MetaCall Docker Images
31-
run: sh ./docker-compose.sh pull
31+
run: bash ./docker-compose.sh pull
3232

3333
- name: Build MetaCall Docker Images
34-
run: sh ./docker-compose.sh build
34+
run: bash ./docker-compose.sh build
3535

3636
- name: Push MetaCall Docker Image to DockerHub
3737
run: |
3838
if [[ "${{ github.ref == 'refs/heads/master' }}" = true ]]; then
39-
sh ./docker-compose.sh push
39+
bash ./docker-compose.sh push
4040
elif [[ "${{ contains(github.ref, 'refs/tags/') }}" = true ]]; then
41-
sh ./docker-compose.sh version
41+
bash ./docker-compose.sh version
4242
else
4343
echo "Failed to push the docker images"
4444
exit 1

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
with:
2626
fetch-depth: 0
2727
- name: Pull the Docker images
28-
run: sh ./docker-compose.sh pull
28+
run: bash ./docker-compose.sh pull
2929
- name: Build the Docker images
30-
run: sh ./docker-compose.sh build
30+
run: bash ./docker-compose.sh build
3131
- name: Extract built artifacts
32-
run: sh ./docker-compose.sh pack
32+
run: bash ./docker-compose.sh pack
3333
- name: Upload built artifacts
3434
uses: actions/upload-artifact@v3
3535
with:

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up the environment
4848
run: sudo ./tools/metacall-environment.sh ${METACALL_INSTALL_OPTIONS}
4949
env:
50-
METACALL_INSTALL_OPTIONS: root base python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust rapidjson funchook swig pack backtrace
50+
METACALL_INSTALL_OPTIONS: base python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust rapidjson funchook swig pack backtrace
5151

5252
- name: Configure
5353
run: |
@@ -64,7 +64,7 @@ jobs:
6464
env:
6565
NODE_PATH: /usr/lib/node_modules
6666
METACALL_BUILD_TYPE: ${{ matrix.buildtype }}
67-
METACALL_BUILD_OPTIONS: root python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack benchmarks
67+
METACALL_BUILD_OPTIONS: python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack benchmarks
6868

6969
- name: Build
7070
run: |
@@ -80,7 +80,7 @@ jobs:
8080
env:
8181
NODE_PATH: /usr/lib/node_modules
8282
METACALL_BUILD_TYPE: ${{ matrix.buildtype }}
83-
METACALL_BUILD_OPTIONS: root python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack benchmarks
83+
METACALL_BUILD_OPTIONS: python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack benchmarks
8484

8585
windows-test:
8686
name: Windows MSVC Test
@@ -110,7 +110,7 @@ jobs:
110110
cmd.exe /c "powershell ..\tools\metacall-configure.ps1 $Env:METACALL_BUILD_TYPE $Env:METACALL_BUILD_OPTIONS"
111111
env:
112112
METACALL_BUILD_TYPE: debug
113-
METACALL_BUILD_OPTIONS: python nodejs tests scripts ports # ruby # root netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # sanitizer v8 coverage
113+
METACALL_BUILD_OPTIONS: python nodejs tests scripts ports # ruby # netcore5 typescript file rpc wasm java c cobol rust examples dynamic install pack benchmarks # sanitizer v8 coverage
114114

115115
- name: Build the core
116116
working-directory: ./build

docker-compose.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
#
44
# MetaCall Build Bash Script by Parra Studios
@@ -19,6 +19,8 @@
1919
# limitations under the License.
2020
#
2121

22+
set -euxo pipefail
23+
2224
# Enable BuildKit whenever possible
2325
export COMPOSE_DOCKER_CLI_BUILD=1
2426
export DOCKER_BUILDKIT=1

docker-compose.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ services:
2424
image: metacall/core:deps
2525
build:
2626
args:
27-
METACALL_INSTALL_OPTIONS: root base python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust rapidjson funchook swig pack backtrace # clangformat v8rep51 coverage
27+
METACALL_INSTALL_OPTIONS: base python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust rapidjson funchook swig pack backtrace # clangformat v8rep51 coverage
2828
dev:
2929
image: metacall/core:dev
3030
build:
3131
args:
3232
METACALL_BUILD_TYPE: debug
33-
METACALL_BUILD_OPTIONS: root python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack ${METACALL_BUILD_SANITIZER} benchmarks # v8 coverage
33+
METACALL_BUILD_OPTIONS: python ruby netcore5 nodejs typescript file rpc wasm java c cobol rust examples tests scripts ports dynamic install pack ${METACALL_BUILD_SANITIZER} benchmarks # v8 coverage

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
METACALL_BASE_IMAGE: $METACALL_BASE_IMAGE
3131
METACALL_PATH: $METACALL_PATH
3232
METACALL_TOOLS_PATH: $METACALL_PATH/tools
33-
METACALL_INSTALL_OPTIONS: root base python ruby nodejs typescript file rpc rapidjson funchook swig pack backtrace # clangformat v8rep51 coverage
33+
METACALL_INSTALL_OPTIONS: base python ruby nodejs typescript file rpc rapidjson funchook swig pack backtrace # clangformat v8rep51 coverage
3434
environment:
3535
DEBIAN_FRONTEND: noninteractive
3636
# Work around https://github.com/dotnet/cli/issues/1582 until Docker releases a
@@ -52,7 +52,7 @@ services:
5252
args:
5353
METACALL_PATH: $METACALL_PATH
5454
METACALL_BUILD_TYPE: $METACALL_BUILD_TYPE
55-
METACALL_BUILD_OPTIONS: root python ruby nodejs typescript file rpc examples tests scripts ports dynamic install pack # v8 coverage benchmarks
55+
METACALL_BUILD_OPTIONS: python ruby nodejs typescript file rpc examples tests scripts ports dynamic install pack # v8 coverage benchmarks
5656
environment:
5757
DEBIAN_FRONTEND: noninteractive
5858
LTTNG_UST_REGISTER_TIMEOUT: 0
@@ -77,7 +77,7 @@ services:
7777
args:
7878
METACALL_PATH: $METACALL_PATH
7979
METACALL_BASE_IMAGE: $METACALL_BASE_IMAGE
80-
METACALL_RUNTIME_OPTIONS: root base python ruby nodejs typescript file rpc backtrace ports clean # v8
80+
METACALL_RUNTIME_OPTIONS: base python ruby nodejs typescript file rpc backtrace ports clean # v8
8181
environment:
8282
DEBIAN_FRONTEND: noninteractive
8383
LTTNG_UST_REGISTER_TIMEOUT: 0

source/tests/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ add_subdirectory(metacall_node_await_chain_test)
145145
add_subdirectory(metacall_node_exception_test)
146146
add_subdirectory(metacall_node_python_deadlock_test)
147147
add_subdirectory(metacall_node_signal_handler_test)
148+
add_subdirectory(metacall_node_native_code_test)
148149
add_subdirectory(metacall_distributable_test)
149150
add_subdirectory(metacall_cast_test)
150151
add_subdirectory(metacall_init_fini_test)
@@ -174,9 +175,9 @@ add_subdirectory(metacall_python_relative_path_test)
174175
add_subdirectory(metacall_python_without_functions_test)
175176
add_subdirectory(metacall_python_builtins_test)
176177
add_subdirectory(metacall_python_async_test)
177-
add_subdirectory(metacall_python_await_test)
178+
# TODO: add_subdirectory(metacall_python_await_test)
178179
add_subdirectory(metacall_python_exception_test)
179-
add_subdirectory(metacall_python_node_await_test)
180+
# TODO: add_subdirectory(metacall_python_node_await_test)
180181
add_subdirectory(metacall_map_test)
181182
add_subdirectory(metacall_map_await_test)
182183
add_subdirectory(metacall_initialize_test)
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Check if this loader is enabled
2+
if(NOT OPTION_BUILD_LOADERS OR NOT OPTION_BUILD_LOADERS_NODE)
3+
return()
4+
endif()
5+
6+
#
7+
# Executable name and options
8+
#
9+
10+
# Target name
11+
set(target metacall-node-native-code-test)
12+
message(STATUS "Test ${target}")
13+
14+
#
15+
# Compiler warnings
16+
#
17+
18+
include(Warnings)
19+
20+
#
21+
# Compiler security
22+
#
23+
24+
include(SecurityFlags)
25+
26+
#
27+
# Sources
28+
#
29+
30+
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
31+
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
32+
33+
set(sources
34+
${source_path}/main.cpp
35+
${source_path}/metacall_node_native_code_test.cpp
36+
)
37+
38+
# Group source files
39+
set(header_group "Header Files (API)")
40+
set(source_group "Source Files")
41+
source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
42+
${header_group} ${headers})
43+
source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$"
44+
${source_group} ${sources})
45+
46+
#
47+
# Create executable
48+
#
49+
50+
# Build executable
51+
add_executable(${target}
52+
${sources}
53+
)
54+
55+
# Create namespaced alias
56+
add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target})
57+
58+
#
59+
# Project options
60+
#
61+
62+
set_target_properties(${target}
63+
PROPERTIES
64+
${DEFAULT_PROJECT_OPTIONS}
65+
FOLDER "${IDE_FOLDER}"
66+
)
67+
68+
#
69+
# Include directories
70+
#
71+
72+
target_include_directories(${target}
73+
PRIVATE
74+
${DEFAULT_INCLUDE_DIRECTORIES}
75+
${PROJECT_BINARY_DIR}/source/include
76+
)
77+
78+
#
79+
# Libraries
80+
#
81+
82+
target_link_libraries(${target}
83+
PRIVATE
84+
${DEFAULT_LIBRARIES}
85+
86+
GTest
87+
88+
${META_PROJECT_NAME}::metacall
89+
)
90+
91+
#
92+
# Compile definitions
93+
#
94+
95+
target_compile_definitions(${target}
96+
PRIVATE
97+
${DEFAULT_COMPILE_DEFINITIONS}
98+
)
99+
100+
#
101+
# Compile options
102+
#
103+
104+
target_compile_options(${target}
105+
PRIVATE
106+
${DEFAULT_COMPILE_OPTIONS}
107+
)
108+
109+
#
110+
# Linker options
111+
#
112+
113+
target_link_libraries(${target}
114+
PRIVATE
115+
${DEFAULT_LINKER_OPTIONS}
116+
)
117+
118+
#
119+
# Define test
120+
#
121+
122+
add_test(NAME ${target}
123+
COMMAND $<TARGET_FILE:${target}>
124+
)
125+
126+
#
127+
# Define dependencies
128+
#
129+
130+
add_dependencies(${target}
131+
node_loader
132+
node_port
133+
)
134+
135+
#
136+
# Define test properties
137+
#
138+
139+
set_property(TEST ${target}
140+
PROPERTY LABELS ${target}
141+
)
142+
143+
include(TestEnvironmentVariables)
144+
145+
test_environment_variables(${target}
146+
""
147+
${TESTS_ENVIRONMENT_VARIABLES}
148+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2022 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gtest/gtest.h>
22+
23+
int main(int argc, char *argv[])
24+
{
25+
::testing::InitGoogleTest(&argc, argv);
26+
27+
return RUN_ALL_TESTS();
28+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* MetaCall Library by Parra Studios
3+
* A library for providing a foreign function interface calls.
4+
*
5+
* Copyright (C) 2016 - 2022 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
#include <gtest/gtest.h>
22+
23+
#include <metacall/metacall.h>
24+
#include <metacall/metacall_loaders.h>
25+
26+
class metacall_node_unsupported_features_test : public testing::Test
27+
{
28+
public:
29+
};
30+
31+
TEST_F(metacall_node_unsupported_features_test, DefaultConstructor)
32+
{
33+
metacall_print_info();
34+
35+
ASSERT_EQ((int)0, (int)metacall_initialize());
36+
37+
/* NodeJS */
38+
#if defined(OPTION_BUILD_LOADERS_NODE)
39+
{
40+
/* Native functions are not supported yet */
41+
const char buffer[] =
42+
"const { metacall_inspect } = process._linkedBinding('node_loader_port_module');\n"
43+
"module.exports = { metacall_inspect }\n";
44+
45+
EXPECT_EQ((int)0, (int)metacall_load_from_memory("node", buffer, sizeof(buffer), NULL));
46+
47+
EXPECT_NE((void *)NULL, (void *)metacall_function("metacall_inspect"));
48+
}
49+
#endif /* OPTION_BUILD_LOADERS_NODE */
50+
51+
/* Print inspect information */
52+
{
53+
size_t size = 0;
54+
55+
struct metacall_allocator_std_type std_ctx = { &std::malloc, &std::realloc, &std::free };
56+
57+
void *allocator = metacall_allocator_create(METACALL_ALLOCATOR_STD, (void *)&std_ctx);
58+
59+
char *inspect_str = metacall_inspect(&size, allocator);
60+
61+
EXPECT_NE((char *)NULL, (char *)inspect_str);
62+
63+
EXPECT_GT((size_t)size, (size_t)0);
64+
65+
std::cout << inspect_str << std::endl;
66+
67+
metacall_allocator_free(allocator, inspect_str);
68+
69+
metacall_allocator_destroy(allocator);
70+
}
71+
72+
EXPECT_EQ((int)0, (int)metacall_destroy());
73+
}

0 commit comments

Comments
 (0)