paambaati / codeclimate-action

GitHub Action to send your code coverage to CodeClimate
MIT License
201 stars 63 forks source link

Support arm64 runners #768

Open nirmalsunny opened 2 months ago

nirmalsunny commented 2 months ago

Describe the bug

The action is failing on arm64 based runners despite using the same config and node version as x64.

Run paambaati/codeclimate-action@v8.0.0
  with:
    coverageCommand: go test -race -coverpkg=./... -coverprofile=coverage.out ./...
    workingDirectory: .
    debug: true
    coverageLocations: coverage.out:gocov
    prefix: github.com/<org>/<repo-name>
    verifyDownload: true
    verifyEnvironment: true
  env:
    GO_VERSION: 1.[2](https://github.com/<org>/<repo-name>/actions/runs/10487987931/job/29049524157#step:5:2)3.0
    CC_TEST_REPORTER_ID: ***

/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter before-build
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 1: ELF: not found
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 1: ��: not found
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 1: ��: not found
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 1: �����c���c��c��$: not found
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 1: cannot open : No such file
/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter: 2: Syntax error: word unexpected (expecting ")")
Error: The process '/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter' failed with exit code 2
/opt/actions-runner/_work/_actions/paambaati/codeclimate-action/v8.0.0/node_modules/@actions/exec/lib/toolrunner.js:592
                error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
                        ^

Error: The process '/opt/actions-runner/_work/<repo-name>/<repo-name>/cc-reporter' failed with exit code 2
    at ExecState._setResult (/opt/actions-runner/_work/_actions/paambaati/codeclimate-action/v8.0.0/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/opt/actions-runner/_work/_actions/paambaati/codeclimate-action/v8.0.0/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/opt/actions-runner/_work/_actions/paambaati/codeclimate-action/v8.0.0/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:[3](https://github.com/<org>/<repo-name>/actions/runs/10487987931/job/29049524157#step:5:3)05:5)

Node.js v20.13.1
Error: 🚨 CC Reporter before-build checkin failed!

Node information

$ node -v
v18.20.4

$ node -e 'console.log(require("os").arch())'
arm64

Version of codeclimate-action you're using v8.0.0

Expected behavior The action to work the same way as it does on x64 systems.

Additional context Using self-hosted runners. v6 works.

paambaati commented 2 months ago

@nirmalsunny Thanks for reporting! I'm looking for a specific line –

Downloading CC Reporter from ...

in the output log, and it is missing.

Can you get me that URL from your workflow logs please? You can get them after setting ACTIONS_STEP_DEBUG environment variables to true and then re-running your workflow – see https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging#enabling-runner-diagnostic-logging

Note that this information is already required according to the bug report template.

nirmalsunny commented 2 months ago

Thank you for the reply.

Downloading CC Reporter from https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64

It looks wrong file is being downloaded.

paambaati commented 2 months ago

@nirmalsunny Interesting, this action uses the arch package to detect the runtime architecture; I'll need your help to take a closer look.

Can you execute this on your runner and paste the output here?

// npm i arch
var arch = require('arch')
console.log(arch())

Additionally, just to make sure you're using the right version of Node, can you also run these and paste the output here?

node -p "process.arch"
node -p "process.platform"
node -p "process.release"
node -p "process.config.variables.host_arch"
nirmalsunny commented 2 months ago
$ node -e 'console.log(require("os").arch())'
arm64

$ node -e "var arch = require('arch'); console.log(arch());"
x64

$ node -p "process.arch"
arm64

$ node -p "process.platform"
linux

$ node -p "process.release"
{
  name: 'node',
  lts: 'Hydrogen',
  sourceUrl: 'https://nodejs.org/download/release/v[18](https://github.com/<org>/<repo>/actions/runs/105063558290/job/291055832049#step:4:19).20.4/node-v18.[20](https://github.com/<org>/<repo>/actions/runs/105063558290/job/291055832049#step:4:21).4.tar.gz',
  headersUrl: 'https://nodejs.org/download/release/v18.20.4/node-v18.20.4-headers.tar.gz'
}

$ node -p "process.config.variables.host_arch"
arm64
paambaati commented 2 months ago

@nirmalsunny Thanks. I notice that you're using the x64 build of Node.js – shouldn't you be using https://nodejs.org/download/release/v18.20.4/node-v18.20.4-linux-arm64.tar.gz instead?

The problem here is that the arch module is reporting the architecture based on the Node.js binary and the platform it was built for – in your case, you're using the x64 version, when in fact, it should be arm64.

alejandrocelada-wiser commented 1 month ago

Same issue for me. I bumped from version v3.2.0 to v9.0.0. But I had to rollback since it seems that this error is present. This is the our runner info:

node -e "const arch = require('arch'); console.log(arch())" -> x64
node -p "process.arch"- > arm64
node -p "process.platform" -> linux
node -p "process.release" -> {
  name: 'node',
  lts: 'Hydrogen',
  sourceUrl: 'https://nodejs.org/download/release/v18.20.4/node-v18.20.4.tar.gz',
  headersUrl: 'https://nodejs.org/download/release/v18.20.4/node-v18.20.4-headers.tar.gz'
}
node -p "process.config.variables.host_arch" -> arm64 

In my case I don't have the ability to modify the runner, could we have a parameter where we hardcode the file instead of it being based on the node version? Or maybe in another previous step I should install the node version base on arm64?

nirmalsunny commented 1 month ago

Sorry for the delay.

I have updated the images to make sure that arm64 version of node is installed, and propagating those images to the runners needed some time.

I have also updated the cc to v9. But the error or the outputs from the commands above have not been changed. Either my images did not change or something wrong with node/arch?

I second the suggestion of having an input to specify architecture if it cannot be assumed. Thank you.

paambaati commented 1 month ago

Thanks for the details, folks. I will add an option to override the download URL in a forthcoming release.