jest-coverage-report-action: Problems running only collect coverage

Hi, I’m trying to use our action just to collect my report and comment on github that information, but I can’t run successfully.

My action:

      - name: Step 08 - Run Tests & Collect Coverage
        run: |
          echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
          cd ./kibana/plugins/wazuh-kibana-app
          ls -la
          echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
          yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json

      - name: Step 09 - Comment coverage
        uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
        with:
          working-directory: ${{ env.PATH_WAZUH-APP }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          skip-step: all

Error result:

Run artiomtr/jest-coverage-report-action@v2.0-rc.1
  with:
    github-token: ***
    skip-step: all
    test-script: npx jest --silent --ci --coverage --testLocationInResults --json --outputFile="report.json"
    icons: emoji
    annotations: all
    package-manager: npm
  env:
    “PATH_WAZUH-APP: /home/runner/work/wazuh-kibana-app/wazuh-kibana-app/kibana/plugins/wazuh-kibana-app/”
Could not read report file located at report.json [Error: ENOENT: no such file or directory, open 'report.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'report.json'
}
/usr/bin/git fetch --all --depth=1
fatal: not a git repository (or any of the parent directories): .git
Error fetching git repository Error: The process '/usr/bin/git' failed with exit code 128
    at f._setResult (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:11470)
    at f.CheckComplete (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:10900)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/artiomtr/jest-coverage-report-action/v2.0-rc.1/dist/index.js:2:9944)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:210:5)
    at Pipe.<anonymous> (net.js:659:12)
/usr/bin/git checkout -f 4.3-7.10
fatal: not a git repository (or any of the parent directories): .git
Error: The process '/usr/bin/git' failed with exit code 128


Here my action.yml

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@gabiwassan,

I think that the problem is that you’re changing directory in previous step, to collect coverage. You can try to simply remove working-directory option from your action.yml file, or just to exit working directory in previous step. So possible configurations could be:

  1. Remove working directory:
      - name: Step 08 - Run Tests & Collect Coverage
        run: |
          echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
          cd ./kibana/plugins/wazuh-kibana-app
          ls -la
          echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
          yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json

      - name: Step 09 - Comment coverage
        uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
        with:
#         working-directory: ./kibana/plugins/wazuh-kibana-app/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          skip-step: all
  1. Exit in previous step:
      - name: Step 08 - Run Tests & Collect Coverage
        run: |
          echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
          cd ./kibana/plugins/wazuh-kibana-app
          ls -la
          echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
          yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
#             ↓
          cd ../../..

      - name: Step 09 - Comment coverage
        uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
        with:
# and specify working directory ↓
          working-directory: ./kibana/plugins/wazuh-kibana-app/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          skip-step: all

Also, if these configurations not solved your issue, try to remove step 8 and let this action collect coverage for you:

      - name: Step 08 - Collect & comment coverage
        uses: artiomtr/jest-coverage-report-action@v2.0-rc.3
        with:
          working-directory: ./kibana/plugins/wazuh-kibana-app/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          test-script: yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json
          package-manager: yarn

If these solutions do not help you, then wait until #118 is merged into the master.

Hello @gabiwassan! 👋

Sorry for the late reply. As far as I can see, in your configuration the working-directory has correct value, but it is not being passed to the action. I’m not sure, but it seems to me that the issue is with the name of the variable: try to rename it so that no hyphen is used (for example PATH_WAZUH_APP). If that doesn’t work, try running an action with a configuration like this:

      - name: Step 08 - Run Tests & Collect Coverage
        run: |
          echo “PATH_WAZUH-APP=$GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/” >> $GITHUB_ENV
          cd ./kibana/plugins/wazuh-kibana-app
          ls -la
          echo $GITHUB_WORKSPACE/kibana/plugins/wazuh-kibana-app/
          yarn run test:jest --silent --ci --testLocationInResults --colors --coverage --json --outputFile=report.json

      - name: Step 09 - Comment coverage
        uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
        with:
#       here is the change    ↓
          working-directory: kibana/plugins/wazuh-kibana-app/
          github-token: ${{ secrets.GITHUB_TOKEN }}
          skip-step: all

Hope my answer will help you!