goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.55k stars 473 forks source link

Build binary for arm64 #737

Closed linki closed 2 years ago

linki commented 2 years ago

This is an attempt to build goss for arm64 so we can run it on Graviton2 machines on AWS.

It fixes https://github.com/aelsabbahy/goss/issues/722.

It adds a Makefile target for release/goss-linux-arm64 alongside release/goss-linux-arm, release/goss-linux-amd64 etc.

Note, that this results in the released assets being changed slightly going forward: goss-linux-arm will be a 32-bit ARM binary and goss-linux-arm64 will be a 64-bit ARM binary.

Other changes

I also changed install.sh a little because the current implementation actually builds for the wrong architecture: when uname -m returns aarch64 it should use GOARCH=arm64 instead of the currently used GOARCH=arm which results in a 32-bit binary.

I also added arm64 to the 64-bit if-statement because that's what is returned on the arm-based Macbooks.

In order to also support 32-bit ARM in install.sh I matched on aarch32 but I don't know if that's correct. I believe that wouldn't work on, e.g. Raspberry Pis, because I think they return something like armv7 or so. I didn't prioritize it here because the current implementation didn't do the right thing anyways.

/cc @tnaroska because you created the original issue /cc @garyschulte because you have built for arm64 as well

ekelali commented 2 years ago

Thank you for submitting this PR:

linki commented 2 years ago

I'm still working on this feature on my end. I'll follow up here as soon as possible.

linki commented 2 years ago

@ekelali Thanks for the suggestion to split the PR. I wasn't sure about the purpose of install.sh but it looks like it's not relevant to the release process.

It should be much easier to get this merged now since it will only add one more binary and shasum to each release, not touching anything else.

Note, that this results in the released assets being changed slightly going forward: goss-linux-arm will be a 32-bit ARM binary and goss-linux-arm64 will be a 64-bit ARM binary.

This was actually a wrong comment by me. goss-linux-arm is already a 32-bit ARM binary (like it should) and this PR adds a goss-linux-arm64 64-bit ARM binary alongside it. So the releases are backwards compatible.

I'll clarify the changes to install.sh in a separate PR.

linki commented 2 years ago

@aelsabbahy Would you mind creating a release that includes the arm64 binaries?

linki commented 2 years ago

@aelsabbahy Thanks! 🤗

aelsabbahy commented 2 years ago

Thank you for the contribution, greatly appreciated!