diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74b9f6d6..4fd2d421 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,7 @@ jobs: matrix: os: ["windows-latest","ubuntu-latest","macos-latest"] shell: ["sh","bash"] + pact_cli_legacy: ["", "1"] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v5 @@ -48,3 +49,5 @@ jobs: uses: actions/download-artifact@v4 - name: test ${{ matrix.os }} package run: ./script/unpack-and-test.sh + env: + PACT_CLI_LEGACY: ${{ matrix.pact_cli_legacy }} diff --git a/README.md b/README.md index a02ff41c..ddf9e936 100644 --- a/README.md +++ b/README.md @@ -4,57 +4,62 @@ Creates a standalone pact command line executable containing -- The rust pact implementation via cargo executables +- The rust pact implementation via a single executable - The ruby pact implementation via Traveling Ruby ## Package contents This version (2.5.5) of the Pact standalone executables package contains: + * [pact-cli](https://github.com/you54f/pact-cli) + * [pact-broker-cli](https://github.com/pact-foundation/pact-broker-cli) + * [pact-plugin-cli](https://github.com/pact-foundation/pact-plugins/tree/main/cli) + * [pact_mock_server_cli](https://github.com/pact-foundation/pact-core-mock-server/tree/main/pact_mock_server_cli) + * [pact_verifier_cli](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli) + * [pact-stub-server](https://github.com/pact-foundation/pact-stub-server) * pact gem 1.67.2 * pact-mock_service gem 3.12.3 * pact-support gem 1.21.2 * pact-provider-verifier gem 1.39.1 * pact_broker-client gem 1.77.0 * pact-message gem 0.11.1 - * [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`: ``` ./pact/bin/ -├── pact (central entry point to all binaries) -├── pact-broker -├── pactflow -├── pact_mock_server_cli -├── pact-stub-server -├── pact_verifier_cli -├── pact-plugin-cli -├── pact-message (legacy) -├── pact-mock-service (legacy) -├── pact-provider-verifier (legacy) -└── pact-stub-service (legacy) +├── pact +├── pact-broker (legacy) - use `pact broker` +├── pactflow (legacy) - use `pact pactflow` +├── pact-message (legacy) - use `pact mock` (consumer) / `pact verifier` (provider) +├── pact-mock-service (legacy) - use `pact mock` +├── pact-provider-verifier (legacy) - use `pact verifier` +└── pact-stub-service (legacy) - use `pact stub` ``` -### Windows Users +Note: from `v2.6.0+`, the legacy commands will redirect to the new cli executables built in rust. -Please append `.bat` to any of the provided ruby-based binaries +Existing behaviour can be preserved by setting the `PACT_CLI_LEGACY` environment variable. -eg. +In `v3.0.0`, the ruby runtime will be removed completely, and all commands will link to the rust executables. -```ps1 - .\pact\bin\pact-broker.bat -``` +Longer term, this package is likely to be deprecated, replaced with a single `pact` cli executable. -Please append `.exe` to any of the provided rust based binaries +### Windows Users + +Please append `.bat` to any of the provided ruby-based binaries eg. +├── pact-broker (legacy) +├── pactflow (legacy) +├── pact-message (legacy) +├── pact-mock-service (legacy) +├── pact-provider-verifier (legacy) +└── pact-stub-service + ```ps1 - .\pact\bin\pact_mock_server_cli.exe + .\pact\bin\pact-broker.bat ``` ## Installation @@ -75,51 +80,62 @@ Ruby is not required on the host platform, Ruby 3.3.9 is provided in the distrib | Linux | 3.3.9 | aarch64 (arm64)| ✅ | | Windows| 3.3.9 | x86_64 | ✅ | | Windows| 3.3.9 | aarch64 (arm64)| 🚧 | +| Windows| N/A. | aarch64 (arm64)| ✅ | 🚧 - Tested under emulation mode x86_64 in Windows on ARM +Windows-arm64 package supports rust based executables only and does not provide an arm64 runtime currently. + +To use ruby packages on windows on arm, please use the x86_64 package. + ## Usage ### pact-mock-service ``` -Commands: - pact-mock-service control # Run a Pact mock service control s... - pact-mock-service control-restart # Start a Pact mock service control... - pact-mock-service control-start # Start a Pact mock service control... - pact-mock-service control-stop # Stop a Pact mock service control ... - pact-mock-service help [COMMAND] # Describe available commands or on... - pact-mock-service restart # Start or restart a mock service. ... - pact-mock-service service # Start a mock service. If the cons... - pact-mock-service start # Start a mock service. If the cons... - pact-mock-service stop -p, --port=PORT # Stop a Pact mock service - pact-mock-service version # Show the pact-mock-service gem version +Standalone Pact mock server -Usage: - pact-mock-service service +Usage: pact mock [OPTIONS] [COMMAND] + +Commands: + start Starts the master mock server + list Lists all the running mock servers + create Creates a new mock server from a pact file + verify Verify the mock server by id or port number, and generate a pact file if all ok + shutdown Shutdown the mock server by id or port number, releasing all its resources + shutdown-master Performs a graceful shutdown of the master server (displayed when it started) + help Print this message or the help of the given subcommand(s) Options: - [--consumer=CONSUMER] # Consumer name - [--provider=PROVIDER] # Provider name - -p, [--port=PORT] # Port on which to run the service - -h, [--host=HOST] # Host on which to bind the service - # Default: localhost - -d, [--pact-dir=PACT_DIR] # Directory to which the pacts will be written - -m, [--pact-file-write-mode=PACT_FILE_WRITE_MODE] # `overwrite` or `merge`. Use `merge` when running multiple mock service instances in parallel for the same consumer/provider pair. Ensure the pact file is deleted before running tests when using this option so that interactions deleted from the code are not maintained in the file. - # Default: overwrite - -i, [--pact-specification-version=PACT_SPECIFICATION_VERSION] # The pact specification version to use when writing the pact. Note that only versions 1 and 2 are currently supported. - # Default: 2 - -l, [--log=LOG] # File to which to log output - [--log-level=LOG_LEVEL] # Log level. Options are DEBUG INFO WARN ERROR - # Default: DEBUG - -o, [--cors=CORS] # Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses - [--ssl], [--no-ssl], [--skip-ssl] # Use a self-signed SSL cert to run the service over HTTPS - # Default: false - [--sslcert=SSLCERT] # Specify the path to the SSL cert to use when running the service over HTTPS - [--sslkey=SSLKEY] # Specify the path to the SSL key to use when running the service over HTTPS - -Start a mock service. If the consumer, provider and pact-dir options are provided, the pact will be written automatically on shutdown (INT). + --enable-otel + Enable OpenTelemetry tracing + --help + Print help and exit + --enable-otel-logs + Enable OpenTelemetry logging + -v, --version + Print version information and exit + --enable-otel-traces + Enable OpenTelemetry traces + -p, --port + port the master mock server runs on (defaults to 8080) + -h, --host + hostname the master mock server runs on (defaults to localhost) + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + -l, --loglevel + Log level for mock servers to write to the log file (defaults to info) [possible values: error, warn, info, debug, trace, none] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --no-term-log + Turns off using terminal ANSI escape codes + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --no-file-log + Do not log to an output file + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] ``` @@ -127,108 +143,185 @@ Start a mock service. If the consumer, provider and pact-dir options are provide ### pact-stub-service ``` -Usage: - pact-stub-service PACT_URI ... +Pact Stub Server 0.6.3 + +Usage: pact stub [OPTIONS] Options: - -p, [--port=PORT] # Port on which to run the service - -h, [--host=HOST] # Host on which to bind the service - # Default: localhost - -l, [--log=LOG] # File to which to log output - -n, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username - -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password - -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token (can also be set using the PACT_BROKER_TOKEN environment variable) - [--log-level=LOG_LEVEL] # Log level. Options are DEBUG INFO WARN ERROR - # Default: DEBUG - -o, [--cors=CORS] # Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses - [--ssl], [--no-ssl], [--skip-ssl] # Use a self-signed SSL cert to run the service over HTTPS - # Default: false - [--sslcert=SSLCERT] # Specify the path to the SSL cert to use when running the service over HTTPS - [--sslkey=SSLKEY] # Specify the path to the SSL key to use when running the service over HTTPS - -Description: - Start a stub service with the given pact file(s) or directories. Pact URIs - may be local file or directory paths, or HTTP. Include any basic auth details - in the URL using the format https://USERNAME:PASSWORD@URI. Where multiple - matching interactions are found, the interactions will be sorted by response - status, and the first one will be returned. This may lead to some - non-deterministic behaviour. If you are having problems with this, please - raise it on the pact-dev google group, and we can discuss some potential - enhancements. Note that only versions 1 and 2 of the pact specification are - currently fully supported. Pacts using the v3 format may be used, however, - any matching features added in v3 will currently be ignored. + --enable-otel + Enable OpenTelemetry tracing + -l, --loglevel + Log level (defaults to info) [default: info] [possible values: error, warn, info, debug, trace, none] + --enable-otel-logs + Enable OpenTelemetry logging + -f, --file + Pact file to load (can be repeated) + -d, --dir + Directory of pact files to load (can be repeated) + --enable-otel-traces + Enable OpenTelemetry traces + -e, --extension + File extension to use when loading from a directory (default is json) + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + -u, --url + URL of pact file to fetch (can be repeated) + -b, --broker-url + URL of the pact broker to fetch pacts from [env: PACT_BROKER_BASE_URL=] + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --user + User and password to use when fetching pacts from URLS or Pact Broker in user:password form + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + -t, --token + Bearer token to use when fetching pacts from URLS or Pact Broker + -p, --port + Port to run on (defaults to random port assigned by the OS) + -o, --cors + Automatically respond to OPTIONS requests and return default CORS headers + --cors-referer + Set the CORS Access-Control-Allow-Origin header to the Referer + --insecure-tls + Disables TLS certificate validation + -s, --provider-state + Provider state regular expression to filter the responses by + --provider-state-header-name + Name of the header parameter containing the provider state to be used in case multiple matching interactions are found + --empty-provider-state + Include empty provider states when filtering with --provider-state + --consumer-name + Consumer name or regex to use to filter the Pacts fetched from the Pact broker (can be repeated) + --provider-name + Provider name or regex to use to filter the Pacts fetched from the Pact broker (can be repeated) + -v, --version + Print version information + -h, --help + Print help ``` ### pact-provider-verifier -To connect to a Pact Broker that uses custom SSL cerificates, set the environment variable `$SSL_CERT_FILE` or `$SSL_CERT_DIR` to a path that contains the appropriate certificate. - ``` -Usage: - pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL +Standalone pact verifier for provider pact verification -Options: - -h, --provider-base-url=PROVIDER_BASE_URL # Provider host URL - -c, [--provider-states-setup-url=PROVIDER_STATES_SETUP_URL] # Base URL to setup the provider states at - [--pact-broker-base-url=PACT_BROKER_BASE_URL] # Base URL of the Pact Broker from which to retrieve the pacts. Can also be set using the environment variable PACT_BROKER_BASE_URL. - -n, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username. Can also be set using the environment variable PACT_BROKER_USERNAME. - -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password. Can also be set using the environment variable PACT_BROKER_PASSWORD. - -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token. Can also be set using the environment variable PACT_BROKER_TOKEN. - [--provider=PROVIDER] - [--consumer-version-tag=TAG] # Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times. - [--provider-version-tag=TAG] # Tag to apply to the provider application version. May be specified multiple times. - [--provider-version-branch=BRANCH] # The name of the branch the provider version belongs to. - -g, [--tag-with-git-branch], [--no-tag-with-git-branch], [--skip-tag-with-git-branch] # Tag provider version with the name of the current git branch. Default: false - # Default: false - -a, [--provider-app-version=PROVIDER_APP_VERSION] # Provider application version, required when publishing verification results - -r, [--publish-verification-results], [--no-publish-verification-results], [--skip-publish-verification-results] # Publish verification results to the broker. This can also be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true - # Default: false - [--enable-pending], [--no-enable-pending], [--skip-enable-pending] # Allow pacts which are in pending state to be verified without causing the overall task to fail. For more information, see https://pact.io/pending - # Default: false - [--custom-provider-header=CUSTOM_PROVIDER_HEADER] # Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times. - [--custom-middleware=FILE] # Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution! - -v, [--verbose=VERBOSE] # Verbose output. Can also be set by setting the environment variable VERBOSE=true. - -f, [--format=FORMATTER] # RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml). - -o, [--out=FILE] # Write output to a file instead of $stdout. - [--wait=SECONDS] # The number of seconds to poll for the provider to become available before running the verification - # Default: 0 - [--log-dir=LOG_DIR] # The directory for the pact.log file - [--log-level=LOG_LEVEL] # The log level - # Default: debug - [--fail-if-no-pacts-found], [--no-fail-if-no-pacts-found], [--skip-fail-if-no-pacts-found] # If specified, will fail when no pacts are found - # Default: false - -Description: - The parameters used when fetching pacts dynamically from a Pact Broker are: - - --pact-broker-base-url (REQUIRED) - --provider (REQUIRED) - --broker-username/--broker-password or --broker-token - --consumer-version-tag or --consumer-version-selector - --enable-pending - --include-wip-pacts-since - - To - verify a pact at a known URL (eg. when a verification is triggered by a - 'contract content changed' webhook), pass in the pact URL(s) as the first - argument(s) to the command, and do NOT set any of the other parameters apart - from the base URL and credentials. - - To publish verification results for either of the above - scenarios, set: - - --publish-verification-results (REQUIRED) - --provider-app-version (REQUIRED) - --provider-version-tag or --tag-with-git-branch - - - Selectors: These are specified using JSON strings. - The keys are 'tag' (the name of the consumer version tag), 'latest' - (true|false), 'consumer', and 'fallbackTag'. For example '{\"tag\": - \"master\", \"latest\": true}'. For a detailed explanation of selectors, see https://pact.io/selectors#consumer-version-selectors +Usage: pact verifier [OPTIONS] +Options: + --enable-otel + Enable OpenTelemetry tracing + --help + Print help and exit + --enable-otel-logs + Enable OpenTelemetry logging + -v, --version + Print version information and exit + --enable-otel-traces + Enable OpenTelemetry traces + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + +Logging options: + -l, --loglevel Log level to emit log events at (defaults to warn) [possible values: error, warn, info, debug, trace, none] + --pretty-log Emits excessively pretty, multi-line logs, optimized for human readability. + --full-log This emits human-readable, single-line logs for each event that occurs, with the current span context displayed before the formatted representation of the event. + --compact-log Emit logs optimized for short line lengths. + -j, --json Generate a JSON report of the verification [env: PACT_VERIFIER_JSON_REPORT=] + -x, --junit Generate a JUnit XML report of the verification (requires the junit feature) [env: PACT_VERIFIER_JUNIT_REPORT=] + --no-colour Disables ANSI escape codes in the output [aliases: --no-color] + +Loading pacts options: + -f, --file + Pact file to verify (can be repeated) + -d, --dir + Directory of pact files to verify (can be repeated) + -u, --url + URL of pact file to verify (can be repeated) + -b, --broker-url + URL of the pact broker to fetch pacts from to verify (requires the provider name parameter) [env: PACT_BROKER_BASE_URL=] + --webhook-callback-url + URL of a Pact to verify via a webhook callback. Requires the broker-url to be set. [env: PACT_WEBHOOK_CALLBACK_URL=] + --ignore-no-pacts-error + Do not fail if no pacts are found to verify + +Authentication options: + --user Username to use when fetching pacts from URLS [env: PACT_BROKER_USERNAME=] + --password Password to use when fetching pacts from URLS [env: PACT_BROKER_PASSWORD=] + -t, --token Bearer token to use when fetching pacts from URLS [env: PACT_BROKER_TOKEN=] + +Provider options: + -h, --hostname + Provider hostname (defaults to localhost) [env: PACT_PROVIDER_HOSTNAME=] + -p, --port + Provider port (defaults to protocol default 80/443) [env: PACT_PROVIDER_PORT=] + --transport + Provider protocol transport to use (http, https, grpc, etc.) [env: PACT_PROVIDER_TRANSPORT=] [default: http] + --transports + Allows multiple protocol transports to be configured (http, https, grpc, etc.) with their associated port numbers separated by a colon. For example, use --transports http:8080 grpc:5555 to configure both. + -n, --provider-name + Provider name (defaults to provider) [env: PACT_PROVIDER_NAME=] + --base-path + Base path to add to all requests [env: PACT_PROVIDER_BASE_PATH=] + --request-timeout + Sets the HTTP request timeout in milliseconds for requests to the target API and for state change requests. [env: PACT_PROVIDER_REQUEST_TIMEOUT=] + -H, --header + Add a custom header to be included in the calls to the provider. Values must be in the form KEY=VALUE, where KEY and VALUE contain ASCII characters (32-127) only. Can be repeated. + --disable-ssl-verification + Disables validation of SSL certificates + +Provider state options: + -s, --state-change-url + URL to post state change requests to [env: PACT_PROVIDER_STATE_CHANGE_URL=] + --state-change-as-query + State change request data will be sent as query parameters instead of in the request body [env: PACT_PROVIDER_STATE_CHANGE_AS_QUERY=] + --state-change-teardown + State change teardown requests are to be made after each interaction [env: PACT_PROVIDER_STATE_CHANGE_TEARDOWN=] + +Filtering interactions: + --filter-description + Only validate interactions whose descriptions match this filter (regex format) [env: PACT_DESCRIPTION=] + --filter-state + Only validate interactions whose provider states match this filter (regex format) [env: PACT_PROVIDER_STATE=] + --filter-no-state + Only validate interactions that have no defined provider state [env: PACT_PROVIDER_NO_STATE=] + -c, --filter-consumer + Consumer name to filter the pacts to be verified (can be repeated) + +Publishing options: + --publish + Enables publishing of verification results back to the Pact Broker. Requires the broker-url and provider-version parameters. + --provider-version + Provider version that is being verified. This is required when publishing results. + --build-url + URL of the build to associate with the published verification results. + --provider-tags + Provider tags to use when publishing results. Accepts comma-separated values. + --provider-branch + Provider branch to use when publishing results + +Pact Broker options: + --consumer-version-tags + Consumer tags to use when fetching pacts from the Broker. Accepts comma-separated values. + --consumer-version-selectors + Consumer version selectors to use when fetching pacts from the Broker. Accepts a JSON string as per https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/. Can be repeated. + --enable-pending + Enables Pending Pacts + --include-wip-pacts-since + Allow pacts that don't match given consumer selectors (or tags) to be verified, without causing the overall task to fail. For more information, see https://pact.io/wip + +Development options: + --exit-on-first-error Stops the verifier at the first failure + --last-failed Only runs the interactions that failed on the previous verifier run. Requires --json-file to have been set ``` @@ -240,127 +333,309 @@ To connect to a Pact Broker that uses custom SSL cerificates, set the environmen #### publish ``` -Usage: - pact-broker publish PACT_DIRS_OR_FILES ... -b, --broker-base-url=BROKER_BASE_URL +Publishes pacts to the Pact Broker + +Usage: pact broker publish [OPTIONS] --broker-base-url ... + +Arguments: + ... + + Glob pattern to match pact files to publish + + ? matches any single character. + * matches any (possibly empty) sequence of characters. + ** matches the current directory and arbitrary subdirectories. This sequence must form + a single path component, so both **a and b** are invalid and will result in an + error. A sequence of more than two consecutive * characters is also invalid. + [...] matches any character inside the brackets. Character sequences can also specify + ranges of characters, as ordered by Unicode, so e.g. [0-9] specifies any character + between 0 and 9 inclusive. An unclosed bracket is invalid. + [!...] is the negation of [...], i.e. it matches any characters not in the brackets. + + The metacharacters ?, *, [, ] can be matched by using brackets (e.g. [?]). When a ] + occurs immediately following [ or [! then it is interpreted as being part of, rather + then ending, the character set, so ] and NOT ] can be matched by []] and [!]] respectively. + The - character can be specified inside a character sequence pattern by placing it at + the start or the end, e.g. [abc-]. + + See https://docs.rs/glob/0.3.0/glob/struct.Pattern.html Options: - -a, [--consumer-app-version=CONSUMER_APP_VERSION] # The consumer application version - -h, [--branch=BRANCH] # Repository branch of the consumer version - -r, [--auto-detect-version-properties], [--no-auto-detect-version-properties], [--skip-auto-detect-version-properties] # Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. - # Default: false - -t, [--tag=TAG] # Tag name for consumer version. Can be specified multiple times. - -g, [--tag-with-git-branch], [--no-tag-with-git-branch], [--skip-tag-with-git-branch] # Tag consumer version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. - # Default: false - [--build-url=BUILD_URL] # The build URL that created the pact - [--merge], [--no-merge], [--skip-merge] # If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes. - # Default: false - -o, [--output=OUTPUT] # json or text - # Default: text - -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker - -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username - -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password - -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token - -v, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output. - # Default: false - -Publish pacts to a Pact Broker. - + -b, --broker-base-url + The base URL of the Pact Broker + + [env: PACT_BROKER_BASE_URL=] + + --enable-otel + Enable OpenTelemetry tracing + + --enable-otel-logs + Enable OpenTelemetry logging + + -u, --broker-username + Pact Broker basic auth username + + [env: PACT_BROKER_USERNAME=] + + --enable-otel-traces + Enable OpenTelemetry traces + + -p, --broker-password + Pact Broker basic auth password + + [env: PACT_BROKER_PASSWORD=] + + -k, --broker-token + Pact Broker bearer token + + [env: PACT_BROKER_TOKEN=] + + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) + + [env: OTEL_TRACES_EXPORTER=] + + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) + + [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + + --validate + Validate the Pact files before publishing. + + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + [possible values: http, http/protobuf] + + --strict + Require strict validation. + + -a, --consumer-app-version + The consumer application version + + --branch + Repository branch of the consumer version + + --log-level + Set the log level (none, off, error, warn, info, debug, trace) + + [default: off] + [possible values: off, none, error, warn, info, debug, trace] + + -r, --auto-detect-version-properties + Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + + -t, --tag [...] + Tag name for consumer version. Can be specified multiple times (delimiter ,). + + --tag-with-git-branch + Tag consumer version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + + --build-url + The build URL that created the pact + + --merge + If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes. + + -o, --output + Value must be one of ["json", "text", "pretty"] + + [default: text] + [possible values: json, text, pretty] + + -c, --ssl-certificate + The path to a valid SSL certificate file + + [env: SSL_CERT_FILE=] + + --skip-ssl-verification + Skip SSL certificate verification + + [env: SSL_SKIP_VERIFICATION=] + + --ssl-trust-store + Use the system's root trust store for SSL verification + + [env: SSL_TRUST_STORE=] + [default: true] + [possible values: true, false] + + -h, --help + Print help (see a summary with '-h') ``` #### can-i-deploy ``` -Usage: - pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL +Usage: pact broker can-i-deploy [OPTIONS] --pacticipant --broker-base-url Options: - -a, --pacticipant=PACTICIPANT # The pacticipant name. Use once for each pacticipant being checked. - -e, [--version=VERSION] # The pacticipant version. Must be entered after the --pacticipant that it relates to. - [--ignore=PACTICIPANT] # The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary. - -l, [--latest=[TAG]] # Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag. - [--branch=BRANCH] # The branch of the version for which you want to check the verification results. - [--main-branch], [--no-main-branch], [--skip-main-branch] # Use the latest version of the configured main branch of the pacticipant as the version for which you want to check the verification results - # Default: false - [--to-environment=ENVIRONMENT] # The environment into which the pacticipant(s) are to be deployed - [--to=TAG] # The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status. - -o, [--output=OUTPUT] # json or table - # Default: table - [--retry-while-unknown=TIMES] # The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running) - # Default: 0 - [--retry-interval=SECONDS] # The time between retries in seconds. Use in conjuction with --retry-while-unknown - # Default: 10 - [--dry-run], [--no-dry-run], [--skip-dry-run] # When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when setting up your CI/CD pipeline for the first time, or in a 'break glass' situation where you need to knowingly deploy what Pact considers a breaking change. For the second scenario, it is recommended to use the environment variable and just set it for the build required to deploy that particular version, so you don't accidentally leave the dry run mode enabled. - # Default: false - -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker - -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username - -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password - -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token - -v, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output. - # Default: false - -Description: - Returns exit code 0 or 1, indicating whether or not the specified application - (pacticipant) has a successful verification result with each of the - application versions that are already deployed to a particular environment. - Prints out the relevant pact/verification details, indicating any missing or - failed verification results. - - The can-i-deploy tool was originally written to support specifying versions - and dependencies using tags. This usage has now been superseded by first - class support for environments, deployments and releases. For documentation - on how to use can-i-deploy with tags, please see - https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/ - - Before `can-i-deploy` can be used, the relevant environment resources must - first be created in the Pact Broker using the `create-environment` command. - The "test" and "production" environments will have been seeded for you. You - can check the existing environments by running `pact-broker - list-environments`. See - https://docs.pact.io/pact_broker/client_cli/readme#environments for more - information. - - $ pact-broker create-environment --name "uat" --display-name "UAT" - --no-production - - After an application is deployed or released, its deployment must be recorded - using the `record-deployment` or `record-release` commands. See - https://docs.pact.io/pact_broker/recording_deployments_and_releases/ for more - information. - - $ pact-broker record-deployment --pacticipant Foo --version 173153ae0 - --environment uat - - Before an application is deployed or released to an environment, the - can-i-deploy command must be run to check that the application version is - safe to deploy with the versions of each integrated application that are - already in that environment. - - $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION - --to-environment ENVIRONMENT - - Example: can I deploy version 173153ae0 of application Foo to the test - environment? - - $ pact-broker can-i-deploy --pacticipant Foo --version 173153ae0 - --to-environment test - - Can-i-deploy can also be used to check if arbitrary versions have a - successful verification. When asking "Can I deploy this application version - with the latest version from the main branch of another application" it - functions as a "can I merge" check. - - $ pact-broker can-i-deploy --pacticipant Foo 173153ae0 \ --pacticipant Bar - --latest main - - ##### Polling - - If the verification process takes a long time and there are results missing - when the can-i-deploy command runs in your CI/CD pipeline, you can configure - the command to poll and wait for the missing results to arrive. The arguments - to specify are `--retry-while-unknown TIMES` and `--retry-interval SECONDS`, - set to appropriate values for your pipeline. + -a, --pacticipant + The pacticipant name. Use once for each pacticipant being checked. The following options (--version, --latest, --tag, --branch, --main-branch, --no-main-branch, --skip-main-branch) must come after each --pacticipant. + + --enable-otel + Enable OpenTelemetry tracing + + -e, --version + The pacticipant version. Must be entered after the --pacticipant that it relates to. + + --enable-otel-logs + Enable OpenTelemetry logging + + --enable-otel-traces + Enable OpenTelemetry traces + + -l, --latest [] + Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag. Must be entered after the --pacticipant that it relates to. + + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) + + [env: OTEL_TRACES_EXPORTER=] + + --tag + The tag of the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --branch + The branch of the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) + + [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + + --main-branch + Use the latest version of the configured main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + [possible values: http, http/protobuf] + + --no-main-branch + Do not use the main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --log-level + Set the log level (none, off, error, warn, info, debug, trace) + + [default: off] + [possible values: off, none, error, warn, info, debug, trace] + + --skip-main-branch + Skip the configured main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --ignore + The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary. + + --to-environment + The environment into which the pacticipant(s) are to be deployed + + --to + The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status. + + -o, --output + Value must be one of ["json", "table"] + + [default: table] + [possible values: json, table] + + --retry-while-unknown + The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running) + + --retry-interval + The time between retries in seconds. Use in conjuction with --retry-while-unknown + + --dry-run + When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when setting up your CI/CD pipeline for the first time, or in a 'break glass' situation where you need to knowingly deploy what Pact considers a breaking change. For the second scenario, it is recommended to use the environment variable and just set it for the build required to deploy that particular version, so you don't accidentally leave the dry run mode enabled. + + -b, --broker-base-url + The base URL of the Pact Broker + + [env: PACT_BROKER_BASE_URL=] + -u, --broker-username + Pact Broker basic auth username + + [env: PACT_BROKER_USERNAME=] + + -p, --broker-password + Pact Broker basic auth password + + [env: PACT_BROKER_PASSWORD=] + + -k, --broker-token + Pact Broker bearer token + + [env: PACT_BROKER_TOKEN=] + + -c, --ssl-certificate + The path to a valid SSL certificate file + + [env: SSL_CERT_FILE=] + + --skip-ssl-verification + Skip SSL certificate verification + + [env: SSL_SKIP_VERIFICATION=] + + --ssl-trust-store + Use the system's root trust store for SSL verification + + [env: SSL_TRUST_STORE=] + [default: true] + [possible values: true, false] + + -h, --help + Print help (see a summary with '-h') + + Check if a pacticipant can be deployed. + + Description: + Returns exit code 0 or 1, indicating whether or not the specified application (pacticipant) has a successful verification result with + each of the application versions that are already deployed to a particular environment. Prints out the relevant pact/verification + details, indicating any missing or failed verification results. + + The can-i-deploy tool was originally written to support specifying versions and dependencies using tags. This usage has now been + superseded by first class support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, + please see https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/ + + Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the + `create-environment` command. The 'test' and 'production' environments will have been seeded for you. You can check the existing + environments by running `pact broker list-environments`. See https://docs.pact.io/pact_broker/client_cli/readme#environments for more + information. + + $ pact broker create-environment --name 'uat' --display-name 'UAT' --no-production + + After an application is deployed or released, its deployment must be recorded using the `record-deployment` or `record-release` + commands. See https://docs.pact.io/pact_broker/recording_deployments_and_releases/ for more information. + + $ pact broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat + + Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application + version is safe to deploy with the versions of each integrated application that are already in that environment. + + $ pact broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT + + Example: can I deploy version 173153ae0 of application Foo to the test environment? + + $ pact broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test + + Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking 'Can I deploy this + application version with the latest version from the main branch of another application' it functions as a 'can I merge' check. + + $ pact broker can-i-deploy --pacticipant Foo 173153ae0 \\ --pacticipant Bar --latest main + + ##### Polling + + If the verification process takes a long time and there are results missing when the can-i-deploy command runs in your CI/CD pipeline, + you can configure the command to poll and wait for the missing results to arrive. The arguments to specify are `--retry-while-unknown + TIMES` and `--retry-interval SECONDS`, set to appropriate values for your pipeline. ``` @@ -371,35 +646,80 @@ Description: #### publish-provider-contract ``` -Usage: - pactflow publish-provider-contract CONTRACT_FILE ... --provider=PROVIDER -a, --provider-app-version=PROVIDER_APP_VERSION -b, --broker-base-url=BROKER_BASE_URL +Publish provider contract to PactFlow -Options: - --provider=PROVIDER # The provider name - -a, --provider-app-version=PROVIDER_APP_VERSION # The provider application version - -h, [--branch=BRANCH] # Repository branch of the provider version - -t, [--tag=TAG] # Tag name for provider version. Can be specified multiple times. - [--specification=SPECIFICATION] # The contract specification - # Default: oas - [--content-type=CONTENT_TYPE] # The content type. eg. application/yml - [--verification-success], [--no-verification-success], [--skip-verification-success] # Whether or not the self verification passed successfully. - [--verification-exit-code=N] # The exit code of the verification process. Can be used instead of --verification-success|--no-verification-success for a simpler build script. - [--verification-results=VERIFICATION_RESULTS] # The path to the file containing the output from the verification process - [--verification-results-content-type=VERIFICATION_RESULTS_CONTENT_TYPE] # The content type of the verification output eg. text/plain, application/yaml - [--verification-results-format=VERIFICATION_RESULTS_FORMAT] # The format of the verification output eg. junit, text - [--verifier=VERIFIER] # The tool used to verify the provider contract - [--verifier-version=VERIFIER_VERSION] # The version of the tool used to verify the provider contract - [--build-url=BUILD_URL] # The build URL that created the provider contract - -o, [--output=OUTPUT] # json or text - # Default: text - -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker - -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username - -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password - -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token - -v, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output. - # Default: false +Usage: pact pactflow publish-provider-contract [OPTIONS] --broker-base-url --provider -Publish provider contract to PactFlow +Arguments: + The contract file to publish + +Options: + -b, --broker-base-url + The base URL of the Pact Broker [env: PACT_BROKER_BASE_URL=] + --enable-otel + Enable OpenTelemetry tracing + --enable-otel-logs + Enable OpenTelemetry logging + -u, --broker-username + Pact Broker basic auth username [env: PACT_BROKER_USERNAME=] + --enable-otel-traces + Enable OpenTelemetry traces + -p, --broker-password + Pact Broker basic auth password [env: PACT_BROKER_PASSWORD=] + -k, --broker-token + Pact Broker bearer token [env: PACT_BROKER_TOKEN=] + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --provider + The provider name + -a, --provider-app-version + The provider application version + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --branch + Repository branch of the provider version + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + -t, --tag [...] + Tag name for provider version. Can be specified multiple times (delimiter ,). + --specification + The contract specification [default: oas] + --content-type + The content type. eg. application/yml + --verification-success + Whether or not the self verification passed successfully. + --no-verification-success + Whether or not the self verification failed. + --verification-exit-code + The exit code of the verification process. Can be used instead of --verification-success|--no-verification-success for a simpler build script. + --verification-results + The path to the file containing the output from the verification process + --verification-results-content-type + The content type of the verification output eg. text/plain, application/yaml + --verification-results-format + The format of the verification output eg. junit, text + --verifier + The tool used to verify the provider contract + --verifier-version + The version of the tool used to verify the provider contract + --build-url + The build URL that created the provider contract + -r, --auto-detect-version-properties + Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + --tag-with-git-branch + Tag provider version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + -o, --output + Value must be one of ["json", "text"] [default: text] [possible values: json, text] + -c, --ssl-certificate + The path to a valid SSL certificate file [env: SSL_CERT_FILE=] + --skip-ssl-verification + Skip SSL certificate verification [env: SSL_SKIP_VERIFICATION=] + --ssl-trust-store + Use the system's root trust store for SSL verification [env: SSL_TRUST_STORE=] [default: true] [possible values: true, false] + -h, --help + Print help ``` diff --git a/install.sh b/install.sh index 5dd20186..91dc3260 100755 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ echo "pact-standalone ${PACT_CLI_VERSION} installed to $(pwd)/pact" echo "-------------------" echo "available commands:" echo "-------------------" -PROJECT_NAME=pact-cli +PROJECT_NAME=pact PACT_CLI_BIN_PATH=${PWD}/pact/bin/ ls -1 "$PACT_CLI_BIN_PATH" diff --git a/packaging/README.md.template b/packaging/README.md.template index 107dda9c..5eec4843 100644 --- a/packaging/README.md.template +++ b/packaging/README.md.template @@ -4,57 +4,62 @@ Creates a standalone pact command line executable containing -- The rust pact implementation via cargo executables +- The rust pact implementation via a single executable - The ruby pact implementation via Traveling Ruby ## Package contents This version (<%= ENV.fetch('VERSION') %>) of the Pact standalone executables package contains: + * [pact-cli](https://github.com/you54f/pact-cli) + * [pact-broker-cli](https://github.com/pact-foundation/pact-broker-cli) + * [pact-plugin-cli](https://github.com/pact-foundation/pact-plugins/tree/main/cli) + * [pact_mock_server_cli](https://github.com/pact-foundation/pact-core-mock-server/tree/main/pact_mock_server_cli) + * [pact_verifier_cli](https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli) + * [pact-stub-server](https://github.com/pact-foundation/pact-stub-server) * pact gem <%= Pact::VERSION %> * pact-mock_service gem <%= Pact::MockService::VERSION %> * pact-support gem <%= Pact::Support::VERSION %> * 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`: ``` ./pact/bin/ -├── pact (central entry point to all binaries) -├── pact-broker -├── pactflow -├── pact_mock_server_cli -├── pact-stub-server -├── pact_verifier_cli -├── pact-plugin-cli -├── pact-message (legacy) -├── pact-mock-service (legacy) -├── pact-provider-verifier (legacy) -└── pact-stub-service (legacy) +├── pact +├── pact-broker (legacy) - use `pact broker` +├── pactflow (legacy) - use `pact pactflow` +├── pact-message (legacy) - use `pact mock` (consumer) / `pact verifier` (provider) +├── pact-mock-service (legacy) - use `pact mock` +├── pact-provider-verifier (legacy) - use `pact verifier` +└── pact-stub-service (legacy) - use `pact stub` ``` -### Windows Users +Note: from `v2.6.0+`, the legacy commands will redirect to the new cli executables built in rust. -Please append `.bat` to any of the provided ruby-based binaries +Existing behaviour can be preserved by setting the `PACT_CLI_LEGACY` environment variable. -eg. +In `v3.0.0`, the ruby runtime will be removed completely, and all commands will link to the rust executables. -```ps1 - .\pact\bin\pact-broker.bat -``` +Longer term, this package is likely to be deprecated, replaced with a single `pact` cli executable. -Please append `.exe` to any of the provided rust based binaries +### Windows Users + +Please append `.bat` to any of the provided ruby-based binaries eg. +├── pact-broker (legacy) +├── pactflow (legacy) +├── pact-message (legacy) +├── pact-mock-service (legacy) +├── pact-provider-verifier (legacy) +└── pact-stub-service + ```ps1 - .\pact\bin\pact_mock_server_cli.exe + .\pact\bin\pact-broker.bat ``` ## Installation @@ -75,32 +80,248 @@ Ruby is not required on the host platform, Ruby 3.3.9 is provided in the distrib | Linux | 3.3.9 | aarch64 (arm64)| ✅ | | Windows| 3.3.9 | x86_64 | ✅ | | Windows| 3.3.9 | aarch64 (arm64)| 🚧 | +| Windows| N/A. | aarch64 (arm64)| ✅ | 🚧 - Tested under emulation mode x86_64 in Windows on ARM +Windows-arm64 package supports rust based executables only and does not provide an arm64 runtime currently. + +To use ruby packages on windows on arm, please use the x86_64 package. + ## Usage ### pact-mock-service ``` -<%= pact_mock_service_usage %> +Standalone Pact mock server + +Usage: pact mock [OPTIONS] [COMMAND] + +Commands: + start Starts the master mock server + list Lists all the running mock servers + create Creates a new mock server from a pact file + verify Verify the mock server by id or port number, and generate a pact file if all ok + shutdown Shutdown the mock server by id or port number, releasing all its resources + shutdown-master Performs a graceful shutdown of the master server (displayed when it started) + help Print this message or the help of the given subcommand(s) + +Options: + --enable-otel + Enable OpenTelemetry tracing + --help + Print help and exit + --enable-otel-logs + Enable OpenTelemetry logging + -v, --version + Print version information and exit + --enable-otel-traces + Enable OpenTelemetry traces + -p, --port + port the master mock server runs on (defaults to 8080) + -h, --host + hostname the master mock server runs on (defaults to localhost) + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + -l, --loglevel + Log level for mock servers to write to the log file (defaults to info) [possible values: error, warn, info, debug, trace, none] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --no-term-log + Turns off using terminal ANSI escape codes + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --no-file-log + Do not log to an output file + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + ``` ### pact-stub-service ``` -<%= pact_stub_service_usage %> +Pact Stub Server 0.6.3 + +Usage: pact stub [OPTIONS] + +Options: + --enable-otel + Enable OpenTelemetry tracing + -l, --loglevel + Log level (defaults to info) [default: info] [possible values: error, warn, info, debug, trace, none] + --enable-otel-logs + Enable OpenTelemetry logging + -f, --file + Pact file to load (can be repeated) + -d, --dir + Directory of pact files to load (can be repeated) + --enable-otel-traces + Enable OpenTelemetry traces + -e, --extension + File extension to use when loading from a directory (default is json) + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + -u, --url + URL of pact file to fetch (can be repeated) + -b, --broker-url + URL of the pact broker to fetch pacts from [env: PACT_BROKER_BASE_URL=] + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --user + User and password to use when fetching pacts from URLS or Pact Broker in user:password form + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + -t, --token + Bearer token to use when fetching pacts from URLS or Pact Broker + -p, --port + Port to run on (defaults to random port assigned by the OS) + -o, --cors + Automatically respond to OPTIONS requests and return default CORS headers + --cors-referer + Set the CORS Access-Control-Allow-Origin header to the Referer + --insecure-tls + Disables TLS certificate validation + -s, --provider-state + Provider state regular expression to filter the responses by + --provider-state-header-name + Name of the header parameter containing the provider state to be used in case multiple matching interactions are found + --empty-provider-state + Include empty provider states when filtering with --provider-state + --consumer-name + Consumer name or regex to use to filter the Pacts fetched from the Pact broker (can be repeated) + --provider-name + Provider name or regex to use to filter the Pacts fetched from the Pact broker (can be repeated) + -v, --version + Print version information + -h, --help + Print help + ``` ### pact-provider-verifier -To connect to a Pact Broker that uses custom SSL cerificates, set the environment variable `$SSL_CERT_FILE` or `$SSL_CERT_DIR` to a path that contains the appropriate certificate. - ``` -<%= pact_provider_verifier_usage %> +Standalone pact verifier for provider pact verification + +Usage: pact verifier [OPTIONS] + +Options: + --enable-otel + Enable OpenTelemetry tracing + --help + Print help and exit + --enable-otel-logs + Enable OpenTelemetry logging + -v, --version + Print version information and exit + --enable-otel-traces + Enable OpenTelemetry traces + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + +Logging options: + -l, --loglevel Log level to emit log events at (defaults to warn) [possible values: error, warn, info, debug, trace, none] + --pretty-log Emits excessively pretty, multi-line logs, optimized for human readability. + --full-log This emits human-readable, single-line logs for each event that occurs, with the current span context displayed before the formatted representation of the event. + --compact-log Emit logs optimized for short line lengths. + -j, --json Generate a JSON report of the verification [env: PACT_VERIFIER_JSON_REPORT=] + -x, --junit Generate a JUnit XML report of the verification (requires the junit feature) [env: PACT_VERIFIER_JUNIT_REPORT=] + --no-colour Disables ANSI escape codes in the output [aliases: --no-color] + +Loading pacts options: + -f, --file + Pact file to verify (can be repeated) + -d, --dir + Directory of pact files to verify (can be repeated) + -u, --url + URL of pact file to verify (can be repeated) + -b, --broker-url + URL of the pact broker to fetch pacts from to verify (requires the provider name parameter) [env: PACT_BROKER_BASE_URL=] + --webhook-callback-url + URL of a Pact to verify via a webhook callback. Requires the broker-url to be set. [env: PACT_WEBHOOK_CALLBACK_URL=] + --ignore-no-pacts-error + Do not fail if no pacts are found to verify + +Authentication options: + --user Username to use when fetching pacts from URLS [env: PACT_BROKER_USERNAME=] + --password Password to use when fetching pacts from URLS [env: PACT_BROKER_PASSWORD=] + -t, --token Bearer token to use when fetching pacts from URLS [env: PACT_BROKER_TOKEN=] + +Provider options: + -h, --hostname + Provider hostname (defaults to localhost) [env: PACT_PROVIDER_HOSTNAME=] + -p, --port + Provider port (defaults to protocol default 80/443) [env: PACT_PROVIDER_PORT=] + --transport + Provider protocol transport to use (http, https, grpc, etc.) [env: PACT_PROVIDER_TRANSPORT=] [default: http] + --transports + Allows multiple protocol transports to be configured (http, https, grpc, etc.) with their associated port numbers separated by a colon. For example, use --transports http:8080 grpc:5555 to configure both. + -n, --provider-name + Provider name (defaults to provider) [env: PACT_PROVIDER_NAME=] + --base-path + Base path to add to all requests [env: PACT_PROVIDER_BASE_PATH=] + --request-timeout + Sets the HTTP request timeout in milliseconds for requests to the target API and for state change requests. [env: PACT_PROVIDER_REQUEST_TIMEOUT=] + -H, --header + Add a custom header to be included in the calls to the provider. Values must be in the form KEY=VALUE, where KEY and VALUE contain ASCII characters (32-127) only. Can be repeated. + --disable-ssl-verification + Disables validation of SSL certificates + +Provider state options: + -s, --state-change-url + URL to post state change requests to [env: PACT_PROVIDER_STATE_CHANGE_URL=] + --state-change-as-query + State change request data will be sent as query parameters instead of in the request body [env: PACT_PROVIDER_STATE_CHANGE_AS_QUERY=] + --state-change-teardown + State change teardown requests are to be made after each interaction [env: PACT_PROVIDER_STATE_CHANGE_TEARDOWN=] + +Filtering interactions: + --filter-description + Only validate interactions whose descriptions match this filter (regex format) [env: PACT_DESCRIPTION=] + --filter-state + Only validate interactions whose provider states match this filter (regex format) [env: PACT_PROVIDER_STATE=] + --filter-no-state + Only validate interactions that have no defined provider state [env: PACT_PROVIDER_NO_STATE=] + -c, --filter-consumer + Consumer name to filter the pacts to be verified (can be repeated) + +Publishing options: + --publish + Enables publishing of verification results back to the Pact Broker. Requires the broker-url and provider-version parameters. + --provider-version + Provider version that is being verified. This is required when publishing results. + --build-url + URL of the build to associate with the published verification results. + --provider-tags + Provider tags to use when publishing results. Accepts comma-separated values. + --provider-branch + Provider branch to use when publishing results + +Pact Broker options: + --consumer-version-tags + Consumer tags to use when fetching pacts from the Broker. Accepts comma-separated values. + --consumer-version-selectors + Consumer version selectors to use when fetching pacts from the Broker. Accepts a JSON string as per https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/. Can be repeated. + --enable-pending + Enables Pending Pacts + --include-wip-pacts-since + Allow pacts that don't match given consumer selectors (or tags) to be verified, without causing the overall task to fail. For more information, see https://pact.io/wip + +Development options: + --exit-on-first-error Stops the verifier at the first failure + --last-failed Only runs the interactions that failed on the previous verifier run. Requires --json-file to have been set ``` @@ -112,14 +333,309 @@ To connect to a Pact Broker that uses custom SSL cerificates, set the environmen #### publish ``` -<%= pact_publish_usage %> +Publishes pacts to the Pact Broker + +Usage: pact broker publish [OPTIONS] --broker-base-url ... + +Arguments: + ... + + Glob pattern to match pact files to publish + + ? matches any single character. + * matches any (possibly empty) sequence of characters. + ** matches the current directory and arbitrary subdirectories. This sequence must form + a single path component, so both **a and b** are invalid and will result in an + error. A sequence of more than two consecutive * characters is also invalid. + [...] matches any character inside the brackets. Character sequences can also specify + ranges of characters, as ordered by Unicode, so e.g. [0-9] specifies any character + between 0 and 9 inclusive. An unclosed bracket is invalid. + [!...] is the negation of [...], i.e. it matches any characters not in the brackets. + + The metacharacters ?, *, [, ] can be matched by using brackets (e.g. [?]). When a ] + occurs immediately following [ or [! then it is interpreted as being part of, rather + then ending, the character set, so ] and NOT ] can be matched by []] and [!]] respectively. + The - character can be specified inside a character sequence pattern by placing it at + the start or the end, e.g. [abc-]. + + See https://docs.rs/glob/0.3.0/glob/struct.Pattern.html + +Options: + -b, --broker-base-url + The base URL of the Pact Broker + + [env: PACT_BROKER_BASE_URL=] + + --enable-otel + Enable OpenTelemetry tracing + + --enable-otel-logs + Enable OpenTelemetry logging + + -u, --broker-username + Pact Broker basic auth username + + [env: PACT_BROKER_USERNAME=] + + --enable-otel-traces + Enable OpenTelemetry traces + + -p, --broker-password + Pact Broker basic auth password + + [env: PACT_BROKER_PASSWORD=] + + -k, --broker-token + Pact Broker bearer token + + [env: PACT_BROKER_TOKEN=] + + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) + + [env: OTEL_TRACES_EXPORTER=] + + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) + + [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + + --validate + Validate the Pact files before publishing. + + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + [possible values: http, http/protobuf] + + --strict + Require strict validation. + + -a, --consumer-app-version + The consumer application version + + --branch + Repository branch of the consumer version + + --log-level + Set the log level (none, off, error, warn, info, debug, trace) + + [default: off] + [possible values: off, none, error, warn, info, debug, trace] + + -r, --auto-detect-version-properties + Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + + -t, --tag [...] + Tag name for consumer version. Can be specified multiple times (delimiter ,). + + --tag-with-git-branch + Tag consumer version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + + --build-url + The build URL that created the pact + + --merge + If a pact already exists for this consumer version and provider, merge the contents. Useful when running Pact tests concurrently on different build nodes. + + -o, --output + Value must be one of ["json", "text", "pretty"] + + [default: text] + [possible values: json, text, pretty] + + -c, --ssl-certificate + The path to a valid SSL certificate file + + [env: SSL_CERT_FILE=] + + --skip-ssl-verification + Skip SSL certificate verification + + [env: SSL_SKIP_VERIFICATION=] + + --ssl-trust-store + Use the system's root trust store for SSL verification + + [env: SSL_TRUST_STORE=] + [default: true] + [possible values: true, false] + + -h, --help + Print help (see a summary with '-h') ``` #### can-i-deploy ``` -<%= pact_broker_can_i_deploy_usage %> +Usage: pact broker can-i-deploy [OPTIONS] --pacticipant --broker-base-url + +Options: + -a, --pacticipant + The pacticipant name. Use once for each pacticipant being checked. The following options (--version, --latest, --tag, --branch, --main-branch, --no-main-branch, --skip-main-branch) must come after each --pacticipant. + + --enable-otel + Enable OpenTelemetry tracing + + -e, --version + The pacticipant version. Must be entered after the --pacticipant that it relates to. + + --enable-otel-logs + Enable OpenTelemetry logging + + --enable-otel-traces + Enable OpenTelemetry traces + + -l, --latest [] + Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag. Must be entered after the --pacticipant that it relates to. + + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) + + [env: OTEL_TRACES_EXPORTER=] + + --tag + The tag of the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --branch + The branch of the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) + + [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + + --main-branch + Use the latest version of the configured main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + [possible values: http, http/protobuf] + + --no-main-branch + Do not use the main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --log-level + Set the log level (none, off, error, warn, info, debug, trace) + + [default: off] + [possible values: off, none, error, warn, info, debug, trace] + + --skip-main-branch + Skip the configured main branch of the pacticipant as the version for which you want to check the verification results. Must be entered after the --pacticipant that it relates to. + + --ignore + The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary. + + --to-environment + The environment into which the pacticipant(s) are to be deployed + + --to + The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status. + + -o, --output + Value must be one of ["json", "table"] + + [default: table] + [possible values: json, table] + + --retry-while-unknown + The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running) + + --retry-interval + The time between retries in seconds. Use in conjuction with --retry-while-unknown + + --dry-run + When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_DEPLOY_DRY_RUN=true. This mode is useful when setting up your CI/CD pipeline for the first time, or in a 'break glass' situation where you need to knowingly deploy what Pact considers a breaking change. For the second scenario, it is recommended to use the environment variable and just set it for the build required to deploy that particular version, so you don't accidentally leave the dry run mode enabled. + + -b, --broker-base-url + The base URL of the Pact Broker + + [env: PACT_BROKER_BASE_URL=] + + -u, --broker-username + Pact Broker basic auth username + + [env: PACT_BROKER_USERNAME=] + + -p, --broker-password + Pact Broker basic auth password + + [env: PACT_BROKER_PASSWORD=] + + -k, --broker-token + Pact Broker bearer token + + [env: PACT_BROKER_TOKEN=] + + -c, --ssl-certificate + The path to a valid SSL certificate file + + [env: SSL_CERT_FILE=] + + --skip-ssl-verification + Skip SSL certificate verification + + [env: SSL_SKIP_VERIFICATION=] + + --ssl-trust-store + Use the system's root trust store for SSL verification + + [env: SSL_TRUST_STORE=] + [default: true] + [possible values: true, false] + + -h, --help + Print help (see a summary with '-h') + + Check if a pacticipant can be deployed. + + Description: + Returns exit code 0 or 1, indicating whether or not the specified application (pacticipant) has a successful verification result with + each of the application versions that are already deployed to a particular environment. Prints out the relevant pact/verification + details, indicating any missing or failed verification results. + + The can-i-deploy tool was originally written to support specifying versions and dependencies using tags. This usage has now been + superseded by first class support for environments, deployments and releases. For documentation on how to use can-i-deploy with tags, + please see https://docs.pact.io/pact_broker/client_cli/can_i_deploy_usage_with_tags/ + + Before `can-i-deploy` can be used, the relevant environment resources must first be created in the Pact Broker using the + `create-environment` command. The 'test' and 'production' environments will have been seeded for you. You can check the existing + environments by running `pact broker list-environments`. See https://docs.pact.io/pact_broker/client_cli/readme#environments for more + information. + + $ pact broker create-environment --name 'uat' --display-name 'UAT' --no-production + + After an application is deployed or released, its deployment must be recorded using the `record-deployment` or `record-release` + commands. See https://docs.pact.io/pact_broker/recording_deployments_and_releases/ for more information. + + $ pact broker record-deployment --pacticipant Foo --version 173153ae0 --environment uat + + Before an application is deployed or released to an environment, the can-i-deploy command must be run to check that the application + version is safe to deploy with the versions of each integrated application that are already in that environment. + + $ pact broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to-environment ENVIRONMENT + + Example: can I deploy version 173153ae0 of application Foo to the test environment? + + $ pact broker can-i-deploy --pacticipant Foo --version 173153ae0 --to-environment test + + Can-i-deploy can also be used to check if arbitrary versions have a successful verification. When asking 'Can I deploy this + application version with the latest version from the main branch of another application' it functions as a 'can I merge' check. + + $ pact broker can-i-deploy --pacticipant Foo 173153ae0 \\ --pacticipant Bar --latest main + + ##### Polling + + If the verification process takes a long time and there are results missing when the can-i-deploy command runs in your CI/CD pipeline, + you can configure the command to poll and wait for the missing results to arrive. The arguments to specify are `--retry-while-unknown + TIMES` and `--retry-interval SECONDS`, set to appropriate values for your pipeline. ``` @@ -130,7 +646,81 @@ To connect to a Pact Broker that uses custom SSL cerificates, set the environmen #### publish-provider-contract ``` -<%= pactflow_publish_provider_contract_usage %> +Publish provider contract to PactFlow + +Usage: pact pactflow publish-provider-contract [OPTIONS] --broker-base-url --provider + +Arguments: + The contract file to publish + +Options: + -b, --broker-base-url + The base URL of the Pact Broker [env: PACT_BROKER_BASE_URL=] + --enable-otel + Enable OpenTelemetry tracing + --enable-otel-logs + Enable OpenTelemetry logging + -u, --broker-username + Pact Broker basic auth username [env: PACT_BROKER_USERNAME=] + --enable-otel-traces + Enable OpenTelemetry traces + -p, --broker-password + Pact Broker basic auth password [env: PACT_BROKER_PASSWORD=] + -k, --broker-token + Pact Broker bearer token [env: PACT_BROKER_TOKEN=] + --otel-exporter + The OpenTelemetry exporter(s) to use, comma separated (stdout, otlp) [env: OTEL_TRACES_EXPORTER=] + --otel-exporter-endpoint + The endpoint to use for the OTLP exporter (required if --otel-exporter=otlp) [env: OTEL_EXPORTER_OTLP_ENDPOINT=] + --provider + The provider name + -a, --provider-app-version + The provider application version + --otel-exporter-protocol + The protocol to use for the OTLP exporter (http/protobuf, http) [env: OTEL_EXPORTER_OTLP_PROTOCOL=] [default: http] [possible values: http, http/protobuf] + --branch + Repository branch of the provider version + --log-level + Set the log level (none, off, error, warn, info, debug, trace) [default: off] [possible values: off, none, error, warn, info, debug, trace] + -t, --tag [...] + Tag name for provider version. Can be specified multiple times (delimiter ,). + --specification + The contract specification [default: oas] + --content-type + The content type. eg. application/yml + --verification-success + Whether or not the self verification passed successfully. + --no-verification-success + Whether or not the self verification failed. + --verification-exit-code + The exit code of the verification process. Can be used instead of --verification-success|--no-verification-success for a simpler build script. + --verification-results + The path to the file containing the output from the verification process + --verification-results-content-type + The content type of the verification output eg. text/plain, application/yaml + --verification-results-format + The format of the verification output eg. junit, text + --verifier + The tool used to verify the provider contract + --verifier-version + The version of the tool used to verify the provider contract + --build-url + The build URL that created the provider contract + -r, --auto-detect-version-properties + Automatically detect the repository commit, branch and build URL from known CI environment variables or git CLI. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + --tag-with-git-branch + Tag provider version with the name of the current git branch. Supports Buildkite, Circle CI, Travis CI, GitHub Actions, Jenkins, Hudson, AppVeyor, GitLab, CodeShip, Bitbucket and Azure DevOps. + -o, --output + Value must be one of ["json", "text"] [default: text] [possible values: json, text] + -c, --ssl-certificate + The path to a valid SSL certificate file [env: SSL_CERT_FILE=] + --skip-ssl-verification + Skip SSL certificate verification [env: SSL_SKIP_VERIFICATION=] + --ssl-trust-store + Use the system's root trust store for SSL verification [env: SSL_TRUST_STORE=] [default: true] [possible values: true, false] + -h, --help + Print help + ``` ### pact @@ -138,13 +728,29 @@ To connect to a Pact Broker that uses custom SSL cerificates, set the environmen #### docs ``` -<%= pact_docs_usage %> +Usage: + pact docs + +Options: + [--pact-dir=PACT_DIR] # Directory containing the pacts + # Default: /home/runner/work/pact-standalone/pact-standalone/build/tmp/spec/pacts + [--doc-dir=DOC_DIR] # Documentation directory + # Default: /home/runner/work/pact-standalone/pact-standalone/build/tmp/doc/pacts + +Generate Pact documentation in markdown + ``` ### pact-message ``` -<%= pact_message_usage %> +Commands: + pact-message help [COMMAND] ... + pact-message reify ... + pact-message update MESSAGE_JSON --consumer=CONSUMER --pact-dir=PACT_DIR --... + pact-message version ... + + ``` ## Troubleshooting diff --git a/packaging/pact-broker.bat b/packaging/pact-broker.bat index c0f50d01..9ce257b0 100644 --- a/packaging/pact-broker.bat +++ b/packaging/pact-broker.bat @@ -3,6 +3,16 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe broker --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe broker %* + EXIT /B %ERRORLEVEL% + ) +) + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-broker.sh b/packaging/pact-broker.sh index 8be616ff..80c21eca 100755 --- a/packaging/pact-broker.sh +++ b/packaging/pact-broker.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" broker --help + else + exec "$APP" broker "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact-message.bat b/packaging/pact-message.bat index 8ef3c6d0..0154702b 100644 --- a/packaging/pact-message.bat +++ b/packaging/pact-message.bat @@ -3,6 +3,12 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + echo pact-message is deprecated. Please use pact_mock_server_cli instead. + echo or set the PACT_CLI_LEGACY environment variable to use the old CLI. + EXIT /B 1 +) + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-message.sh b/packaging/pact-message.sh index 13cb9bf1..b79a2ed4 100755 --- a/packaging/pact-message.sh +++ b/packaging/pact-message.sh @@ -15,6 +15,12 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + echo "pact-message is deprecated. Please use pact_mock_server_cli instead." + echo "or set the PACT_CLI_LEGACY environment variable to use the old CLI." + exit 1 +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact-mock-service.bat b/packaging/pact-mock-service.bat index 7dffdf5e..f69d7eda 100644 --- a/packaging/pact-mock-service.bat +++ b/packaging/pact-mock-service.bat @@ -3,6 +3,17 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe mock --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe mock %* + EXIT /B %ERRORLEVEL% + ) +) + + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-mock-service.sh b/packaging/pact-mock-service.sh index db5e2786..8fc56781 100755 --- a/packaging/pact-mock-service.sh +++ b/packaging/pact-mock-service.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" mock --help + else + exec "$APP" mock "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact-provider-verifier.bat b/packaging/pact-provider-verifier.bat index 4cad4713..cfe00258 100644 --- a/packaging/pact-provider-verifier.bat +++ b/packaging/pact-provider-verifier.bat @@ -3,6 +3,16 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe verifier --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe verifier %* + EXIT /B %ERRORLEVEL% + ) +) + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-provider-verifier.sh b/packaging/pact-provider-verifier.sh index 8e2e7726..2273ef2e 100755 --- a/packaging/pact-provider-verifier.sh +++ b/packaging/pact-provider-verifier.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" verifier --help + else + exec "$APP" verifier "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact-publish.bat b/packaging/pact-publish.bat index f40626c2..b350ded4 100644 --- a/packaging/pact-publish.bat +++ b/packaging/pact-publish.bat @@ -3,6 +3,16 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe pact publish --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe pact publish %* + EXIT /B %ERRORLEVEL% + ) +) + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-publish.sh b/packaging/pact-publish.sh index 5114aa8c..56107094 100755 --- a/packaging/pact-publish.sh +++ b/packaging/pact-publish.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" pact publish --help + else + exec "$APP" pact publish "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact-stub-service.bat b/packaging/pact-stub-service.bat index 82003f5b..e5794f3e 100644 --- a/packaging/pact-stub-service.bat +++ b/packaging/pact-stub-service.bat @@ -3,6 +3,16 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe stub --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe stub %* + EXIT /B %ERRORLEVEL% + ) +) + :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pact-stub-service.sh b/packaging/pact-stub-service.sh index 1ff19281..669e88eb 100755 --- a/packaging/pact-stub-service.sh +++ b/packaging/pact-stub-service.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" stub --help + else + exec "$APP" stub "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/packaging/pact.bat b/packaging/pact.bat deleted file mode 100644 index b712631a..00000000 --- a/packaging/pact.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -SET RUNNING_PATH=%~dp0 -CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH - -:: Tell Bundler where the Gemfile and gems are. -set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" -set BUNDLE_IGNORE_CONFIG= -set RUBYGEMS_GEMDEPS= -set BUNDLE_APP_CONFIG= -set BUNDLE_FROZEN=1 - -:: Run the actual app using the bundled Ruby interpreter, with Bundler activated. -@"%ROOT_PATH%\lib\ruby\bin\ruby.bat" -E UTF-8 -rbundler/setup -I "%ROOT_PATH%\lib\app\lib" "%ROOT_PATH%\lib\app\pact.rb" %* - -GOTO :EOF - -:RESOLVE -SET %2=%~f1 -GOTO :EOF diff --git a/packaging/pact.rb b/packaging/pact.rb deleted file mode 100644 index 7c35adff..00000000 --- a/packaging/pact.rb +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -INTERNAL_APP = ARGV[0].to_s -FILENAME = File.basename($PROGRAM_NAME).split.first.chomp(".rb") - -case ARGV[0] -when "pact" - ARGV.shift - require "pact/cli" - Pact::CLI.start -when "pactflow" - ARGV.shift - require "pactflow/client/cli/pactflow" - Pactflow::Client::CLI::Pactflow.start -when "stub-service" - ARGV.shift - require "pact/stub_service/cli" - Pact::StubService::CLI.start -when "provider-verifier" - ARGV.shift - ENV["PACT_EXECUTING_LANGUAGE"] ||= "unknown" - require "pact/provider_verifier/cli/verify" - Pact::ProviderVerifier::CLI::Verify.start -when "mock-service" - ARGV.shift - require "pact/mock_service/cli" - Pact::MockService::CLI.start -when "message" - ARGV.shift - require "pact/message/cli" - Pact::Message::CLI.start -when "broker", "pact-broker" - ARGV.shift - require "pact_broker/client/cli/broker" - if ENV["PACT_BROKER_DISABLE_SSL_VERIFICATION"] == "true" || ENV["PACT_DISABLE_SSL_VERIFICATION"] == "true" - require "openssl" - OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE - warn " - WARN: SSL verification has been disabled by a dodgy hack - (reassigning the VERIFY_PEER constant to VERIFY_NONE). - You acknowledge that you do this at your own risk! - " - end - PactBroker::Client::CLI::Broker.start -when 'plugin' - ARGV.shift - output = `#{File.expand_path("../../bin/pact-plugin-cli", __dir__)} #{ARGV.join(" ")}` - exit_status = $?.exitstatus - puts output - exit(exit_status) -when 'verifier' - ARGV.shift - output = `#{File.expand_path("../../bin/pact_verifier_cli", __dir__)} #{ARGV.join(" ")}` - exit_status = $?.exitstatus - puts output - exit(exit_status) -when 'mock-server' - ARGV.shift - IO.popen([File.expand_path("../../bin/pact_mock_server_cli", __dir__), *ARGV], err: [:child, :out]) do |io| - while (line = io.gets) - $stdout.write(line) - end - exit_status = Process.wait2(io.pid)[1].exitstatus - exit(exit_status) - end -when 'stub-server' - ARGV.shift - IO.popen([File.expand_path("../../bin/pact-stub-server", __dir__), *ARGV], err: [:child, :out]) do |io| - while (line = io.gets) - $stdout.write(line) - end - exit_status = Process.wait2(io.pid)[1].exitstatus - exit(exit_status) - end -else - puts "available commands:" - puts "__________________" - puts "#{FILENAME} help" - puts "#{FILENAME} pact" - puts "#{FILENAME} pactflow" - puts "#{FILENAME} stub-server" - puts "#{FILENAME} verifier" - puts "#{FILENAME} mock-server" - puts "#{FILENAME} message" - puts "#{FILENAME} broker" - puts "#{FILENAME} pact-broker" - puts "#{FILENAME} plugin" - puts "#{FILENAME} stub-service (legacy)" - puts "#{FILENAME} provider-verifier (legacy)" - puts "#{FILENAME} mock-service (legacy)" -end \ No newline at end of file diff --git a/packaging/pact.sh b/packaging/pact.sh deleted file mode 100755 index 0a0cf901..00000000 --- a/packaging/pact.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -e - -SOURCE="$0" -while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - TARGET="$(readlink "$SOURCE")" - START="$( echo "$TARGET" | cut -c 1 )" - if [ "$START" = "/" ]; then - SOURCE="$TARGET" - else - DIR="$( dirname "$SOURCE" )" - SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located - fi -done -RDIR="$( dirname "$SOURCE" )" -DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -# Figure out where this script is located. -LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" - -# Tell Bundler where the Gemfile and gems are. -export BUNDLE_GEMFILE="$LIBDIR/vendor/Gemfile" -unset BUNDLE_IGNORE_CONFIG -unset RUBYGEMS_GEMDEPS -unset BUNDLE_APP_CONFIG -export BUNDLE_FROZEN=1 - -# Run the actual app using the bundled Ruby interpreter, with Bundler activated. -exec "$LIBDIR/ruby/bin/ruby" -E UTF-8 -rreadline -rbundler/setup -I "$LIBDIR/app/lib" "$LIBDIR/app/pact.rb" "$@" diff --git a/packaging/pactflow.bat b/packaging/pactflow.bat index f8720979..9123de24 100644 --- a/packaging/pactflow.bat +++ b/packaging/pactflow.bat @@ -3,6 +3,15 @@ SET RUNNING_PATH=%~dp0 CALL :RESOLVE "%RUNNING_PATH%\.." ROOT_PATH +IF NOT DEFINED PACT_CLI_LEGACY ( + IF "%~1"=="" ( + %RUNNING_PATH%pact.exe pactflow --help + EXIT /B %ERRORLEVEL% + ) ELSE ( + %RUNNING_PATH%pact.exe pactflow %* + EXIT /B %ERRORLEVEL% + ) +) :: Tell Bundler where the Gemfile and gems are. set "BUNDLE_GEMFILE=%ROOT_PATH%\lib\vendor\Gemfile" set BUNDLE_IGNORE_CONFIG= diff --git a/packaging/pactflow.sh b/packaging/pactflow.sh index cc6742a1..0693d0f8 100755 --- a/packaging/pactflow.sh +++ b/packaging/pactflow.sh @@ -15,6 +15,18 @@ done RDIR="$( dirname "$SOURCE" )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ -z "${PACT_CLI_LEGACY}" ]; then + APP="$DIR/pact" + if [ -x "$APP" ]; then + if [ "$#" -eq 0 ]; then + exec "$APP" pactflow --help + else + exec "$APP" pactflow "$@" + fi + exit $? + fi +fi + # Figure out where this script is located. LIBDIR="$(cd "$DIR" && cd ../lib && pwd)" diff --git a/script/test.sh b/script/test.sh index f06e10fd..3bb8bc2c 100755 --- a/script/test.sh +++ b/script/test.sh @@ -39,26 +39,65 @@ 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-broker - pact-message pact-mock-service pact-provider-verifier pact-stub-service pactflow - pact-plugin-cli - pact-stub-server - pact_verifier_cli - pact_mock_server_cli ) +if [ ! -z "${PACT_CLI_LEGACY:-}" ]; then + tools+=(pact-message) +else + tools+=( + pact + "pact plugin" + "pact stub" + "pact verifier" + "pact mock" + "pact broker" + ) +fi + test_cmd="" -for tool in ${tools[@]}; do - echo testing $tool - 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}; +for tool in "${tools[@]}"; do + FILE_EXT="" + test_cmd="" + case "$tool" in + *" "*) + test_cmd="--help" + ;; + esac + if [ "$tool" = "pact-mock-service" ] || [ "$tool" = "pact-provider-verifier" ] || [ "$tool" = "pact-stub-verifier" ]; then + test_cmd="--help" + fi + if [ "$BINARY_OS" = "windows" ]; then + case "$tool" in + pact\ *) + FILE_EXT=".exe" + ;; + pact) + if [ ! -z "${PACT_CLI_LEGACY:-}" ]; then + FILE_EXT=".exe" + fi + ;; + *) + FILE_EXT=".bat" + ;; + esac + fi + + case "$tool" in + *" "*) + cmd="${tool%% *}" + arg="${tool#* }" + echo executing "${cmd}${FILE_EXT}" "${arg}" ${test_cmd} + "${PATH_TO_BIN}${cmd}${FILE_EXT}" "${arg}" ${test_cmd} + ;; + *) + echo executing "${tool}${FILE_EXT}" ${test_cmd} + "${PATH_TO_BIN}${tool}${FILE_EXT}" ${test_cmd} + esac done \ No newline at end of file diff --git a/script/unpack-and-test.sh b/script/unpack-and-test.sh index f3cc91a1..a7a00179 100755 --- a/script/unpack-and-test.sh +++ b/script/unpack-and-test.sh @@ -46,28 +46,6 @@ ls if [ "$BINARY_OS" != "windows" ]; then tar xvf *$BINARY_OS-$BINARY_ARCH.tar.gz; else unzip *$BINARY_OS-$BINARY_ARCH.zip; fi if [ "$BINARY_OS" != "windows" ] ; then PATH_SEPERATOR=/ ; else PATH_SEPERATOR=\\; fi -PATH_TO_BIN=.${PATH_SEPERATOR}pact${PATH_SEPERATOR}bin${PATH_SEPERATOR} -tools=( - pact - pact-broker - pact-message - pact-mock-service - 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 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 +cd .. +./script/test.sh diff --git a/tasks/package.rake b/tasks/package.rake index 3304cc72..57db3d95 100644 --- a/tasks/package.rake +++ b/tasks/package.rake @@ -13,9 +13,11 @@ PLUGIN_CLI_VERSION = "0.1.3" # https://github.com/pact-foundation/pact-plugins/r MOCK_SERVER_CLI_VERSION = "1.0.6" # https://github.com/pact-foundation/pact-core-mock-server/releases VERIFIER_CLI_VERSION = "1.2.0" # https://github.com/pact-foundation/pact-reference/releases STUB_SERVER_CLI_VERSION = "0.6.2" # https://github.com/pact-foundation/pact-stub-server/releases +PACT_BROKER_CLI_VERSION = "0.2.0" # https://github.com/pact-foundation/pact-broker-cli/releases +PACT_CLI_VERSION = "0.7.0" # https://github.com/you54f/pact-cli/releases desc "Package pact-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'] +task :package => ['package:linux:x86_64','package:linux:arm64', 'package:osx:x86_64', 'package:osx:arm64','package:windows:x86_64', 'package:windows:arm64'] namespace :package do namespace :linux do @@ -47,10 +49,16 @@ namespace :package do create_package(TRAVELING_RUBY_VERSION, "windows-x86_64", "windows-x86_64", :windows) end end + namespace :windows do + desc "Package pact-standalone for windows arm64" + task :arm64 do + create_package(TRAVELING_RUBY_VERSION, "windows-arm64", "windows-arm64", :windows) + end + end desc "Install gems to local directory" task :bundle_install do 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." + abort "You can only 'bundle install' using Ruby #{TRAVELING_RB_VERSION}, because that's what Traveling Ruby uses. \n You are using Ruby #{RUBY_VERSION}." end sh "rm -rf build/tmp" sh "mkdir -p build/tmp" @@ -106,7 +114,11 @@ def create_package(version, source_target, package_target, os_type) # sh "cp -pR lib #{package_dir}/lib/app" sh "mkdir #{package_dir}/lib/ruby" - sh "tar -xzf build/traveling-ruby-#{version}-#{source_target}.tar.gz -C #{package_dir}/lib/ruby" + if package_target == "windows-arm64" + sh "mkdir -p #{package_dir}/lib/ruby/lib" + else + sh "tar -xzf build/traveling-ruby-#{version}-#{source_target}.tar.gz -C #{package_dir}/lib/ruby" + end # From https://curl.se/docs/caextract.html sh "cp packaging/cacert.pem #{package_dir}/lib/ruby/lib/ca-bundle.crt" @@ -120,22 +132,27 @@ def create_package(version, source_target, package_target, os_type) else raise "We don't serve their kind (#{os_type}) here!" end - - sh "cp -pR build/vendor #{package_dir}/lib/" - sh "cp packaging/Gemfile packaging/Gemfile.lock #{package_dir}/lib/vendor/" - sh "mkdir #{package_dir}/lib/vendor/.bundle" - sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config" - - if package_target.include? 'windows' - sh "sed -i.bak '37s/^/#/' #{package_dir}/lib/ruby/lib/ruby/#{RUBY_COMPAT_VERSION}/bundler/stub_specification.rb" - else - sh "sed -i.bak '41s/^/#/' #{package_dir}/lib/ruby/lib/ruby/site_ruby/#{RUBY_COMPAT_VERSION}/bundler/stub_specification.rb" + unless package_target == "windows-arm64" + sh "cp -pR build/vendor #{package_dir}/lib/" + sh "cp packaging/Gemfile packaging/Gemfile.lock #{package_dir}/lib/vendor/" + sh "mkdir #{package_dir}/lib/vendor/.bundle" + sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config" end + unless package_target == "windows-arm64" + + if package_target.include? 'windows' + sh "sed -i.bak '37s/^/#/' #{package_dir}/lib/ruby/lib/ruby/#{RUBY_COMPAT_VERSION}/bundler/stub_specification.rb" + else + sh "sed -i.bak '41s/^/#/' #{package_dir}/lib/ruby/lib/ruby/site_ruby/#{RUBY_COMPAT_VERSION}/bundler/stub_specification.rb" + end 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 + end + install_pact_cli package_dir, package_target + # 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 + # install_broker_cli package_dir, package_target if !ENV['DIR_ONLY'] sh "mkdir -p pkg" @@ -146,7 +163,7 @@ def create_package(version, source_target, package_target, os_type) sh "zip -9rq pkg/#{package_name}.zip #{package_dir}" end - sh "rm -rf #{package_dir}" + # sh "rm -rf #{package_dir}" end end @@ -262,6 +279,10 @@ def install_plugin_cli(package_dir, package_target) sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.exe.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-windows-x86_64.exe.gz" sh "gunzip -N -f #{package_dir}/bin/pact-plugin-cli.exe.gz" sh "chmod +x #{package_dir}/bin/pact-plugin-cli.exe" + when "windows-arm64" + sh "curl -L -o #{package_dir}/bin/pact-plugin-cli.exe.gz https://github.com/pact-foundation/pact-plugins/releases/download/pact-plugin-cli-v#{PLUGIN_CLI_VERSION}/pact-plugin-cli-windows-aarch64.exe.gz" + sh "gunzip -N -f #{package_dir}/bin/pact-plugin-cli.exe.gz" + sh "chmod +x #{package_dir}/bin/pact-plugin-cli.exe" end end @@ -287,6 +308,10 @@ def install_mock_server_cli(package_dir, package_target) 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" + when "windows-arm64" + 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-aarch64.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 @@ -312,6 +337,10 @@ def install_verifier_cli(package_dir, package_target) 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" + when "windows-arm64" + 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-aarch64.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 @@ -337,5 +366,55 @@ def install_stub_server_cli(package_dir, package_target) 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" + when "windows-arm64" + 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-aarch64.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 +end + +def install_broker_cli(package_dir, package_target) + case package_target + when "linux-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-x86_64-linux-musl" + sh "chmod +x #{package_dir}/bin/pact-broker-cli" + when "linux-arm64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-aarch64-linux" + sh "chmod +x #{package_dir}/bin/pact-broker-cli" + when "osx-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-x86_64-macos" + sh "chmod +x #{package_dir}/bin/pact-broker-cli" + when "osx-arm64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-aarch64-macos" + sh "chmod +x #{package_dir}/bin/pact-broker-cli" + when "windows-x86_64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli.exe https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-x86_64-windows-gnu.exe" + sh "chmod +x #{package_dir}/bin/pact-broker-cli.exe" + when "windows-arm64" + sh "curl -L -o #{package_dir}/bin/pact-broker-cli.exe https://github.com/pact-foundation/pact-broker-cli/releases/download/v#{PACT_BROKER_CLI_VERSION}/pact-broker-cli-aarch64-windows-msvc.exe" + sh "chmod +x #{package_dir}/bin/pact-broker-cli.exe" + end +end + +def install_pact_cli(package_dir, package_target) + case package_target + when "linux-x86_64" + sh "curl --fail -L -o #{package_dir}/bin/pact https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-x86_64-linux-musl" + sh "chmod +x #{package_dir}/bin/pact" + when "linux-arm64" + sh "curl --fail -L -o #{package_dir}/bin/pact https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-aarch64-linux-musl" + sh "chmod +x #{package_dir}/bin/pact" + when "osx-x86_64" + sh "curl --fail -L -o #{package_dir}/bin/pact https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-x86_64-macos" + sh "chmod +x #{package_dir}/bin/pact" + when "osx-arm64" + sh "curl --fail -L -o #{package_dir}/bin/pact https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-aarch64-macos" + sh "chmod +x #{package_dir}/bin/pact" + when "windows-x86_64" + sh "curl --fail -L -o #{package_dir}/bin/pact.exe https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-x86_64-windows-gnu.exe" + sh "chmod +x #{package_dir}/bin/pact.exe" + when "windows-arm64" + sh "curl --fail -L -o #{package_dir}/bin/pact.exe https://github.com/you54f/pact-cli/releases/download/v#{PACT_CLI_VERSION}/pact-aarch64-windows-msvc.exe" + sh "chmod +x #{package_dir}/bin/pact.exe" + end +end diff --git a/tasks/release.rake b/tasks/release.rake index a2e6b6c3..3e1f4bc6 100644 --- a/tasks/release.rake +++ b/tasks/release.rake @@ -20,6 +20,7 @@ task :generate_release_notes, [:tag] do | t, args | release_notes_content = release_notes_content.gsub("", VERSION) File.open(RELEASE_NOTES_PATH, "w") do |file| file << release_notes_content + file << "\n\n" file << readme_content end end