diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62d92bd..477d218 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,9 +42,3 @@ jobs: uses: actions/download-artifact@v3 - name: test ${{ matrix.os }} package run: ./script/unpack-and-test.sh - - name: test x86 package - if: ${{ runner.os == 'Windows'}} - run: ./script/unpack-and-test.sh - env: - BINARY_OS: 'windows' - BINARY_ARCH: 'x86' diff --git a/packaging/README.md.template b/packaging/README.md.template index fa92f82..f71f213 100644 --- a/packaging/README.md.template +++ b/packaging/README.md.template @@ -2,7 +2,10 @@ ![Build](https://github.com/pact-foundation/pact-ruby-standalone/workflows/Build/badge.svg) -Creates a standalone pact command line executable using the ruby pact implementation and Traveling Ruby +Creates a standalone pact command line executable containing + +- The rust pact implementation via cargo executables +- The ruby pact implementation via Traveling Ruby ## Package contents @@ -14,6 +17,10 @@ This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables pa * pact-provider-verifier gem <%= Pact::ProviderVerifier::VERSION %> * pact_broker-client gem <%= PactBroker::Client::VERSION %> * pact-message gem <%= Pact::Message::VERSION %> + * [pact_mock_server_cli](https://github.com/pact-foundation/pact-core-mock-server/tree/main/pact_mock_server_cli) + * [pact-stub-server](https://github.com/pact-foundation/pact-stub-server) + * [pact_verifier_cli](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli) + * [pact-plugin-cli](https://github.com/pact-foundation/pact-plugins/tree/main/cli) Binaries will be extracted into `pact/bin`: @@ -25,12 +32,16 @@ Binaries will be extracted into `pact/bin`: ├── pact-message ├── pact-mock-service ├── pact-provider-verifier -└── pact-stub-service +├── pact-stub-service +├── pact_mock_server_cli (rust) +├── pact-stub-server (rust) +├── pact_verifier_cli (rust) +└── pact-plugin-cli (rust) ``` ### Windows Users -Please append `.bat` to any of the provided binaries +Please append `.bat` to any of the provided ruby-based binaries eg. @@ -38,6 +49,14 @@ eg. .\pact\bin\pact-broker.bat ``` +Please append `.exe` to any of the provided rust based binaries + +eg. + +```ps1 + .\pact\bin\pact_mock_server_cli.exe +``` + ## Installation See the [release page][releases]. @@ -55,10 +74,9 @@ Ruby is not required on the host platform, Ruby 3.3.3 is provided in the distrib | Linux | 3.3.3 | x86_64 | ✅ | | Linux | 3.3.3 | aarch64 (arm64)| ✅ | | Windows| 3.3.3 | x86_64 | ✅ | -| Windows| 3.3.3 | x86 | ✅ | | Windows| 3.3.3 | aarch64 (arm64)| 🚧 | -🚧 - Tested under emulation mode x86 / x86_64 in Windows on ARM +🚧 - Tested under emulation mode x86_64 in Windows on ARM ## Usage diff --git a/packaging/RELEASE_NOTES.md.template b/packaging/RELEASE_NOTES.md.template index 25d87d4..104ba1a 100644 --- a/packaging/RELEASE_NOTES.md.template +++ b/packaging/RELEASE_NOTES.md.template @@ -49,12 +49,4 @@ tar xzf pact--linux-arm64.tar.gz ``` curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download//pact--windows-x86_64.zip unzip pact--windows-x86_64.zip -``` - -#### x86 - -``` -curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download//pact--windows-x86.zip -unzip pact--windows-x86.zip -``` - +``` \ No newline at end of file diff --git a/script/test.sh b/script/test.sh index 2c98c2d..f06e10f 100755 --- a/script/test.sh +++ b/script/test.sh @@ -29,10 +29,6 @@ if [ "$BINARY_OS" == "" ] || [ "$BINARY_ARCH" == "" ] ; then BINARY_OS=windows BINARY_ARCH=x86_64 ;; - "Windows"* | "MINGW"*) - BINARY_OS=windows - BINARY_ARCH=x86 - ;; *) echo "Sorry, os not determined" exit 1 @@ -40,24 +36,29 @@ if [ "$BINARY_OS" == "" ] || [ "$BINARY_ARCH" == "" ] ; then esac; fi +if [ "$BINARY_OS" != "windows" ] ; then PATH_SEPERATOR=/ ; else PATH_SEPERATOR=\\; fi +PATH_TO_BIN=.${PATH_SEPERATOR}pkg${PATH_SEPERATOR}pact${PATH_SEPERATOR}bin${PATH_SEPERATOR} tools=( - # pact + pact pact-broker pact-message pact-mock-service - pact-plugin-cli pact-provider-verifier pact-stub-service pactflow + pact-plugin-cli + pact-stub-server + pact_verifier_cli + pact_mock_server_cli ) +test_cmd="" for tool in ${tools[@]}; do echo testing $tool - if [ "$BINARY_OS" != "windows" ] ; then echo "no bat file ext needed for $(uname -a)" ; else FILE_EXT=.bat; fi - if [ "$BINARY_OS" = "windows" ] && [ "$tool" = "pact-plugin-cli" ] ; then FILE_EXT=.exe ; else echo "no exe file ext needed for $(uname -a)"; fi + if [ "$BINARY_OS" = "windows" ] ; then FILE_EXT=.bat; fi + if [ "$BINARY_OS" = "windows" ] && ([ "$tool" = "pact-plugin-cli" ] || [ "$tool" = "pact-stub-server" ] || [ "$tool" = "pact_verifier_cli" ] || [ "$tool" = "pact_mock_server_cli" ]) ; then FILE_EXT=.exe ; fi + if [ "$tool" = "pact_verifier_cli" ] || [ "$tool" = "pact-mock-service" ]; then test_cmd="--help" ; fi echo executing ${tool}${FILE_EXT} - if [ "$BINARY_ARCH" = "x86" ] && [ "$tool" = "pact-plugin-cli" ] ; then echo "skipping for x86" ; else ${tool}${FILE_EXT} help; fi -done - - + ${PATH_TO_BIN}${tool}${FILE_EXT} ${test_cmd}; +done \ No newline at end of file diff --git a/script/unpack-and-test.sh b/script/unpack-and-test.sh index f40b1d1..f3cc91a 100755 --- a/script/unpack-and-test.sh +++ b/script/unpack-and-test.sh @@ -29,10 +29,6 @@ if [ "$BINARY_OS" == "" ] || [ "$BINARY_ARCH" == "" ] ; then BINARY_OS=windows BINARY_ARCH=x86_64 ;; - "Windows"* | "MINGW"*) - BINARY_OS=windows - BINARY_ARCH=x86 - ;; *) echo "Sorry, os not determined" exit 1 @@ -40,6 +36,9 @@ if [ "$BINARY_OS" == "" ] || [ "$BINARY_ARCH" == "" ] ; then esac; fi +if [[ "$BINARY_OS" == "windows" ]]; then + FILE_EXT=".zip" +fi cd pkg rm -rf pact @@ -50,22 +49,25 @@ if [ "$BINARY_OS" != "windows" ] ; then PATH_SEPERATOR=/ ; else PATH_SEPERATOR=\ PATH_TO_BIN=.${PATH_SEPERATOR}pact${PATH_SEPERATOR}bin${PATH_SEPERATOR} tools=( - # pact + pact pact-broker pact-message pact-mock-service - pact-plugin-cli pact-provider-verifier pact-stub-service pactflow + pact-plugin-cli + pact-stub-server + pact_verifier_cli + pact_mock_server_cli ) +test_cmd="" for tool in ${tools[@]}; do echo testing $tool - if [ "$BINARY_OS" != "windows" ] ; then echo "no bat file ext needed for $(uname -a)" ; else FILE_EXT=.bat; fi - if [ "$BINARY_OS" = "windows" ] && [ "$tool" = "pact-plugin-cli" ] ; then FILE_EXT=.exe ; else echo "no exe file ext needed for $(uname -a)"; fi - echo executing ${PATH_TO_BIN}${tool}${FILE_EXT} - if [ "$BINARY_ARCH" = "x86" ] && [ "$tool" = "pact-plugin-cli" ] ; then echo "skipping for x86" ; else ${PATH_TO_BIN}${tool}${FILE_EXT} help; fi -done - - + if [ "$BINARY_OS" = "windows" ] ; then FILE_EXT=.bat; fi + if [ "$BINARY_OS" = "windows" ] && ([ "$tool" = "pact-plugin-cli" ] || [ "$tool" = "pact-stub-server" ] || [ "$tool" = "pact_verifier_cli" ] || [ "$tool" = "pact_mock_server_cli" ]) ; then FILE_EXT=.exe ; fi + if [ "$tool" = "pact_verifier_cli" ] || [ "$tool" = "pact-mock-service" ]; then test_cmd="--help" ; fi + echo executing ${tool}${FILE_EXT} + ${PATH_TO_BIN}${tool}${FILE_EXT} ${test_cmd}; +done \ No newline at end of file diff --git a/tasks/package.rake b/tasks/package.rake index 0fa4a5b..f1eddbd 100644 --- a/tasks/package.rake +++ b/tasks/package.rake @@ -5,10 +5,17 @@ PACKAGE_NAME = "pact" VERSION = File.read('VERSION').strip TRAVELING_RUBY_VERSION = "20240615-3.3.3" TRAVELING_RUBY_PKG_DATE = TRAVELING_RUBY_VERSION.split("-").first -PLUGIN_CLI_VERSION = "0.1.2" +TRAVELING_RB_VERSION = TRAVELING_RUBY_VERSION.split("-").last +RUBY_COMPAT_VERSION = TRAVELING_RB_VERSION.split(".").first(2).join(".") + ".0" +RUBY_MAJOR_VERSION = TRAVELING_RB_VERSION.split(".").first.to_i +RUBY_MINOR_VERSION = TRAVELING_RB_VERSION.split(".")[1].to_i +PLUGIN_CLI_VERSION = "0.1.3" # https://github.com/pact-foundation/pact-plugins/releases +MOCK_SERVER_CLI_VERSION = "1.0.6" # https://github.com/pact-foundation/pact-core-mock-server/releases +VERIFIER_CLI_VERSION = "1.1.4" # https://github.com/pact-foundation/pact-reference/releases +STUB_SERVER_CLI_VERSION = "0.6.0" # https://github.com/pact-foundation/pact-stub-server/releases desc "Package pact-ruby-standalone for OSX, Linux x86_64 and windows x86_64" -task :package => ['package:linux:x86_64','package:linux:arm64', 'package:osx:x86_64', 'package:osx:arm64','package:windows:x86_64','package:windows:x86'] +task :package => ['package:linux:x86_64','package:linux:arm64', 'package:osx:x86_64', 'package:osx:arm64','package:windows:x86_64'] namespace :package do namespace :linux do @@ -27,27 +34,23 @@ namespace :package do desc "Package pact-ruby-standalone for OS X x86_64" task :x86_64 => [:bundle_install, "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx-x86_64.tar.gz"] do create_package(TRAVELING_RUBY_VERSION, "osx-x86_64", "osx-x86_64", :unix) - end + end desc "Package pact-ruby-standalone for OS X arm64" task :arm64 => [:bundle_install, "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx-arm64.tar.gz"] do create_package(TRAVELING_RUBY_VERSION, "osx-arm64", "osx-arm64", :unix) - end + end end namespace :windows do desc "Package pact-ruby-standalone for windows x86_64" task :x86_64 => [:bundle_install, "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-windows-x86_64.tar.gz"] do create_package(TRAVELING_RUBY_VERSION, "windows-x86_64", "windows-x86_64", :windows) end - desc "Package pact-ruby-standalone for windows x86" - task :x86 => [:bundle_install, "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-windows-x86.tar.gz"] do - create_package(TRAVELING_RUBY_VERSION, "windows-x86", "windows-x86", :windows) - end end desc "Install gems to local directory" task :bundle_install do - if RUBY_VERSION !~ /^3\.3\./ - abort "You can only 'bundle install' using Ruby 3.3.3, because that's what Traveling Ruby uses." + if RUBY_VERSION !~ /^#{RUBY_MAJOR_VERSION}\.#{RUBY_MINOR_VERSION}\./ + abort "You can only 'bundle install' using Ruby #{RUBY_VERSION}, because that's what Traveling Ruby uses." end sh "rm -rf build/tmp" sh "mkdir -p build/tmp" @@ -91,10 +94,6 @@ end file "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-windows-x86_64.tar.gz" do download_runtime(TRAVELING_RUBY_VERSION, "windows-x86_64") end -file "build/traveling-ruby-#{TRAVELING_RUBY_VERSION}-windows-x86.tar.gz" do - download_runtime(TRAVELING_RUBY_VERSION, "windows-x86") -end - def create_package(version, source_target, package_target, os_type) package_dir = "#{PACKAGE_NAME}" package_name = "#{PACKAGE_NAME}-#{VERSION}-#{package_target}" @@ -129,17 +128,20 @@ def create_package(version, source_target, package_target, os_type) remove_unnecessary_files package_dir install_plugin_cli package_dir, package_target + install_mock_server_cli package_dir, package_target + install_verifier_cli package_dir, package_target + install_stub_server_cli package_dir, package_target if !ENV['DIR_ONLY'] sh "mkdir -p pkg" - if os_type == :unix - sh "tar -czf pkg/#{package_name}.tar.gz #{package_dir}" - else - sh "zip -9rq pkg/#{package_name}.zip #{package_dir}" - end + if os_type == :unix + sh "tar -czf pkg/#{package_name}.tar.gz #{package_dir}" + else + sh "zip -9rq pkg/#{package_name}.zip #{package_dir}" + end - sh "rm -rf #{package_dir}" + sh "rm -rf #{package_dir}" end end @@ -221,8 +223,8 @@ def remove_unnecessary_files package_dir end def generate_readme - template = File.absolute_path("packaging/README.md.template") - script = File.absolute_path("packaging/generate_readme_contents.rb") + template = File.absolute_path('packaging/README.md.template') + script = File.absolute_path('packaging/generate_readme_contents.rb') Bundler.with_unbundled_env do sh "cd build/tmp && env VERSION=#{VERSION} bundle exec ruby #{script} #{template} > ../README.md" end @@ -230,7 +232,7 @@ end def download_runtime(version, target) sh "cd build && curl -L -O --fail " + - "https://github.com/YOU54F/traveling-ruby/releases/download/rel-#{TRAVELING_RUBY_PKG_DATE}/traveling-ruby-#{version}-#{target}.tar.gz" + "https://github.com/YOU54F/traveling-ruby/releases/download/rel-#{TRAVELING_RUBY_PKG_DATE}/traveling-ruby-#{version}-#{target}.tar.gz" end def install_plugin_cli(package_dir, package_target) @@ -244,11 +246,11 @@ def install_plugin_cli(package_dir, package_target) sh "gunzip -N -f #{package_dir}/bin/pact-plugin-cli.gz" sh "chmod +x #{package_dir}/bin/pact-plugin-cli" when "osx-x86_64" - sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-osx-x86_64.gz" + sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-macos-x86_64.gz" sh "gunzip -N -f #{package_dir}/bin/pact-plugin-cli.gz" sh "chmod +x #{package_dir}/bin/pact-plugin-cli" when "osx-arm64" - sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-osx-aarch64.gz" + sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-macos-aarch64.gz" sh "gunzip -N -f #{package_dir}/bin/pact-plugin-cli.gz" sh "chmod +x #{package_dir}/bin/pact-plugin-cli" when "windows-x86_64" @@ -257,3 +259,78 @@ def install_plugin_cli(package_dir, package_target) sh "chmod +x #{package_dir}/bin/pact-plugin-cli.exe" end end + +def install_mock_server_cli(package_dir, package_target) + case package_target + when "linux-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_mock_server_cli.gz https://github.com/pact-foundation/pact-core-mock-server//releases/download/pact_mock_server_cli-v#{MOCK_SERVER_CLI_VERSION}/pact_mock_server_cli-linux-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_mock_server_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_mock_server_cli" + when "linux-arm64" + sh "curl -L -o #{package_dir}/bin/pact_mock_server_cli.gz https://github.com/pact-foundation/pact-core-mock-server//releases/download/pact_mock_server_cli-v#{MOCK_SERVER_CLI_VERSION}/pact_mock_server_cli-linux-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_mock_server_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_mock_server_cli" + when "osx-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_mock_server_cli.gz https://github.com/pact-foundation/pact-core-mock-server//releases/download/pact_mock_server_cli-v#{MOCK_SERVER_CLI_VERSION}/pact_mock_server_cli-macos-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_mock_server_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_mock_server_cli" + when "osx-arm64" + sh "curl -L -o #{package_dir}/bin/pact_mock_server_cli.gz https://github.com/pact-foundation/pact-core-mock-server//releases/download/pact_mock_server_cli-v#{MOCK_SERVER_CLI_VERSION}/pact_mock_server_cli-macos-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_mock_server_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_mock_server_cli" + when "windows-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_mock_server_cli.exe.gz https://github.com/pact-foundation/pact-core-mock-server//releases/download/pact_mock_server_cli-v#{MOCK_SERVER_CLI_VERSION}/pact_mock_server_cli-windows-x86_64.exe.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_mock_server_cli.exe.gz" + sh "chmod +x #{package_dir}/bin/pact_mock_server_cli.exe" + end +end + +def install_verifier_cli(package_dir, package_target) + case package_target + when "linux-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v#{VERIFIER_CLI_VERSION}/pact_verifier_cli-linux-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_verifier_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_verifier_cli" + when "linux-arm64" + sh "curl -L -o #{package_dir}/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v#{VERIFIER_CLI_VERSION}/pact_verifier_cli-linux-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_verifier_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_verifier_cli" + when "osx-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v#{VERIFIER_CLI_VERSION}/pact_verifier_cli-macos-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_verifier_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_verifier_cli" + when "osx-arm64" + sh "curl -L -o #{package_dir}/bin/pact_verifier_cli.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v#{VERIFIER_CLI_VERSION}/pact_verifier_cli-macos-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_verifier_cli.gz" + sh "chmod +x #{package_dir}/bin/pact_verifier_cli" + when "windows-x86_64" + sh "curl -L -o #{package_dir}/bin/pact_verifier_cli.exe.gz https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v#{VERIFIER_CLI_VERSION}/pact_verifier_cli-windows-x86_64.exe.gz" + sh "gunzip -N -f #{package_dir}/bin/pact_verifier_cli.exe.gz" + sh "chmod +x #{package_dir}/bin/pact_verifier_cli.exe" + end +end + +def install_stub_server_cli(package_dir, package_target) + case package_target + when "linux-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-stub-server.gz https://github.com/pact-foundation/pact-stub-server/releases/download/v#{STUB_SERVER_CLI_VERSION}/pact-stub-server-linux-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-stub-server.gz" + sh "chmod +x #{package_dir}/bin/pact-stub-server" + when "linux-arm64" + sh "curl -L -o #{package_dir}/bin/pact-stub-server.gz https://github.com/pact-foundation/pact-stub-server/releases/download/v#{STUB_SERVER_CLI_VERSION}/pact-stub-server-linux-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-stub-server.gz" + sh "chmod +x #{package_dir}/bin/pact-stub-server" + when "osx-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-stub-server.gz https://github.com/pact-foundation/pact-stub-server/releases/download/v#{STUB_SERVER_CLI_VERSION}/pact-stub-server-osx-x86_64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-stub-server.gz" + sh "chmod +x #{package_dir}/bin/pact-stub-server" + when "osx-arm64" + sh "curl -L -o #{package_dir}/bin/pact-stub-server.gz https://github.com/pact-foundation/pact-stub-server/releases/download/v#{STUB_SERVER_CLI_VERSION}/pact-stub-server-osx-aarch64.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-stub-server.gz" + sh "chmod +x #{package_dir}/bin/pact-stub-server" + when "windows-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-stub-server.exe.gz https://github.com/pact-foundation/pact-stub-server/releases/download/v#{STUB_SERVER_CLI_VERSION}/pact-stub-server-windows-x86_64.exe.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-stub-server.exe.gz" + sh "chmod +x #{package_dir}/bin/pact-stub-server.exe" + end +end \ No newline at end of file