From aaddff9a7ccfef757f6516c72c69224dc47d3229 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 25 Apr 2024 19:26:57 +0100 Subject: [PATCH] feat: update installer script - more supported platforms - install to ~/.pact/bin --- .github/workflows/examples.yml | 22 +++++++++--------- .github/workflows/gradle.yml | 4 ++-- .github/workflows/rust.yml | 6 ++--- scripts/install-plugin-cli.sh | 34 +++++++++++++++++----------- scripts/install-verifier-cli.sh | 40 ++++++++++++++++++++------------- scripts/run-grpc-examples.sh | 2 +- 6 files changed, 62 insertions(+), 46 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 9fb519c0..5e1ee6f7 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -31,10 +31,10 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Install csv plugin - run: ~/bin/pact-plugin-cli -y install csv + run: ~/.pact/bin/pact-plugin-cli -y install csv shell: bash - name: Install Pact verifier run: scripts/install-verifier-cli.sh @@ -51,8 +51,8 @@ jobs: nohup ./target/debug/csv-provider & PID=$! trap "kill $PID" EXIT - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-rust/target/pacts/CsvClient-CsvServer.json -p 8080 - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-rust/target/pacts/CsvClient-CsvServer.json -p 8080 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080 cd ../csv-provider-jvm mkdir -p server/src/test/resources/pacts cp ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json server/src/test/resources/pacts @@ -70,7 +70,7 @@ jobs: nohup ./target/debug/csv-provider & PID=$! trap "kill $PID" EXIT - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080 shell: bash working-directory: examples/csv if: runner.os == 'Windows' @@ -110,7 +110,7 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Install Pact verifier run: scripts/install-verifier-cli.sh @@ -138,8 +138,8 @@ jobs: PID=$! trap "kill $PID" EXIT timeout --foreground -s TERM 30s bash -c 'while [[ "$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' -XPOST -d'{}' http://127.0.0.1:8111)" != "200" ]]; do echo "Waiting for http://127.0.0.1:8111" && sleep 2; done' - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111 - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111 shell: bash working-directory: examples/protobuf if: runner.os == 'Linux' @@ -158,8 +158,8 @@ jobs: PID=$! trap "kill $PID" EXIT timeout --foreground -s TERM 30s bash -c 'while [[ "$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' -XPOST -d'{}' http://127.0.0.1:8111)" != "200" ]]; do echo "Waiting for http://127.0.0.1:8111" && sleep 2; done' - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111 - pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111 + pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111 shell: bash working-directory: examples/protobuf if: runner.os != 'Linux' @@ -199,7 +199,7 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Install Pact verifier run: scripts/install-verifier-cli.sh diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 91e13f18..5d30dfc9 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -28,7 +28,7 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Run plugin driver tests run: ./gradlew -s --no-daemon -i check @@ -61,7 +61,7 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Run plugin driver tests run: ./gradlew -s --no-daemon -i check diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ea5ed7e..4420b3fc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,10 +24,10 @@ jobs: run: scripts/install-plugin-cli.sh shell: bash - name: Install Protobuf plugin - run: ~/bin/pact-plugin-cli -y install protobuf + run: ~/.pact/bin/pact-plugin-cli -y install protobuf shell: bash - name: Install csv plugin - run: ~/bin/pact-plugin-cli -y install csv + run: ~/.pact/bin/pact-plugin-cli -y install csv shell: bash - name: Tests run: cargo test @@ -63,7 +63,7 @@ jobs: curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.88.77/pact-1.88.77-linux-x86_64.tar.gz tar xzf pact-1.88.77-linux-x86_64.tar.gz VER=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - pact/bin/pact-broker publish -a "$VER+$GITHUB_SHA" -b https://pact-foundation.pactflow.io -k ${{ secrets.PACTFLOW_TOKEN }} target/pacts + pact/bin/pact-broker publish -a "$VER+$GITHUB_SHA" -b https://saf.pactflow.io -k ${{ secrets.PACTFLOW_TOKEN }} target/pacts working-directory: drivers/rust/driver_pact_tests if: runner.os == 'Linux' diff --git a/scripts/install-plugin-cli.sh b/scripts/install-plugin-cli.sh index f88e3fc7..cb6321e1 100755 --- a/scripts/install-plugin-cli.sh +++ b/scripts/install-plugin-cli.sh @@ -5,36 +5,44 @@ set -x VERSION="0.1.0" -mkdir -p ~/bin +mkdir -p ~/.pact/bin case "$(uname -s)" in Darwin) echo '== Installing plugin CLI for Mac OSX ==' - if [ "$(uname -m)" == "arm64" ]; then - curl -L -o ~/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-osx-aarch64.gz + if [ "$(uname -m)" = "arm64" ]; then + curl -L -o ~/.pact/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-osx-aarch64.gz else - curl -L -o ~/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-osx-x86_64.gz + curl -L -o ~/.pact/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-osx-x86_64.gz fi - gunzip -N -f ~/bin/pact-plugin-cli.gz - chmod +x ~/bin/pact-plugin-cli + gunzip -N -f ~/.pact/bin/pact-plugin-cli.gz + chmod +x ~/.pact/bin/pact-plugin-cli ;; Linux) echo '== Installing plugin CLI for Linux ==' - curl -L -o ~/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-linux-x86_64.gz - gunzip -N -f ~/bin/pact-plugin-cli.gz - chmod +x ~/bin/pact-plugin-cli + if [ "$(uname -m)" = "aarch64" ]; then + curl -L -o ~/.pact/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-linux-aarch64.gz + else + curl -L -o ~/.pact/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-linux-x86_64.gz + fi + gunzip -N -f ~/.pact/bin/pact-plugin-cli.gz + chmod +x ~/.pact/bin/pact-plugin-cli ;; CYGWIN*|MINGW32*|MSYS*|MINGW*) echo '== Installing plugin CLI for MS Windows ==' - curl -L -o ~/bin/pact-plugin-cli.exe.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-windows-x86_64.exe.gz - gunzip -N -f ~/bin/pact-plugin-cli.exe.gz - chmod +x ~/bin/pact-plugin-cli.exe + if [ "$(uname -m)" = "aarch64" ]; then + curl -L -o ~/.pact/bin/pact-plugin-cli.exe.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-windows-aarch64.exe.gz + else + curl -L -o ~/.pact/bin/pact-plugin-cli.exe.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v${VERSION}/pact-plugin-cli-windows-x86_64.exe.gz + fi + gunzip -N -f ~/.pact/bin/pact-plugin-cli.exe.gz + chmod +x ~/.pact/bin/pact-plugin-cli.exe ;; *) echo "ERROR: $(uname -s) is not a supported operating system" exit 1 ;; -esac +esac \ No newline at end of file diff --git a/scripts/install-verifier-cli.sh b/scripts/install-verifier-cli.sh index d0d2b318..ec106552 100755 --- a/scripts/install-verifier-cli.sh +++ b/scripts/install-verifier-cli.sh @@ -5,36 +5,44 @@ set -x VERSION="0.9.20" -mkdir -p ~/bin +mkdir -p ~/.pact/bin case "$(uname -s)" in Darwin) - echo '== Installing verifier CLI for Mac OSX ==' - if [ "$(uname -m)" == "arm64" ]; then - curl -L -o ~/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-osx-aarch64.gz + echo '== Installing pact verifier CLI for Mac OSX ==' + if [ "$(uname -m)" = "arm64" ]; then + curl -L -o ~/.pact/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-osx-aarch64.gz else - curl -L -o ~/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-osx-x86_64.gz + curl -L -o ~/.pact/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-osx-x86_64.gz fi - gunzip -N -f ~/bin/pact_verifier_cli.gz - chmod +x ~/bin/pact_verifier_cli + gunzip -N -f ~/.pact/bin/pact_verifier_cli.gz + chmod +x ~/.pact/bin/pact_verifier_cli ;; Linux) - echo '== Installing verifier CLI for Linux ==' - curl -L -o ~/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-linux-x86_64.gz - gunzip -N -f ~/bin/pact_verifier_cli.gz - chmod +x ~/bin/pact_verifier_cli + echo '== Installing pact verifier CLI for Linux ==' + if [ "$(uname -m)" = "aarch64" ]; then + curl -L -o ~/.pact/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-linux-aarch64.gz + else + curl -L -o ~/.pact/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-linux-x86_64.gz + fi + gunzip -N -f ~/.pact/bin/pact_verifier_cli.gz + chmod +x ~/.pact/bin/pact_verifier_cli ;; CYGWIN*|MINGW32*|MSYS*|MINGW*) - echo '== Installing verifier CLI for MS Windows ==' - curl -L -o ~/bin/pact_verifier_cli.exe.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-windows-x86_64.exe.gz - gunzip -N -f ~/bin/pact_verifier_cli.exe.gz - chmod +x ~/bin/pact_verifier_cli.exe + echo '== Installing pact verifier CLI for MS Windows ==' + if [ "$(uname -m)" = "aarch64" ]; then + curl -L -o ~/.pact/bin/pact_verifier_cli.exe.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-windows-aarch64.exe.gz + else + curl -L -o ~/.pact/bin/pact_verifier_cli.exe.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v${VERSION}/pact_verifier_cli-windows-x86_64.exe.gz + fi + gunzip -N -f ~/.pact/bin/pact_verifier_cli.exe.gz + chmod +x ~/.pact/bin/pact_verifier_cli.exe ;; *) echo "ERROR: $(uname -s) is not a supported operating system" exit 1 ;; -esac +esac \ No newline at end of file diff --git a/scripts/run-grpc-examples.sh b/scripts/run-grpc-examples.sh index a8cb4291..b6902359 100755 --- a/scripts/run-grpc-examples.sh +++ b/scripts/run-grpc-examples.sh @@ -44,7 +44,7 @@ trap "kill $PID" EXIT sleep 1 ls -la PROVIDER_PORT=$(cat provider.go.out | cut -f4 -d:) -~/bin/pact_verifier_cli -f ../consumer-jvm/build/pacts/grpc-consumer-jvm-area-calculator-provider.json\ +~/.pact/bin/pact_verifier_cli -f ../consumer-jvm/build/pacts/grpc-consumer-jvm-area-calculator-provider.json\ -f ../consumer-rust/target/pacts/grpc-consumer-rust-area-calculator-provider.json\ -f ../consumer-go/pacts/grpc-consumer-go-area-calculator-provider.json\ -p "$PROVIDER_PORT"