Skip to content

Commit

Permalink
various fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Feb 26, 2024
1 parent 2d44ee1 commit d64dc49
Showing 7 changed files with 49 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -223,6 +223,7 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: make get_pact_ffi
- run: make get_pact_plugins
- run: make deno
bun:
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -14,4 +14,5 @@ scratchpad
*.gz
*.exe
*.dll
*.dll.lib
*.dll.lib
*.log
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ alpine_julia: # needs an x86_64 binary
docker run --platform=linux/amd64 -v ${PWD}:/app --rm julia:alpine sh -c 'apk add make gcc musl-dev && cd /app && make julia'

julia_hello_ffi:
$(LOAD_PATH)/libs/x64-musl julia julia/hello_ffi.jl
$(LOAD_PATH) julia julia/hello_ffi.jl

julia: julia_hello_ffi

40 changes: 34 additions & 6 deletions python/ctypes/download-plugin-cli.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ require_binary gunzip

require_env_var PLUGIN_CLI_VERSION

BASEURL=https://github.com/pact-foundation/pact-plugins/releases/download
BASEURL=https://github.com/you54f/pact-plugins/releases/download
PLUGIN_CLI_DIR="${HOME}/.pact/cli/plugin"

if [[ $(find "${PLUGIN_CLI_DIR}" -name "${PLUGIN_CLI_VERSION}*") ]]; then
@@ -83,13 +83,41 @@ case ${detected_os} in
;;
"Linux aarch64"* | "Linux arm64"*)
echo "downloading of linux aarch64 FFI libs"
os='linux-aarch64'
download_plugin_cli "linux-aarch64.gz" "" "pact-plugin-cli.gz" "${os}"
if ldd /bin/ls >/dev/null 2>&1; then
ldd_output=$(ldd /bin/ls)
case "$ldd_output" in
*musl*)
os='linux-aarch64-musl'
download_plugin_cli "linux-aarch64-musl.gz" "" "pact-plugin-cli.gz" "${os}"
;;
*)
os='linux-aarch64'
download_plugin_cli "linux-aarch64.gz" "" "pact-plugin-cli.gz" "${os}"
;;
esac
else
os='linux-aarch64'
download_plugin_cli "linux-aarch64.gz" "" "pact-plugin-cli.gz" "${os}"
fi
;;
'Linux x86_64' | "Linux"*)
echo "downloading of linux x86_64 FFI libs"
os='linux-x86_64'
download_plugin_cli "linux-x86_64.gz" "" "pact-plugin-cli.gz" "${os}"
if ldd /bin/ls >/dev/null 2>&1; then
ldd_output=$(ldd /bin/ls)
case "$ldd_output" in
*musl*)
os='linux-x86_64-musl'
download_plugin_cli "linux-x86_64-musl.gz" "" "pact-plugin-cli.gz" "${os}"
;;
*)
os='linux-x86_64'
download_plugin_cli "linux-x86_64.gz" "" "pact-plugin-cli.gz" "${os}"
;;
esac
else
os='linux-x86_64'
download_plugin_cli "linux-x86_64.gz" "" "pact-plugin-cli.gz" "${os}"
fi
;;
"Windows"* | "MINGW64"*)
echo "downloading of windows x86_64 FFI libs"
@@ -105,7 +133,7 @@ esac


# Write readme in the plugin folder
# cat << EOF > "$PLUGIN_CLI_DIR/pact_ffi.dll"
# cat << EOF > "$PLUGIN_CLI_DIR/README.md"
# # Pact plugin cli

# This folder is automatically populated during build by /script/download-plugin-cli.sh
2 changes: 1 addition & 1 deletion script/lib/download-plugin-cli.sh
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ require_binary gunzip

require_env_var PLUGIN_CLI_VERSION

BASEURL=https://github.com/pact-foundation/pact-plugins/releases/download
BASEURL=https://github.com/you54f/pact-plugins/releases/download
PLUGIN_CLI_DIR="${HOME}/.pact/cli/plugin"

if [[ $(find "${PLUGIN_CLI_DIR}" -name "${PLUGIN_CLI_VERSION}*") ]]; then
2 changes: 1 addition & 1 deletion script/lib/export-binary-versions.sh
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
PROJECT_DIR="${LIB_DIR}"/../../
export FFI_VERSION=v$(cat $PROJECT_DIR/FFI_VERSION)
export PLUGIN_CLI_VERSION=v0.0.1
export PLUGIN_CLI_VERSION=v0.1.2
18 changes: 9 additions & 9 deletions zig/hello_pact_mock_server.zig
Original file line number Diff line number Diff line change
@@ -23,36 +23,36 @@ pub extern fn pactffi_write_pact_file(i32, [*c]const u8, bool) i32;

pub fn main() !void {
const stdout = std.io.getStdOut().writer();
var version: [*c]u8 = pactffi_version();
const version: [*c]u8 = pactffi_version();
try stdout.print("{s}\n", .{version});
pactffi_logger_init();
var pactffi_logger_attach_sink_res: i32 = pactffi_logger_attach_sink("stdout", 3);
const pactffi_logger_attach_sink_res: i32 = pactffi_logger_attach_sink("stdout", 3);
try stdout.print("pactffi_logger_attach_sink result {}\n", .{pactffi_logger_attach_sink_res});
var pactffi_logger_apply_res: i32 = pactffi_logger_apply();
const pactffi_logger_apply_res: i32 = pactffi_logger_apply();
pactffi_log_message("pact-zig-ffi", "INFO", "Pact Zig FFI is alive");
try stdout.print("pactffi_logger_apply_res {}\n", .{pactffi_logger_apply_res});

const pact =
\\ {"consumer":{"name":"pact-raku-ffi"},"interactions":[{"description":"a retrieve Mallory request","request":{"method":"GET","path":"/mallory","query":"name=ron&status=good"},"response":{"body":"That is some good Mallory.","headers":{"Content-Type":"text/html"},"status":200}}],"metadata":{"pact-zig":{"ffi":"0.3.15","version":"1.0.0"},"pactRust":{"mockserver":"0.9.5","models":"1.0.0"},"pactSpecification":{"version":"1.0.0"}},"provider":{"name":"Alice Service"}}
;
var mock_server_port: i32 = pactffi_create_mock_server(pact, "127.0.0.1:4432", 0);
const mock_server_port: i32 = pactffi_create_mock_server(pact, "127.0.0.1:4432", 0);
pactffi_log_message("pact-zig-ffi", "INFO", "mock_server_port: $mock_server_port");
try stdout.print("mock_server_port result {}\n", .{mock_server_port});
var result = make_request("http://127.0.0.1:4432/mallory?name=ron&status=good");
const result = make_request("http://127.0.0.1:4432/mallory?name=ron&status=good");
try stdout.print("matched result {!}\n", .{result});

var matched: bool = pactffi_mock_server_matched(mock_server_port);
const matched: bool = pactffi_mock_server_matched(mock_server_port);
pactffi_log_message("pact-zig-ffi", "INFO", "pactffi_mock_server_matched: $matched");
try stdout.print("matched result {}\n", .{matched});

if (matched) {
var PACT_FILE_DIR = "./pacts";
var res_write_pact: i32 = pactffi_write_pact_file(mock_server_port, PACT_FILE_DIR, false);
const PACT_FILE_DIR = "./pacts";
const res_write_pact: i32 = pactffi_write_pact_file(mock_server_port, PACT_FILE_DIR, false);
pactffi_log_message("pact-zig-ffi", "INFO", "pactffi_write_pact_file: $res_write_pact");
try stdout.print("res_write_pact result {}\n", .{res_write_pact});
}

var pactffi_cleanup_mock_server_result: i32 = pactffi_cleanup_mock_server(mock_server_port);
const pactffi_cleanup_mock_server_result: i32 = pactffi_cleanup_mock_server(mock_server_port);
pactffi_log_message("pact-zig-ffi", "INFO", "pactffi_cleanup_mock_server");
try stdout.print("pactffi_cleanup_mock_server_result result {}\n", .{pactffi_cleanup_mock_server_result});
}

0 comments on commit d64dc49

Please sign in to comment.