ArtiomTr/jest-coverage-report-action

The process '/usr/bin/git' failed with exit code 128

bmeverett opened this issue ยท 15 comments

Describe a bug

After the recent releases, I've been seeing errors with pulling down code and running the tests. May be related to the updated package in #340 Can't determine which release it was as they 2.1.3 and 2.2.0 happened so close together over the weekend when I wasn't running tests.

Expected behavior

The action should be able to pull code and run as expect

Details

  • Action version: v2

  • OS, where your action is running (windows, linux): linux

  • action.yml file
    ```yml
    runs-on: ubuntu-latest
    steps:
        - uses: actions/checkout@v1
        - name: Use Node.js 16.15.0
          uses: actions/setup-node@v1
          with:
              node-version: 16.15.0
              registry-url: 'https://npm.pkg.github.com/'
        - uses: ArtiomTr/jest-coverage-report-action@v2
          with:
              test-script: npm run test:cov
              annotations: none
          env:
            NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
    ```
    
  • Screenshots
    <!-- If you encounter an incorrect coverage comment display, replace this comment with screenshot -->
    
    <!-- If your action unexpectedly fails, please replace this comment with a screenshot of your console  -->
    

Image 2023-02-06 at 11 40 17

</details>

Additional context

I am seeing this as well, this is rather recent as I recently went through upgrading other GitHub actions myself and this action was working fine on v2.

Reverted to the v2.1.3 version, so v2 should work now.

@bmeverett it looks like there is an issue with credentials. Do you use ssh? And could you please share the configuration, and how you check out your repo? Like configuration of actions/checkout step

@ArtiomTr here's my yaml, I'm just using the standard checkout action


runs-on: ubuntu-latest
steps:
    - uses: actions/checkout@v1
    - name: Use Node.js 16.15.0
      uses: actions/setup-node@v1
      with:
          node-version: 16.15.0
          registry-url: 'https://npm.pkg.github.com/'
    - uses: ArtiomTr/jest-coverage-report-action@v2
      with:
          test-script: npm run test:cov
          annotations: none
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Hey @bmeverett, everything should work now, published under the tag v2.2.1-rc.0. Currently doesn't set up this as the latest release, to avoid breaking things one more time ๐Ÿ˜ž

Could you please confirm, if the issue is fixed now?

Also, one thing to mention - you're using a v1 version of actions/checkout. That's OK, this action supports it. However, I highly recommend updating to the v2, or even v3 version. That's because v1 is an outdated version, which does several things that may mess everything up:

  1. It checkouts the repository in a "detached head" state. Usually, that's not what you want, as it may cause issues when checking out to the base branch.
  2. It doesn't configure git credentials correctly. So, this action will not work correctly when PRs are coming from forks.

Fortunately, the fix should be pretty easy - just replace v1 with v3:

runs-on: ubuntu-latest
steps:
    - uses: actions/checkout@v3 # <----- change version here
    - name: Use Node.js 16.15.0
      uses: actions/setup-node@v1
      with:
          node-version: 16.15.0
          registry-url: 'https://npm.pkg.github.com/'
    - uses: ArtiomTr/jest-coverage-report-action@v2.2.1-rc.0 # <----- use version with fix
      with:
          test-script: npm run test:cov
          annotations: none
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

@ArtiomTr we are still running into this issue even when using the new v2.2.1-rc.0 version and your provided fix with checkout@v3. Any ideas?

Hello @ocastx ๐Ÿ‘‹,

Could you please share action logs?

Hi @ArtiomTr, sure thing:

Running using node v16.18.1
Begin initialization stage...
Initialization stage ended
Begin stages.parsethreshold...
stages.parseThreshold ended
Begin stages.getbranch...
/usr/bin/git show -s --pretty=%D HEAD
grafted, HEAD, pull/26/merge
stages.getBranch ended
Begin stages.switchtohead...
/usr/bin/git fetch --depth=1 --dry-run https://github.com/redactedapp/redacted-id.git
From https://github.com/redactedapp/redacted-id
 * branch            HEAD       -> FETCH_HEAD
/usr/bin/git remote add covbot-pr-head-remote https://github.com/redactedapp/redacted-id.git
error: remote covbot-pr-head-remote already exists.
Failed to perform new algorithm for checking out. The action will automatically fallback and try to do as much as it could. However, this may lead to inconsistent behavior. Usually, this issue is caused by old version of `actions/checkout` action. Try to use modern version, like `v2` or `v3`.
/usr/bin/git fetch --depth=1
From https://github.com/redactedapp/redacted-id
 + 6437783...624f11b fix/ci     -> origin/fix/ci  (forced update)
/usr/bin/git checkout fix/ci -f
hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
hint: you can do so by fully qualifying the name with the --track option:
hint: 
hint:     git checkout --track origin/<name>
hint: 
hint: If you'd like to always have checkouts of an ambiguous <name> prefer
hint: one remote, e.g. the 'origin' remote, consider setting
hint: checkout.defaultRemote=origin in your config.
fatal: 'fix/ci' matched multiple (3) remote tracking branches
stages.switchToHead failed
Error: Error: The process '/usr/bin/git' failed with exit code 128
Error: The process '/usr/bin/git' failed with exit code 128
    at rh._setResult (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:17898)
    at rh.CheckComplete (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:17485)
    at ChildProcess.<anonymous> (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:16477)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
stages.switchToHead ended
Begin head coverage collection...
Head coverage collection skipped
Head coverage collection ended
Begin switching to base branch...
/usr/bin/git fetch --depth=1 --dry-run https://github.com/redactedapp/redacted-id.git
From https://github.com/redactedapp/redacted-id
 * branch            HEAD       -> FETCH_HEAD
/usr/bin/git remote add covbot-pr-base-remote https://github.com/redactedapp/redacted-id.git
error: remote covbot-pr-base-remote already exists.
Failed to perform new algorithm for checking out. The action will automatically fallback and try to do as much as it could. However, this may lead to inconsistent behavior. Usually, this issue is caused by old version of `actions/checkout` action. Try to use modern version, like `v2` or `v3`.
/usr/bin/git fetch --depth=1
/usr/bin/git checkout main -f
hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
hint: you can do so by fully qualifying the name with the --track option:
hint: 
hint:     git checkout --track origin/<name>
hint: 
hint: If you'd like to always have checkouts of an ambiguous <name> prefer
hint: one remote, e.g. the 'origin' remote, consider setting
hint: checkout.defaultRemote=origin in your config.
fatal: 'main' matched multiple (3) remote tracking branches
Switching to base branch failed
Error: Error: The process '/usr/bin/git' failed with exit code 128
Error: The process '/usr/bin/git' failed with exit code 128
    at rh._setResult (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:17898)
    at rh.CheckComplete (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:17485)
    at ChildProcess.<anonymous> (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:21:16477)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1100:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
Switching to base branch ended
Begin base coverage collection...
Base coverage collection skipped
Base coverage collection ended
Begin switching back to original branch...
/usr/bin/git fetch --all --depth=1
Fetching origin
Fetching covbot-pr-head-remote
From https://github.com/redactedapp/redacted-id
 + 6437783...624f11b fix/ci     -> covbot-pr-head-remote/fix/ci  (forced update)
Fetching covbot-pr-base-remote
From https://github.com/redactedapp/redacted-id
 + 6437783...624f11b fix/ci     -> covbot-pr-base-remote/fix/ci  (forced update)
/usr/bin/git checkout -f pull/26/merge
HEAD is now at cbcb1eb Merge 624f11bdb33d22ce99206ea2dffb511445633a3d into e2859d6a038231d705f68966f3935cace655e90c
Switching back to original branch ended
Begin stages.checkthreshold...
stages.checkThreshold skipped
stages.checkThreshold ended
Begin generating report...
Generating report failed
Error: TypeError: Cannot read properties of undefined (reading 'success')
TypeError: Cannot read properties of undefined (reading 'success')
    at CT (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:2218:293)
    at /Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:2230:15507
    at ei (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:2221:164)
    at UD (/Users/runner/actions-runner/_work/_actions/ArtiomTr/jest-coverage-report-action/v2.2.1-rc.0/dist/index.js:2230:15469)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Generating report ended
Begin report publish...
Report publish skipped
Report publish ended
Begin setting outputs...
Setting outputs skipped
Setting outputs ended
Begin failed tests' annotations publication...
Failed tests' annotations publication skipped
Failed tests' annotations publication ended
Begin coverage annotations publication...
Coverage annotations publication skipped
Coverage annotations publication ended
Error: Jest coverage report action failed
Error: Process completed with exit code 1.

@ocastx can you please also send me your action.yaml file? I just can't understand, the action tells that remotes covbot-pr-head-remote and covbot-pr-base-remote already exist

@ArtiomTr the action file looks like this

name: Pull Request
on:
  pull_request:

defaults:
  run:
    working-directory: functions

jobs:
  CI:
    runs-on: [self-hosted]
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version-file: "functions/package.json"
      - name: Create npmrc
        run: |
          echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
          echo "@redactedapp:registry=https://npm.pkg.github.com" >> .npmrc
      - name: Install
        run: npm i
      - name: Lint
        run: npm run lint
      - name: Jest coverage report
        uses: ArtiomTr/jest-coverage-report-action@v2.2.1-rc.0
        with:
          working-directory: functions
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

@ocastx tried to fix that, could you please test the solution?

        uses: ArtiomTr/jest-coverage-report-action@Improve-checkout-algorithm # <-- here
        with:
          working-directory: functions
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

@ArtiomTr yes the fix worked great!

@ocastx the fix is now available under v2.2.1 or just v2 tag

@ArtiomTr awesome thank you for the fast fix

Hi @ArtiomTr ๐Ÿ‘‹
I have the following action file:

 coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Install Node
        uses: actions/setup-node@v3
        with:
          node-version: '14'
      - name: Coverage Report Packages
        uses: ArtiomTr/jest-coverage-report-action@v2
        with:
          package-manager: yarn
          test-script: yarn run test:packages
          custom-title: Coverage report - Packages
      - name: Coverage Report Explorer
        uses: ArtiomTr/jest-coverage-report-action@v2
        with:
          package-manager: yarn
          working-directory: apps/@explorer
          test-script: yarn run test
          custom-title: Coverage report - Explorer

on the first coverage report everything goes fine. but the second report always fails. I can post the error logs, if you need it, but they look very similar to the one above.
Anyway, I manage to fix this by creating two separate jobs. But just wanted to make you aware of the issue.