Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include test coverage results in GitHub Action CI script #1148

Open
dondi opened this issue Nov 13, 2024 · 8 comments
Open

Include test coverage results in GitHub Action CI script #1148

dondi opened this issue Nov 13, 2024 · 8 comments
Assignees

Comments

@dondi
Copy link
Owner

dondi commented Nov 13, 2024

In addition to running tests, we should start recapturing coverage results from the tests (formerly handled by Coveralls) and include this in the script as well. Per #1146, once we have coverage captured, it would be good to also include these results in the README badge

@akaiap
Copy link
Collaborator

akaiap commented Nov 20, 2024

  1. I will modify the Github Actions workflow to generate coverage reports
  • run: npm test -- --coverage --coverageReporters=text-lcov | coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} Need to confirm coveralls account in repo secrets
  1. Update README file
  • [![Coverage Status](https://coveralls.io/repos/github/<OWNER>/<REPO>/badge.svg?branch=master)](https://coveralls.io/github/<OWNER>/<REPO>?branch=master)
  • Test Test Test

@dondi
Copy link
Owner Author

dondi commented Nov 20, 2024

Instructions look good; learning about secrets systems comes with the territory so is a good aspect of these tickets

@akaiap
Copy link
Collaborator

akaiap commented Dec 4, 2024

What I have done so far

  • Updated the scripts in mocha
  • Did some tested and updated mocha's version.

-coverage: Uses nyc with mocha to run tests and collect coverage data.
coveralls: Generates a coverage report in LCOV format and pipes it to coveralls.
  • After removing Istanbul and installed I did some testing using npm run coverage and npm run coveralls
  • and success ! Screenshot 2024-12-04 at 12 30 13 PM
  • However, adding the coverage badge can get complicated due to GitHub "secrets." These secrets are admin tokens for Coveralls, and the safest approach is to avoid committing the token.

next steps to get the token:
Sign in to Coveralls.io with GRNSight account.
Enable repository if not already active.
Navigate to the repository's settings on Coveralls.
Copy the Repo Token provided.
Add the Token to GitHub Repository Secrets:

Click on Settings > Secrets and variables > Actions.
Click on New repository secret.
Name the secret COVERALLS_REPO_TOKEN.
Paste the token you copied from Coveralls.
Save the secret.

This way this token will not be pushed to the repo.

@dondi
Copy link
Owner Author

dondi commented Jan 15, 2025

The next steps for @akaiap are listed above, plus she will verify the preferred location for the secret

@akaiap
Copy link
Collaborator

akaiap commented Jan 22, 2025

  • While progressing to the next steps, I wanted to make sure I reproduce npm run coverage and npm run coveralls
  • However, after npm install, I was not able to npm run converalls or npm run coverage.
  • receiving this error -->
Image
  • Even after uninstalling Istanbul (and reinstalling) + reinstalling nyc I still receive the error. It looks like the local coverage script is still referencing istanbul cover _mocha somewhere, despite the package.json (but using NYC) not referencing Istanbul.
  • Within the terminal above I used the command npm run coverage --dry-run -- and received the same error.
  • Deleted package-json and node_modules --> npm install
  • Reasons: Within my own local copy

@dondi
Copy link
Owner Author

dondi commented Jan 22, 2025

@akaiap reported on the actions she took leading to the comment above; it looks like some setup questions need to be resolved:

  • Double-check that the coverage branch being worked on has indeed been pushed to origin
  • Double-check that the folder which VSCode is displaying is the same one as the folder on the command line
    • One pre-step is to open a terminal in VSCode (which is guaranteed to be the same one as the files being viewed) to see if that terminal behaves any differently
    • Use pwd command to get a full path for where you are

@akaiap
Copy link
Collaborator

akaiap commented Jan 28, 2025

I found the problem!

  • I have multiple GRNsight folders on my machine. I was cloned into the wrong one (lol) and this is why when I tried to replicate the command npm run coverage , it did not run and still referenced Istanbul instead of nyc.
  • The branch is there, so now to push this I need to follow the steps to run coveralls npm run coveralls command.
    As for right now -- this is the error you get when that command is run:
Image
  • While following the steps of attaining the coverage token, it still needs to be referenced within the yml file.
  • Ready to go! All we need is the token, which we can review tomorrow! :)

@dondi
Copy link
Owner Author

dondi commented Jan 29, 2025

@akaiap and @dondi will meet sometime next week to address the Coverall token issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants