forked from pact-foundation/pact-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
193 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash -eu | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running | ||
|
||
. "${SCRIPT_DIR}/lib/export-binary-versions.sh" | ||
"${SCRIPT_DIR}/lib/download-ffi.sh" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash -eu | ||
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running | ||
. "${LIB_DIR}/robust-bash.sh" | ||
. "${LIB_DIR}/download-file.sh" | ||
|
||
require_binary curl | ||
require_binary gunzip | ||
|
||
require_env_var FFI_VERSION | ||
|
||
BASEURL=https://github.com/pact-foundation/pact-reference/releases/download | ||
FFI_DIR="${LIB_DIR}/../../internal/native/libs" | ||
|
||
if [[ $(find "${FFI_DIR}" -name "${FFI_VERSION}*") ]]; then | ||
log "Skipping download of FFI libraries ${FFI_VERSION}, as they exist" | ||
exit 0 | ||
fi | ||
|
||
warn "Cleaning ffi directory $FFI_DIR" | ||
rm -rf "${FFI_DIR:?}" | ||
mkdir -p "$FFI_DIR/macos-x86_64" | ||
mkdir -p "$FFI_DIR/linux-x86_64" | ||
mkdir -p "$FFI_DIR/linux-musl-x86_64" | ||
mkdir -p "$FFI_DIR/windows-x86_64" | ||
mkdir -p "$FFI_DIR/macos-aarch64" | ||
mkdir -p "$FFI_DIR/linux-aarch64" | ||
mkdir -p "$FFI_DIR/linux-musl-aarch64" | ||
|
||
function download_ffi_file { | ||
if [ -z "${1:-}" ]; then | ||
error "${FUNCNAME[0]} requires the filename to download" | ||
exit 1 | ||
fi | ||
if [ -z "${2:-}" ]; then | ||
error "${FUNCNAME[0]} requires the output filename to download" | ||
exit 1 | ||
fi | ||
FFI_FILENAME="$1" | ||
OUTPUT_FILENAME="$2" | ||
|
||
URL="${BASEURL}/libpact_ffi-${FFI_VERSION}/${FFI_FILENAME}" | ||
DOWNLOAD_LOCATION="$FFI_DIR/${OUTPUT_FILENAME}" | ||
|
||
log "Downloading ffi $FFI_VERSION for $FFI_FILENAME" | ||
download_to "$URL" "$DOWNLOAD_LOCATION" | ||
debug_log " ... downloaded to '$DOWNLOAD_LOCATION'" | ||
} | ||
|
||
function download_ffi { | ||
if [ -z "${1:-}" ]; then | ||
error "${FUNCNAME[0]} requires the environment filename suffix" | ||
exit 1 | ||
fi | ||
SUFFIX="$1" | ||
PREFIX="${2:-}" | ||
OUTPUT_FILENAME="${3:-}" | ||
|
||
download_ffi_file "${PREFIX}pact_ffi-$SUFFIX" "${OUTPUT_FILENAME}" | ||
debug_log " ... unzipping '$DOWNLOAD_LOCATION'" | ||
gunzip -f "$DOWNLOAD_LOCATION" | ||
} | ||
|
||
if [[ ${RUNNER_OS:-} == 'Windows' ]]; then | ||
ONLY_DOWNLOAD_PACT_FOR_WINDOWS=true | ||
fi | ||
|
||
if [ -z "${ONLY_DOWNLOAD_PACT_FOR_WINDOWS:-}" ]; then | ||
download_ffi "linux-x86_64.so.gz" "lib" "linux-x86_64/libpact_ffi.so.gz" | ||
download_ffi "linux-aarch64.so.gz" "lib" "linux-aarch64/libpact_ffi.so.gz" | ||
download_ffi "linux-x86_64-musl.so.gz" "lib" "linux-musl-x86_64/libpact_ffi_musl.so.gz" | ||
download_ffi "linux-aarch64-musl.so.gz" "lib" "linux-musl-aarch64/libpact_ffi_musl.so.gz" | ||
download_ffi "macos-x86_64.dylib.gz" "lib" "macos-x86_64/libpact_ffi.dylib.gz" | ||
download_ffi "macos-aarch64.dylib.gz" "lib" "macos-aarch64/libpact_ffi.dylib.gz" | ||
else | ||
warn "Skipped download of non-windows FFI libs because ONLY_DOWNLOAD_PACT_FOR_WINDOWS is set" | ||
fi | ||
|
||
download_ffi "windows-x86_64.dll.gz" "" "windows-x86_64/pact_ffi.dll.gz" | ||
download_ffi "windows-x86_64.dll.lib.gz" "" "windows-x86_64/pact_ffi.dll.lib.gz" | ||
|
||
# download_ffi_file "pact.h" "pact.h" | ||
# download_ffi_file "pact-cpp.h" "pact-cpp.h" | ||
|
||
# Write readme in the ffi folder | ||
# cat << EOF > "$FFI_DIR/README.md" | ||
# # FFI binaries | ||
|
||
# This folder is automatically populated during build by /script/download-ffi.sh | ||
# EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash -eu | ||
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running | ||
. "${LIB_DIR}/robust-bash.sh" | ||
|
||
function download_to { | ||
if [ -z "${1:-}" ]; then | ||
error "${FUNCNAME[0]} requires the URL to download from as the first argument" | ||
exit 1 | ||
fi | ||
if [ -z "${2:-}" ]; then | ||
error "${FUNCNAME[0]} requires the file to save the download in as the second argument" | ||
exit 1 | ||
fi | ||
debug_log "about to download" | ||
URL="$1" | ||
OUTPUT_FILE="$2" | ||
debug_log "doing curl of: '$URL', saving in $OUTPUT_FILE" | ||
|
||
if [[ "$(uname -m)" == "Darwin" ]] || [[ "$(uname -m)" == "Linux" ]]; then | ||
HTTP_CODE="$(curl --silent --output "$OUTPUT_FILE" --write-out "%{http_code}" --location "$URL")" | ||
else | ||
# temp workaround for curl 8.8.x error on windows gha runners | ||
# https://github.com/curl/curl/issues/13845 | ||
curl --silent --output "$OUTPUT_FILE" --location "$URL" | ||
if [ $? -ne 0 ]; then | ||
error "Unable to download file at url ${URL}" | ||
exit 1 | ||
else | ||
HTTP_CODE=200 | ||
fi | ||
fi | ||
debug_log "did curl, http code was '${HTTP_CODE}'" | ||
if [[ "${HTTP_CODE}" -lt 200 || "${HTTP_CODE}" -gt 299 ]] ; then | ||
error "Unable to download file at url ${URL}" | ||
error "Downloaded content follows" | ||
cat "$OUTPUT_FILE" | ||
exit 1 | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash -eu | ||
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running | ||
PROJECT_DIR="${LIB_DIR}"/../../ | ||
export FFI_VERSION=v$(grep "version: \"" "$PROJECT_DIR"/installer/installer.go | awk -F'"' '{print $2}' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash -eu | ||
if [ -z "${LIB_ROBUST_BASH_SH:-}" ]; then | ||
LIB_ROBUST_BASH_SH=included | ||
|
||
function error { | ||
echo "❌ ${1:-}" | ||
} | ||
|
||
function log { | ||
echo "🔵 ${1:-}" | ||
} | ||
|
||
function debug_log { | ||
if [ ! -z "${LIB_ROBUST_BASH_DEBUG:-}" ]; then | ||
echo "🔎 ${1:-}" | ||
fi | ||
} | ||
|
||
function warn { | ||
echo "🟡 ${1:-}" | ||
} | ||
|
||
# Check to see that we have a required binary on the path | ||
# and fail the script if it is not present | ||
function require_binary { | ||
if [ -z "${1:-}" ]; then | ||
error "${FUNCNAME[0]} requires an argument" | ||
exit 1 | ||
fi | ||
|
||
if ! [ -x "$(command -v "$1")" ]; then | ||
error "The required executable '$1' is not on the path." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Check to see that we have a required environment variable set, | ||
# and fail the script if it is not set. | ||
# | ||
# Optionally, a second argument can be provided to display | ||
# a helpful message before failing | ||
function require_env_var { | ||
var_name="${1:-}" | ||
if [ -z "${!var_name:-}" ]; then | ||
error "The required environment variable ${var_name} is empty" | ||
if [ ! -z "${2:-}" ]; then | ||
echo " - $2" | ||
fi | ||
exit 1 | ||
fi | ||
} | ||
fi |