Skip to content

Commit

Permalink
ci: enable plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Feb 13, 2024
1 parent 77e27b2 commit 065f3b6
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 15 deletions.
2 changes: 2 additions & 0 deletions script/ci/download-standalone-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running
. "$SCRIPT_DIR"/../lib/robust-bash.sh

./script/install-cli.sh
./script/install-plugins.sh
./script/download-standalone.sh
./script/ci/build-and-test.sh
82 changes: 82 additions & 0 deletions script/install-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh -e
#
# Usage:
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh | bash
# or
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh -O- | bash
#
set -e # Needed for Windows bash, which doesn't read the shebang

detect_osarch() {
# detect_musl
case $(uname -sm) in
'Linux x86_64')
if ldd /bin/ls >/dev/null 2>&1; then
ldd_output=$(ldd /bin/ls)
case "$ldd_output" in
*musl*)
os='linux'
arch='x86_64-musl'
;;
*)
os='linux'
arch='x86_64'
;;
esac
else
os='linux'
arch='x86_64'
fi
;;
'Linux aarch64')
if ldd /bin/ls >/dev/null 2>&1; then
ldd_output=$(ldd /bin/ls)
case "$ldd_output" in
*musl*)
os='linux'
arch='aarch64-musl'
;;
*)
os='linux'
arch='aarch64'
;;
esac
else
os='linux'
arch='aarch64'
fi
;;
'Darwin x86' | 'Darwin x86_64')
os='osx'
arch='x86_64'
;;
'Darwin arm64')
os='osx'
arch='aarch64'
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
os="windows"
arch='x86_64'
ext='.exe'
;;
*)
echo "Sorry, you'll need to install the plugin CLI manually."
exit 1
;;
esac
}


VERSION="0.1.3"
detect_osarch

if [ ! -f ~/.pact/bin/pact-plugin-cli ]; then
echo "--- 🐿 Installing plugins CLI version '${VERSION}' (from tag ${TAG})"
mkdir -p ~/.pact/bin
DOWNLOAD_LOCATION=https://github.com/you54f/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-${os}-${arch}${ext}.gz
echo " Downloading from: ${DOWNLOAD_LOCATION}"
curl -L -o ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz "${DOWNLOAD_LOCATION}"
echo " Downloaded $(file ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz)"
gunzip -N -f ~/.pact/bin/pact-plugin-cli-${os}-${arch}.gz
chmod +x ~/.pact/bin/pact-plugin-cli
fi
14 changes: 14 additions & 0 deletions script/install-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -e
#
# Usage:
# $ curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh | bash
# or
# $ wget -q https://raw.githubusercontent.com/pact-foundation/pact-plugins/master/install-cli.sh -O- | bash
#
set -e # Needed for Windows bash, which doesn't read the shebang


~/.pact/bin/pact-plugin-cli -y install https://github.com/you54f/pact-protobuf-plugin/releases/tag/v-0.3.14
# ~/.pact/bin/pact-plugin-cli -y install https://github.com/you54f/pact-plugins/releases/tag/csv-plugin-0.0.6
~/.pact/bin/pact-plugin-cli -y install https://github.com/you54f/pact-matt-plugin/releases/tag/v0.1.0
# ~/.pact/bin/pact-plugin-cli -y install https://github.com/austek/pact-avro-plugin/releases/tag/v0.0.5
6 changes: 3 additions & 3 deletions test/consumer.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64';
const usesOctetStream = isWin || isDarwinArm64;

describe('FFI integration test for the HTTP Consumer API', () => {
setLogLevel('trace');
setLogLevel('info');

let port: number;
let pact: ConsumerPact;
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('FFI integration test for the HTTP Consumer API', () => {
});

// Should only run this if the plugin is installed
describe.skip('using a plugin (protobufs)', () => {
describe('using a plugin (protobufs)', () => {
const protoFile = `${__dirname}/integration/plugin.proto`;

beforeEach(() => {
Expand All @@ -264,7 +264,7 @@ describe('FFI integration test for the HTTP Consumer API', () => {
'bar-provider',
FfiSpecificationVersion['SPECIFICATION_VERSION_V3']
);
pact.addPlugin('protobuf', '0.1.14');
pact.addPlugin('protobuf', '0.3.14');

const interaction = pact.newInteraction('some description');
const protobufContents = {
Expand Down
4 changes: 1 addition & 3 deletions test/integration/grpc/grpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"interactions": [
{
"description": "A request to do a foo",
"key": "539a26be10e0124e",
"pending": false,
"request": {
"body": {
Expand Down Expand Up @@ -47,7 +46,6 @@
"markup": "```protobuf\nmessage Feature {\n string name = 1;\n message .routeguide.Point location = 2;\n}\n```\n",
"markupType": "COMMON_MARK"
},
"key": "d81a62841ce862db",
"pending": false,
"pluginConfiguration": {
"protobuf": {
Expand Down Expand Up @@ -143,7 +141,7 @@
}
},
"name": "protobuf",
"version": "0.1.14"
"version": "0.3.14"
}
]
},
Expand Down
Loading

0 comments on commit 065f3b6

Please sign in to comment.