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.

Base coverage collection skipped with base coverage file provided

See original GitHub issue

Describe a bug

The base coverage collection is still beeing skipped although a base coverage file is provided by the configuration. That means no coverage diff is reported on the PR comment. My Bugfix from #239 was supposed to fix this issue but it does not seem to work. I would look into it myself, but I do not have the time right now. If this is not picked up until next week I will come back to it myself.

Expected behavior

Base coverage is collected from the provided coverage file and coverage diff percentage is shown in the PR comment. Also the branch should remain unchanged. We know it was working before when branches where switched, but that should be unnecessary and can cause other errors (see #236)

Details

Action version: 2.0.4 OS, where your action is running (windows, linux): linux

action.yml file
name: Test, build & Docker push
on: pull_request

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        # We need full history for commitlint.
        with:
          fetch-depth: 0

      - name: Get coverage cache
        uses: actions/cache@v2
        with:
          key: base-coverage-${{ github.ref }}
          restore-keys: base-coverage-${{ github.base_ref }}
          path: ./coverage/base-report.json
      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: '16.14.0'
          cache: 'yarn'
      - name: Install project dependencies
        run: yarn --frozen-lockfile

      - name: Run linting
        if: ${{ false }}
        run: yarn lint
      - name: Run tests
        run: yarn test --runInBand --coverage --coverageThreshold '{}' --testLocationInResults --json --outputFile=./coverage/report.json

      # make sure the file exists
      - run: cat ./coverage/base-report.json
      - uses: artiomtr/jest-coverage-report-action@v2.0.4
        # It will annotate failing tests as well, so we can run it always.
        if: always()
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          package-manager: yarn
          coverage-file: ./coverage/report.json
          base-coverage-file: ./coverage/base-report.json
          annotations: all
          skip-step: all
Screenshots

image image

Additional context

Log output
Run artiomtr/jest-coverage-report-action@v2.0.4
  with:
    github-token: ***
    package-manager: yarn
    coverage-file: ./coverage/report.json
    base-coverage-file: ./coverage/base-report.json
    annotations: all
    skip-step: all
    test-script: npx jest
    icons: emoji
Run $GITHUB_ACTION_PATH/run.sh
  $GITHUB_ACTION_PATH/run.sh
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    INPUT_GITHUB-TOKEN: ***
    INPUT_TEST-SCRIPT: npx jest
    INPUT_THRESHOLD: 
    INPUT_WORKING-DIRECTORY: 
    INPUT_ICONS: emoji
    INPUT_ANNOTATIONS: all
    INPUT_PACKAGE-MANAGER: yarn
    INPUT_SKIP-STEP: all
    INPUT_CUSTOM-TITLE: 
    INPUT_COVERAGE-FILE: ./coverage/report.json
    INPUT_BASE-COVERAGE-FILE: ./coverage/base-report.json
Running using node v16.14.0
Begin initialization stage...
Initialization stage ended
Begin stages.parsethreshold...
[...] (unrelated esbuild warning about jest.config.ts)
stages.parseThreshold ended
Begin head coverage collection...
Begin installing dependencies...
Installing dependencies skipped
Installing dependencies ended
Begin running tests...
Running tests skipped
Running tests ended
Begin collecting coverage...
Loading code coverage from file: coverage/report.json
Collecting coverage ended
Begin parsing coverage...
Parsing coverage ended
Head coverage collection ended
Begin switching to base branch...
Switching to base branch skipped
Switching to base branch ended
Begin base coverage collection...
Base coverage collection skipped
Base coverage collection ended
Begin switching back to original branch...
Switching back to original branch skipped
Switching back to original branch ended
Begin stages.checkthreshold...
stages.checkThreshold ended
Begin generating report...
Generating report ended
Begin report publish...
Report publish ended
Begin failed tests' annotations publication...
Failed tests' annotations publication skipped
Failed tests' annotations publication ended
Begin coverage annotations publication...
Coverage annotations publication ended

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Raigencommented, Mar 7, 2022

I tried artiomtr/jest-coverage-report-action@v2.0.5 and it works as expected. Thanks!

0reactions
venux92commented, Aug 26, 2022

@Raigen Thanks for the clarification, make sense now, thank you =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems running only collect coverage #113 - GitHub
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....
Read more >
Command line usage — Coverage.py 6.4.4 documentation
The --skip-covered switch will skip any file with 100% coverage, letting you focus on the files that still need attention. The --no-skip-covered option...
Read more >
lcov not working properly for coverage - gcov - Stack Overflow
Firstly I would suggest to check if gcov returns correct coverage data. Means need to run gcov tool and check *.gcov file for...
Read more >
Unexpected Coverage Changes - Codecov
There are many reasons why coverage may change in unexpected ways. Centrally, these occur in files that are not directly changed in the...
Read more >
Publish code coverage results v1 task - Microsoft Learn
Code coverage tool. Default: JaCoCo. summaryFileLocation: # string. Required. Summary file. #pathToSources: # string. Path to Source files ...
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