question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems running only collect coverage

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ArtiomTrcommented, Aug 5, 2021

@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.

1reaction
ArtiomTrcommented, Jul 22, 2021

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest finds tests but doesn't collect coverage - Stack Overflow
I found that when upgrading jest (from 23 to 26) that i had this issue, and the resolution was to run with the...
Read more >
Troubleshooting Code Coverage - Visual Studio (Windows)
Learn how to resolve erroneous empty results messages when you expect Visual Studio to collect data for native and managed assemblies.
Read more >
Test coverage visualization - GitLab Docs
With the help of GitLab CI/CD, you can collect the test coverage information of your favorite testing or coverage-analysis tool, and visualize this ......
Read more >
Compiling for Coverage — gcovr 5.1 documentation
In order to collect coverage data, your software must be “instrumented” by the compiler. That means, you must re-compile your software with special...
Read more >
Jest CLI Options
Run only the tests that were specified with a pattern or filename: ... Indicates that test coverage information should be collected and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found