ArtiomTr / jest-coverage-report-action

Track your code coverage in every pull request.
https://www.covbot.dev
MIT License
493 stars 142 forks source link

opt-out of comparison doesn't work well #376

Open earonesty opened 1 year ago

earonesty commented 1 year ago

the action still checks out the master branch, even if the base-coverage-file is specified

it is unclear where the base-coverage-file should live. i had jest produce a "report.json" and the code still looks in "master/report.json"

i think it would be better for there to be a simple option

with: comparision: false

or something.

boryscastor commented 1 year ago

Same here! I am trying to implement just a coverage on the current branch, without comparison (I also don't need it for the sack of time) - still fetches the main branch.

ChrisMBarr commented 4 months ago

Yes please, I also don't need it to compare anything. I just want it to show me the coverage from the current PR. I thought that was the whole point of this project anyway. Branch comparison seems like a huge extra step that should not be on by default.

For my company, we pay for GitHub enterprise, and anything that makes a build step take longer or store more artifacts actually can cost us real money. I'd love to have a way to simply run jest tests and report the results. That's all.

earonesty commented 4 months ago

i pip installed "diff-cover" https://pypi.org/project/diff-cover/. using that for now

ChrisMBarr commented 4 months ago

I ended up using https://github.com/MishaKav/jest-coverage-comment/

You run the tests separately, it generates report files, and then you point this action at the files. It also can show reports from multiple projects, useful for a monorepo

name: Pull Request Sanity Check

on:
  pull_request:
    paths-ignore: ['.vscode/**', 'README.md', '.*']

permissions:
  contents: write # allows actions to read & write files generated by the build steps, etc.
  pull-requests: write # allows actions to modify aspects of the PR, like adding comments, labels, etc.

jobs:
  pr-sanity-check:
    concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
    runs-on: ubuntu-latest
    steps:
      - name: 🧪 Unit Test Runner
        working-directory: server-nest
        run: npx jest --coverage --coverageReporters=text --coverageReporters=json-summary --reporters=jest-junit --reporters=github-actions

      - name: 🧪 Unit Test Reporter
        uses: MishaKav/jest-coverage-comment@main
        with: #we can have this report on code coverage in multiple projects
          title: Code Coverage Report
          multiple-files: |
            NestJS Server, ./server-nest/coverage/coverage-summary.json
          multiple-junitxml-files: |
            NestJS Server, ./server-nest/junit.xml