Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ARM64 version available for building #502

Merged
merged 2 commits into from
Oct 27, 2022

Conversation

camillof
Copy link
Contributor

@camillof camillof commented Oct 25, 2022

Updated Makefile so the ARM64 version of the test-reporter is available to be built.

➜  test-reporter git:(QUA-795/ARM-binary-release) file --brief artifacts/bin/test-reporter-0.10.3-linux-arm64
ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=rp0JmTgqwUwNjGy_zlc0/jm6vqQgU7nHL3Gu1471w/laH10Nt_Y0gKwCvZ6rFa/Emf5LCySp9699oRMiyME, not stripped

So far, it has been tested by successfully uploading a test coverage from an Ubuntu arm64 image using this new test-coverage binary.

...
Test report uploaded successfully to Code Climate
root@6a4529efb71e:/test-project# uname -m
aarch64
root@6a4529efb71e:/test-project# /artifacts/test-reporter-0.10.3-linux-arm64 env
GIT_BRANCH=main
GIT_COMMIT_SHA=d860ac535656884cc17b5fb1021c9864bc44277f
GIT_COMMITTED_AT=1650896777

I also updated the Makefile so the release of this binary is included on new releases. For this, I run the new build-linux-arm64 command inside a circleci/golang:1.15 container to be sure everything is ok -> The binary was built successfully.

$ readelf -h artifacts/bin/test-reporter-0.10.4-linux-arm64 | grep 'Class\|File\|Machine'
  Class:                             ELF64
  Machine:                           AArch64

⚠️ Is it worth creating a CI step for running the tests on a linux arm64 image?

Generated ARM64 binary ⬇️
test-reporter-0.10.4-linux-arm64.zip

@camillof camillof marked this pull request as ready for review October 25, 2022 18:44
@camillof camillof requested review from a team, RubyBrewsday and dantevvp and removed request for a team October 25, 2022 18:44
@RubyBrewsday
Copy link

@camillof so I'm testing this out on my end but getting the following error:

➜  Downloads ./test-reporter-0.10.4-linux-arm64
zsh: exec format error: ./test-reporter-0.10.4-linux-arm64

Gonna try pulling your version and rebuilding locally and see what happens when i try to run that, but if youve run into this before would love to hear what you did to fix it.

@camillof
Copy link
Contributor Author

Quick update here. The versions released are for linux based computers, not darwin. That's why we couldn't get them to work on @RubyBrewsday computer. The bad news is that for compiling for darwin arm64, we need go 1.16 (and the project is on 1.15 and I’m afraid many changes are needed before upgrading)

I'll try to get access to a linux arm64 based EC2 instance (Graviton EC2 instance) and try those there.

@RubyBrewsday
Copy link

To add some extra context that @camillof and I already chatted about offline, it does seem like for what it's worth that the version we currently have up for codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 actually works when I run it locally on my M1 mac :/

➜  Downloads ./test-reporter-latest-darwin-amd64
Report information about tests to Code Climate

Usage:
  cc-test-reporter [flags]
  cc-test-reporter [command]

Available Commands:
  after-build     Locate, parse, and re-format supported coverage sources. Upload pre-formatted coverage payloads to Code Climate servers.
  before-build    To be run before a build
  env             Infer and output information about the environment the reporter is running in.
  format-coverage Locate, parse, and re-format supported coverage sources.
  help            Help about any command
  show-coverage   Show coverage results in standard output
  sum-coverage    Combine (sum) multiple pre-formatted coverage payloads into one.
  upload-coverage Upload pre-formatted coverage payloads to Code Climate servers.

Flags:
  -d, --debug     run in debug mode
  -v, --version   Show version information

Use "cc-test-reporter [command] --help" for more information about a command.
➜  Downloads ./test-reporter-latest-darwin-amd64 before-build
➜  Downloads

Haven't actually tried testing it out in terms of running any kind of test coverage locally and using the library but part of me does kinda sorta wonder if we just change the name of the executable if it would magically just "work".

@camillof
Copy link
Contributor Author

I created a EC2 graviton arm64 instance for testing:
image

[ec2-user@ip-10-0-0-22 ~]$ uname -m
aarch64

After copying the binary into the instance, I was able to successfully upload a test report to CC.

[ec2-user@ip-10-0-0-22 mfcs-ruby-test-simplecov]$ CC_TEST_REPORTER_ID=XXXXXX ../test-reporter-0.10.4-linux-arm64 after-build
Test report uploaded successfully to Code Climate

From my point of view, this validates that the binary is working correctly on arm64 machines

@RubyBrewsday
Copy link

@camillof I'm ok with that as well. I'd be curious to publish this package and then once it's up pulling that down and seeing if I can run that locally. But yeah good stuff!

@camillof
Copy link
Contributor Author

If everything works well, I'll push another PR to update the README, to publish the arm64 linux versions.

@camillof camillof merged commit e1363e4 into master Oct 27, 2022
@skydivedan
Copy link

...it does seem like for what it's worth that the version we currently have up for codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 actually works when I run it locally on my M1 mac :/

My guess is that it works because of the "Rosetta" layer on your Mac.

I tried using this in the latest CircleCI (which can run on M1 machines) and those machines don't have have Rosetta installed, apparently, because I get this message:

/bin/bash: ./cc-test-reporter: Bad CPU type in executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants