Skip to content

Conversation

jcq
Copy link
Contributor

@jcq jcq commented Dec 20, 2023

Ticket

Resolves #106

Changes

added GH Actions workflow that uses an existing Marketplace script to provide Jest code coverage reports on PRs

Copy link

github-actions bot commented Dec 20, 2023

Coverage report for app

St.
Category Percentage Covered / Total
🟡 Statements 76.54% 62/81
🟡 Branches 64.29% 9/14
🟡 Functions 71.43% 10/14
🟡 Lines 75% 54/72

Test suite run success

7 tests passing in 3 suites.

Report generated by 🧪jest coverage report action from db4cd3f

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ArtiomTr/jest-coverage-report-action@v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on folding this into the existing test workflow so it doesn't have to rerun the tests?

To bypass running unit tests, you can pass the filepath to the current report.json

https://github.com/ArtiomTr/jest-coverage-report-action?tab=readme-ov-file#use-existing-test-reports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think ultimately we'd want to have it run through only once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think I've got it incorporated into the existing workflow such that the only extra work it is doing is the necessary run of tests for the main branch (for comparison).

Comment on lines 4 to 6
branches:
- master
- main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it do this instead, so it runs on any pull request that touches an app file? This is what we do on ci-app.yml

Suggested change
branches:
- master
- main
paths:
- app/**
- .github/workflows/ci-jest-coverage.yml

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ArtiomTr/jest-coverage-report-action@v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see in their docs that it can "Comparing coverage with base branch". Were you able to test that out or is it dependent on something existing on the base branch first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I think we've got that working, though it's difficult to tell in this actual PR since it isn't changing any files that would be covered. As mentioned in this discussion, apparently the spoiler tags w/ more info (& comparisons) only show up if there are relevant files that are changed.

I could add some sort of TS file here in this PR for testing, but I'm more inclined to just try merging this and see how it works on other PRs. Open to other thoughts though!

Copy link

Coverage report for app

St.
Category Percentage Covered / Total
🟡 Statements 76.54% 62/81
🟡 Branches 64.29% 9/14
🟡 Functions 71.43% 10/14
🟡 Lines 75% 54/72

Test suite run success

7 tests passing in 3 suites.

Report generated by 🧪jest coverage report action from 3ed541b

@jcq jcq merged commit b98d1cc into main Dec 22, 2023
@jcq jcq deleted the jcq/106-ci-jest-coverage branch December 22, 2023 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add test coverage stats on PRs
2 participants