pact-foundation / pact-ruby-standalone

A standalone pact command line executable using the ruby pact implementation and Travelling Ruby
https://pact.io
MIT License
42 stars 33 forks source link

Add support for arm64 on Linux #70

Closed maatthc closed 1 year ago

maatthc commented 2 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Expected behaviour

Would be nice to have support to aarch64 as Amazon and Oracle Cloud have good offers for instances on this platform.

Actual behaviour

Available executable are not compatible with ARM.

Steps to reproduce

Try to run any of the released packages on Arm-based AWS Graviton2 processors on EC2.

Relevent log files

Please ensure you set logging to DEBUG and attach any relevant log files here (or link from a gist).

bethesque commented 2 years ago

Which part of the ruby standalone are you interested in using? eg. the pact broker CLI, or the pact mock service/verifier.

maatthc commented 2 years ago

The ideal would be to have support to everything.

bethesque commented 2 years ago

The reason I ask is that the mock service and verifier are being replaced in each of the languages by a shared rust lib, so the "pact" commands in the standalone are pretty much legacy now. The pact-broker CLI commands have their own docker image. So it would help to know which parts of the standalone you're using, and for which language, because they'll need to be solved differently.

p0deje commented 2 years ago

It would be nice to at least be able to install pact-node on Linux arm64 so that the images could be used on M1.

Right now it's impossible to build a Docker image for any JavaScript application that uses pact-node on newer MacBooks with M1 processors:

 => ERROR [builder 7/9] RUN yarn install  31.5s
...
#17 27.28 [5/5] Building fresh packages...
#17 30.20 error /app/node_modules/@pact-foundation/pact-node: Command failed.
#17 30.20 Exit code: 1
#17 30.20 Command: node postinstall.js
#17 30.20 Arguments:
#17 30.20 Directory: /app/node_modules/@pact-foundation/pact-node
#17 30.20 Output:
#17 30.20 /app/node_modules/@pact-foundation/pact-node/standalone/install.js:42
#17 30.20     throw new Error(chalk_1.default.red("Error while installing binary: " + msg));
#17 30.20     ^
#17 30.20
#17 30.20 Error: Error while installing binary: Cannot find binary for platform 'linux' with architecture 'arm64'.
#17 30.20     at throwError (/app/node_modules/@pact-foundation/pact-node/standalone/install.js:42:11)
#17 30.20     at getBinaryEntry (/app/node_modules/@pact-foundation/pact-node/standalone/install.js:290:11)
#17 30.20     at setup (/app/node_modules/@pact-foundation/pact-node/standalone/install.js:294:17)
#17 30.20     at /app/node_modules/@pact-foundation/pact-node/standalone/install.js:327:12
#17 30.20     at Object.<anonymous> (/app/node_modules/@pact-foundation/pact-node/postinstall.js:3:1)
#17 30.20     at Module._compile (internal/modules/cjs/loader.js:999:30)
#17 30.20     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
#17 30.20     at Module.load (internal/modules/cjs/loader.js:863:32)
#17 30.20     at Function.Module._load (internal/modules/cjs/loader.js:708:14)
#17 30.20     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
#17 30.20     at internal/main/run_main_module.js:17:47
#17 30.20 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
bethesque commented 2 years ago

Travelling Ruby (what we use to package up the pact-ruby-standalone) is not being maintained any more, and is unlikely to ever be supported for M1. We're transitioning all the pact clients away from that and onto a shared rust library. The Rust library will be supported on M1 (but I don't know the timing on this). @mefellows and @TimothyJones might be able to add more information about this.

I believe theres is a work around for the M1 issue however, as one of my colleagues is currently running the standalone on her M1. Try searching in the pact-js issues or asking in the #pact-js Slack channel.

mefellows commented 2 years ago

To run on node, you need to install it and run through Rosetta mode.

mefellows commented 2 years ago

For "everything" support it will unlikely be possible via the standalone, as the maintainer of that library has basically stated they will no longer be adding major updates.

You could install the bits you need via rubygems or we could add arm support to the docker image (ruby itself can run on arm, so we'd just need to build an arm image).

timReynolds commented 1 year ago

For those trying to build an image which includes pact on M1 Macs you specify the platform;

docker build --platform linux/amd64  .

Solution is outline in detail here.

SanjayaKumarSahoo commented 1 year ago

Are we going to fix this issue, we are looking at this as urgent. Any help on this would be appreciable.

TimothyJones commented 1 year ago

Does the docker command that Tim linked above not work for you? What problems are you encountering?

YOU54F commented 1 year ago

☝🏾 to that linked issue, I have got some very alpha arm64 osx and linux standalone packages you can trial

https://github.com/YOU54F/pact-ruby-standalone/releases/tag/v3.1.2.2-alpha

Note these aren't official builds so your mileage might vary and you shouldn't rely on them at the moment until we get some feedback

Direct Download

curl -fsSL https://raw.githubusercontent.com/you54f/pact-ruby-standalone/ruby_3.2.2_upgrade/install.sh | bash

wget -q https://raw.githubusercontent.com/you54f/pact-ruby-standalone/ruby_3.2.2_upgrade/install.sh -O- | bash

Script here

https://github.com/YOU54F/pact-ruby-standalone/blob/ruby_3.2.2_upgrade/install.sh

HomeBrew

https://github.com/you54f/homebrew-pact-ruby-standalone

brew tap you54f/pact-ruby-standalone
brew install pact-ruby-standalone

FlatPak

https://github.com/YOU54F/flatpak

Scoop

scoop bucket add pact https://github.com/you54f/scoop scoop install pact

https://github.com/YOU54F/scoop

 Choco

choco install pact --version=0.0.1

https://github.com/YOU54F/choco

YOU54F commented 1 year ago

Are we going to fix this issue, we are looking at this as urgent. Any help on this would be appreciable.

@SanjayaKumarSahoo what functionality are you requiring from the standalone package, that isn't available in other means?

Same question for @maatthc - you say support everything - we will do that in Rust, where it suits, but we need to know what in particular is of use to you currently in the Ruby package, that isn't in the Rust package.

Most of the functionality is available via other means, cross compiled for additional platforms (and rust makes it very easy to support new ones), the ruby packaging system in general doesn't lend itself well for the platforms/archs we now want to cover (there are lots more people working on the rust cross compiling that those working on packaging ruby apps standalone, x-platform)

YOU54F commented 1 year ago

You want it?

You got it!

See https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v2.0.0

Now, just don't break it 😂