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

Fix: code coverage percent for gatorgrade files #157

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

hannahb09
Copy link

Code Coverage

Description

This is a fix so that gatorgrade when running the code coverage gets the right files which is gatorgrade files and leaves out empty files that have no code in the over all percentage. These are the code commands that should work. poetry run task coverage I got on linux
Screenshot from 2024-11-11 16-50-29
Screenshot from 2024-11-11 16-51-11
Screenshot from 2024-11-11 16-51-16
for poetry run task test I got
Screenshot from 2024-11-11 16-55-23
Screenshot from 2024-11-11 16-55-31
Screenshot from 2024-11-11 16-55-37

Type of Change

  • Feature
  • [X ] Bug fix
  • Documentation

Copy link
Collaborator

@PCain02 PCain02 left a comment

Choose a reason for hiding this comment

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

Based on the conversations from class today it looks like uploading the coverage.json is not a viable option and our coverage badge should be generated in actions and based on that. I was able to the coverage command to run however so that is good. I think we need to have more discussions about what to do about the .json file.

@hannahb09
Copy link
Author

today in lab professor said we are not gonna have it committed anymore so I updated and deleted it.

@gkapfham
Copy link
Collaborator

Hello @hannahb09 there is at least one revision that has been requested, can you please investigate this further?

@PCain02
Copy link
Collaborator

PCain02 commented Nov 21, 2024

So what is the plan going forward with coverage? Does it still work but no json is made or is it getting ignored in the .gitignore now? Because we will continue to run into problems with people commiting large json files on accident if it is not ignored and that adds to the size of our repo. Please keep me updated on the plan going forward! I'll take the changes requested off once I know this coverage process is resolved. Also is the same issue in execexam?

@hannahb09 hannahb09 requested a review from PCain02 November 22, 2024 16:54
@boulais01
Copy link
Collaborator

Hi @hannahb09, you've requested review but you haven't addressed the comments/questions here. Please do so.

@hannahb09
Copy link
Author

So what is the plan going forward with coverage? Does it still work but no json is made or is it getting ignored in the .gitignore now? Because we will continue to run into problems with people commiting large json files on accident if it is not ignored and that adds to the size of our repo. Please keep me updated on the plan going forward! I'll take the changes requested off once I know this coverage process is resolved. Also is the same issue in execexam?

We are ignoring the coverage.json file now on it has been added to the gitignore file and Kapfhammer has said we will not commit it from now on.

Copy link
Collaborator

@PCain02 PCain02 left a comment

Choose a reason for hiding this comment

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

I got an error when trying to run poetry run task coverage on Windows 10

image

C:\Users\Palla\AppData\Local\pypoetry\Cache\virtualenvs\gatorgrade-QO4nVhz5-py3.12\Lib\site-packages\_pytest\config\__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
UsageError: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
  config = pluginmanager.hook.pytest_cmdline_parse(
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")

@PCain02
Copy link
Collaborator

PCain02 commented Nov 26, 2024

I also noticed the coverage commands in the pyproject.toml file should be updated unless these are the correct commands and they just aren't working.

coverage-test-command = "pytest -s --cov-context=test --cov-fail-under=50 --cov-config .coveragerc --cov-report term-missing --cov-report json --cov --cov-branch"
coverage-test-command-silent = "pytest -x --show-capture=no --cov-config .coveragerc --cov-report term-missing --cov-report json --cov --cov-branch"

@PCain02
Copy link
Collaborator

PCain02 commented Nov 26, 2024

I got an error when trying to run poetry run task coverage on Windows 10

image

C:\Users\Palla\AppData\Local\pypoetry\Cache\virtualenvs\gatorgrade-QO4nVhz5-py3.12\Lib\site-packages\_pytest\config\__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
UsageError: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
  config = pluginmanager.hook.pytest_cmdline_parse(
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")

I think part of it is json isn't a valid option for a coverage report in this case. I was able to generate a coverage.xml by changing a couple things but I figure that messes with the pipeline by changing file types so that is not a good fix.

@hannahb09
Copy link
Author

I got an error when trying to run poetry run task coverage on Windows 10
image

C:\Users\Palla\AppData\Local\pypoetry\Cache\virtualenvs\gatorgrade-QO4nVhz5-py3.12\Lib\site-packages\_pytest\config\__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
UsageError: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
  config = pluginmanager.hook.pytest_cmdline_parse(
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")

I think part of it is json isn't a valid option for a coverage report in this case. I was able to generate a coverage.xml by changing a couple things but I figure that messes with the pipeline by changing file types so that is not a good fix.

I do not understand what is going wrong what you suggested is what is already in the pyproject.toml file. It be important to see if this works on Mac or the error still happens

@PCain02
Copy link
Collaborator

PCain02 commented Nov 26, 2024

I got an error when trying to run poetry run task coverage on Windows 10
image

C:\Users\Palla\AppData\Local\pypoetry\Cache\virtualenvs\gatorgrade-QO4nVhz5-py3.12\Lib\site-packages\_pytest\config\__init__.py:331: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
UsageError: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
  config = pluginmanager.hook.pytest_cmdline_parse(
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-report: invalid choice: "json" (choose from "['term', 'term-missing', 'annotate', 'html', 'xml']")

I think part of it is json isn't a valid option for a coverage report in this case. I was able to generate a coverage.xml by changing a couple things but I figure that messes with the pipeline by changing file types so that is not a good fix.

I do not understand what is going wrong what you suggested is what is already in the pyproject.toml file. It be important to see if this works on Mac or the error still happens

Yeah I am not convinced the toml file is set up properly.

@hemanialaparthi
Copy link
Collaborator

tested this on a mac and had the same issue where i tried to run the command poetry run task coverage and this was my output:

image

but here is the other command: poetry run task test, which looks like it works as intended:
image

@hannahb09 hannahb09 requested a review from PCain02 December 3, 2024 05:27
@hannahb09
Copy link
Author

tested this on a mac and had the same issue where i tried to run the command poetry run task coverage and this was my output:

image

but here is the other command: poetry run task test, which looks like it works as intended: image

I updated it so now it show work poetry run task coverage. Some of the pytest in pyproject.toml needed the numbers to be upped so it could run properly. There should be no json error now.

Copy link
Collaborator

@CalebKendra CalebKendra left a comment

Choose a reason for hiding this comment

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

LGTM, poetry run task coverage and poetry run task coverage-silent work well on Ubuntu

Copy link
Collaborator

@PCain02 PCain02 left a comment

Choose a reason for hiding this comment

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

image

There issues with the test cases. This is not your bug but still needs fixed. What is happening is that there is a test that wants gatorgrade to fail a check but it is displaying all this output! That is not good because it looks like things are failing! Please fix the toml file to update the commands.

@hannahb09
Copy link
Author

image

There issues with the test cases. This is not your bug but still needs fixed. What is happening is that there is a test that wants gatorgrade to fail a check but it is displaying all this output! That is not good because it looks like things are failing! Please fix the toml file to update the commands.

poetry run task test-silent makes the command work where the test just tells you how many passes.

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.

6 participants